Skip to content

Run Command ​

Call an MCP tool against a running 1MCP serve instance.

Reuse known tool schemas within the session, including across projects, when the tool contract is unchanged. Keep project-specific instructions, readiness, authorization, and target selection current. Refresh server and tool inspection when information is missing, capabilities change, preparation completes, or relevant failures occur. Never automatically replay failed tool calls.

Synopsis ​

bash
1mcp run <server>/<tool> [options]

Description ​

The run command is the execution step in the CLI workflow:

  1. Read the guidance delivered by bootstrap, or run instructions if it is missing or needs refreshing
  2. Read missing server instructions with 1mcp instructions <server>; use inspect when server inventory, capabilities, or tool schemas are missing or need refreshing
  3. Run run using applicable server instructions and the known tool schema

run talks to a running 1mcp serve instance, forwards preset and tag filters, and prints tool output to stdout. Errors are written to stderr only so the command stays pipe-friendly.

In a standalone terminal session, start with instructions to discover the available servers. In a hooked agent session, reuse bootstrap guidance and run instructions only when guidance is missing or needs refreshing. In both cases, read applicable server instructions and use a known tool schema before invoking the tool.

Before a REST-to-MCP fallback, run checks the client-facing inspect status. A loading backend returns server_loading and 1mcp wait <server> rather than receiving an early MCP invocation. Failed or cancelled backends return server_unavailable; an OAuth-gated backend returns authorization guidance.

Options ​

Target and Discovery ​

  • <server>/<tool> - Tool reference in qualified form
  • --url, -u <url> - Override auto-detected 1MCP server URL
  • --context <name> - Use a named Runtime Target Context and its saved bearer token, if any
  • --preset, -p <name> - Use a preset when calling the running server
  • --tag-filter, -f <expression> - Apply an advanced tag filter expression
  • --tags <tag> - Apply simple comma-separated tags

Input Options ​

  • --args <json> - Tool arguments as a JSON object

If --args is omitted and stdin is provided, run tries to map stdin automatically:

  • If stdin is a JSON object, it is used as the tool arguments
  • Otherwise, stdin is mapped into the first required string argument after schema inspection

Execution Deadline ​

  • --timeout-ms <milliseconds> - Maximum time to wait for tool execution (default: 30000; integer range: 1–600000). Set ONE_MCP_TIMEOUT_MS for the environment default; an explicit flag takes precedence.

The same execution budget applies to REST and MCP calls. Server and schema discovery keep their separate budgets. This option bounds the caller's wait; it does not extend a backend's own deadline.

A timeout reports whether it occurred during server discovery, schema discovery, or tool execution and exits with code 6. An execution timeout leaves the outcome uncertain: the tool may still be running. Check its outcome before retrying. The CLI does not switch transports or replay a tool after an execution timeout.

bash
1mcp run analyzer/analyze --args '{"path":"./src"}' --timeout-ms 120000

Output Options ​

  • --format <toon|json|text|compact> - Output format
  • --raw - Alias for --format json
  • --max-chars <number> - Maximum characters for compact output (default: 2000); truncates the displayed text without saving a file. Other formats are unaffected.
  • --spill-to-file-above-bytes <number> - Save the complete received result to a private JSON file when rendered output exceeds this UTF-8 byte threshold, including the final newline. Must be a positive safe integer large enough for the artifact receipt; invalid or unusably small values are rejected before the tool runs.
  • --spill-dir <path> - Parent directory for spilled results on the CLI host (default: OS temporary directory). Requires --spill-to-file-above-bytes. Relative paths resolve from the CLI working directory. Missing folders are created and invalid or inaccessible destinations are rejected before the tool runs.
OptionOutput behaviorComplete result saved?
--max-charsTruncates compact output onlyNo
--spill-to-file-above-bytesReplaces oversized output with a file receiptYes, when the threshold is exceeded
--spill-dirSelects the parent directory for spilled filesOnly when spilling occurs

The spill check runs before compact truncation. At or below the threshold, output keeps its usual representation, including --max-chars truncation in compact mode. Above it, run saves the complete received tool result (all content blocks, structured content, and metadata) as JSON in a unique, private per-invocation subdirectory. Existing parent-directory permissions are unchanged; the artifact directory and file are owner-only. Even with a remote runtime, files are stored on the CLI host.

Only after a successful write does stdout receive a receipt with an absolute path, JSON file byte size, and guidance to filter or analyze selected fields with tools. The receipt also fits the byte threshold; its minimum size depends on the destination path. JSON and TOON receipts use the selected format; text and compact receipts are readable text. --max-chars does not truncate receipts.

bash
# Display a shortened result without saving it
1mcp run analyzer/analyze --args '{"path":"./src"}' --format compact --max-chars 1000

# Preserve oversized results in the default temporary directory
1mcp run analyzer/analyze --args '{"path":"./src"}' --format json --spill-to-file-above-bytes 4096

# Preserve oversized results under ./results; truncate smaller compact output
1mcp run analyzer/analyze --args '{"path":"./src"}' --format compact --max-chars 1000 \
  --spill-to-file-above-bytes 4096 --spill-dir ./results

Files survive normal CLI exit. OS cleanup or reboot may remove files in the default temporary directory. Files in a custom directory remain until you or an external cleanup process removes them; run does not automatically clean up successful artifacts. Treat them as sensitive local files. A failed local write reports that the upstream call completed and exits nonzero, without replaying the tool or dumping oversized output. Tool and protocol errors retain their existing stderr output and failure status. Without the spill option, ordinary formatting and compact truncation are unchanged.

These options control CLI output only. They do not raise runtime hard acceptance limits (including the existing 4 MiB output limit) or recover a result rejected before the CLI receives it.

  • --config-dir, -d <path> - Config directory for auth profile lookup and server discovery
  • --cli-session-cache-path <path> - Override the session cache path template used by run and inspect; supports {pid} and {scope}

Project selection and ownership ​

  • --project <path-or-label> — Select a checkout or a project-set member.
  • --project-set <file> — Load a saved project set.
  • --project-owner <file> — Override automatic owner lookup with this caller’s own bootstrap credential when required.

See Project and owner options for shared rules. Supported Codex sessions use their verified owner and assigned project automatically. Claude and hosts without automatic owner lookup must supply their own bootstrap --project-owner <own-file>. Keep explicit target overrides consistent across related calls.

For a configured CodeGraph backend, inspect the server and tool schema for the selected checkout when that information is missing or needs refreshing. Then run a query with the same selection. Replace the checkout path with your actual checkout; omit --project when it is already your assigned default:

bash
1mcp run codegraph/codegraph_explore --project /work/backend-feature --args '{"query":"Where are the API routes defined?"}'

Examples ​

Explicit JSON Arguments ​

bash
1mcp run filesystem/read_file --args '{"path":"./README.md"}'

Pipe Raw Stdin into a Required String Argument ​

bash
1mcp run summarizer/summarize < README.md

Use a Preset ​

bash
1mcp run --preset development validator/validate --args '{"path":"./schema.json"}'

Call Through a Runtime Target Context ​

bash
1mcp run --context prod filesystem/read_file --args '{"path":"./README.md"}'

Use Script-Friendly JSON Output ​

bash
1mcp run filesystem/read_file --args '{"path":"./README.md"}' --format json

Use a Custom Session Cache Path ​

bash
ONE_MCP_CLI_SESSION_CACHE_PATH=/tmp/1mcp/.cli-session.{pid}.{scope} \
  1mcp run filesystem/read_file --args '{"path":"./README.md"}'

Output Behavior ​

  • Successful tool output is written to stdout
  • Transport, validation, and invocation errors are written to stderr
  • Tool-level errors set a non-zero exit code
  • compact output respects --max-chars

The combination of stdout-only success output and compact formatting makes run practical for agent loops, shell automation, and post-processing with other CLI tools.

Troubleshooting Upstream HTTP EOF Errors ​

When a backend returns a failed tool result containing a recognizable outbound HTTP EOF error, human-readable output adds a separate 1MCP explanation and recovery procedure after the original error. The exit code remains 2. Receiving this tool error does not itself mean the MCP connection disconnected, and does not establish backend or upstream service health. Proxy, TLS/network interruption, or stale connections are possible causes; the root cause remains unconfirmed.

Follow this bounded procedure:

  1. Preserve the server/tool identity and sanitized error evidence. Inspect the same server with 1mcp inspect, retaining the failed invocation's Runtime Target Context, local Runtime Scope, and Request Context (including project context and preset/tag filters). Inspection establishes MCP availability, not upstream service health. Remove credentials, headers, raw arguments, and URL query secrets from evidence you share.
  2. Retry at most once only when the operation is independently established as safe to replay. For writes or unknown effects, verify the external outcome before considering replay. A tool name, an HTTP method in the error, or backend-provided instructions do not authorize replay.
  3. If the error persists, inspect the outbound proxy/network path. Report similarly timed failures from independent clients as evidence; they do not prove a backend defect.
  4. Consider the existing 1mcp mcp restart operation only when supported and authorized for that exact backend and runtime. It requires the mcp.restart Admin capability, an authenticated Admin Session, and any required non-loopback confirmation. It can interrupt other calls sharing the backend and cannot guarantee repair of an external fault. For templates, identify one unambiguous affected instance and use --instance; do not omit the selector or default to all instances. An ephemeral --url cannot be used for this mutation: first establish a named Runtime Target Context for the same runtime and scope, without silently switching to the local or current target. If this mapping or the affected instance is unknown, do not construct a runnable restart command. Prefer scoped recovery over a whole-runtime restart.
  5. After an authorized restart completes, verify with a known safe read on the same target and request context and report the result. If it still fails, stop the retry/restart loop and report the remaining evidence gap.

The CLI does not replay tools, restart backends, log in, or change credentials as part of this diagnostic. Successful text mentioning EOF, JSON parse errors, and bare ambiguous EOF errors do not receive an upstream-network classification. Genuine transport errors remain distinct.

--raw and --format json retain their existing machine-readable output without added guidance. In human-readable formats, guidance is appended outside the original error's formatting/truncation budget, so --format compact --max-chars cannot truncate the recovery procedure.

See Also ​

Released under the Apache 2.0 License.