# cs mcp (/docs/cli/mcp)

`cs mcp` runs the CoreSpeed MCP endpoint's tools under your session. An
organization can have more than a thousand of them, so an agent (or a person)
works in three steps instead of reading them all: search for the task, get the
one tool it picked, call it. Because the session is a member session, it can
also do what an API key cannot, such as mint a key with `manage__keys_create`.

## Usage \[#usage]

```bash
cs mcp search <words…> [--limit <n>] [--json]
cs mcp get <tool> [--json]
cs mcp call <tool> [jsonArgs|-] [--raw]
cs mcp list [--json]
```

```bash
cs mcp search search tweets
cs mcp get twitter__search_posts
cs mcp call twitter__search_posts '{"query": "from:corespeed", "account": "@corespeed"}'
```

## search \[#search]

`cs mcp search` ranks your tools for a need described in words and prints one
line per match, best first: the tool name, its declared hints (`read-only`,
`destructive`) and the first sentence of its description.

```text title="Output"
twitter__search_posts [read-only]  Search recent posts on X (Twitter).
twitter__create_post  Post a new tweet, or reply with reply_to_id.
social__x_search [read-only]  Search public X posts by keyword (search_type Top | Latest | Media | People | Lists; paginate with cursor).
```

It matches tool names, descriptions and argument names and descriptions, so
describe the task rather than guessing an identifier. It prints the ten best
matches; `--limit` changes that, and `--json` prints the matches' full
definitions instead. A tool only exists here once its connector is connected
([`cs connectors list`](/docs/cli/connectors)).

## get \[#get]

`cs mcp get` prints one tool in full: its description as written, its input
schema (and output schema) verbatim — every type, range, default and required
field the tool declares — and a call to start from. For a tool that takes
`account`, it also lists the accounts connected for that connector; `account`
is required when there is more than one.

```text title="Output"
twitter__search_posts [read-only]

Search recent posts on X (Twitter). Returns up to max_results posts matching the query.

Input schema:
{
  "type": "object",
  "properties": { … },
  "required": ["query"]
}

Connected accounts (pass one as account): @acme, @corespeed

Call it:
  cs mcp call 'twitter__search_posts' '{"query":"<string>","account":"@acme"}'
```

On Windows the call is written for PowerShell, which pipes the arguments in
(see [call](#call)):

```text title="Output on Windows"
Call it (PowerShell):
  $OutputEncoding = [Text.UTF8Encoding]::new($false); echo '{"query":"<string>","account":"@acme"}' | cs mcp call twitter__search_posts -
```

`--json` prints the tool's definition exactly as `tools/list` declares it. An
unknown name exits `1` and names the closest tools.

## list \[#list]

`cs mcp list` prints every tool you can call, one line each in the same format
as `search`, already filtered to your connected accounts and enabled
capabilities. `--json` prints the tools' definitions exactly as `tools/list`
declares them:

```bash
cs mcp list --json | jq -r '.[].name'
```

## call \[#call]

`cs mcp call` invokes one tool with JSON arguments and prints its result. The
arguments must be a single valid JSON object.

```bash
cs mcp call memory__search '{"query": "rollout window"}'
cs mcp call manage__whoami
```

With `-` for the arguments, `cs mcp call` reads them from stdin. Use it in
Windows PowerShell, which removes the `"` inside an argument it passes to a
program, so `'{"query": "x"}'` arrives as `{query: x}`:

```powershell
$OutputEncoding = [Text.UTF8Encoding]::new($false)
echo '{"query": "发布窗口"}' | cs.cmd mcp call memory__search -
```

In PowerShell, type `cs.cmd` for a `cs` installed with npm, or
`npx.cmd @corespeed/cs@latest` ([why](/docs/cli#windows-powershell)). Set
`$OutputEncoding` first in Windows PowerShell 5.1: it pipes text to a program
in ASCII and turns every other character, such as 发布窗口, into `?` before
`cs` reads it. PowerShell 7 pipes UTF-8 already. A `\uXXXX` escape in the
JSON gets through either way.

A blank stdin sends no arguments. To pass the arguments from a file, redirect
it in a POSIX shell or Command Prompt: `cs mcp call memory__search - <
args.json`. PowerShell has no `<`. On Windows, the calls `cs` prints itself —
in `cs mcp get`, and when a call waits for approval — use the piped form, in
ASCII.

The result is the tool's `structuredContent` when it returns one: the MCP spec
makes that the result data, validated against the tool's output schema, and
the text a tool adds beside it is a copy for clients that cannot read it. When
that text is more than a JSON copy of the result, a line on `stderr` says it was
not shown. Some tools put their answer in the text and only metadata in
`structuredContent` — `media__understand` does — so read those with `--raw`. A
tool without `structuredContent` prints its content: JSON text pretty-printed,
other text as written, and a one-line summary for images, audio and resources
instead of their bytes. Numbers and strings are printed exactly as the server
sent them, 64-bit integers included.

`--raw` prints the `CallToolResult` exactly as it arrived — `content`,
`structuredContent`, `isError` and `_meta`:

```bash
cs mcp call twitter__search_posts '{"query": "from:corespeed"}' --raw \
  | jq -r '.content[0].text | fromjson | .data[].id'
```

The result is printed whatever it says. The exit code then says whether the
tool did what it was asked, and the reason goes to `stderr`:

| Code | The call                                                                                                |
| ---- | ------------------------------------------------------------------------------------------------------- |
| `0`  | Ran and succeeded.                                                                                      |
| `1`  | Was refused: the tool answered `isError: true`, the tool does not exist, or the arguments were invalid. |
| `4`  | Did not run because of the organization's standing, such as its balance or a suspension.                |
| `5`  | Hit a CoreSpeed failure. Retry later.                                                                   |
| `6`  | Is waiting for a human's approval and has not run.                                                      |

A call that waits for approval prints the approval id and the call that waits
for the decision. Run it right away, because the request expires if nobody
waits on it:

```bash
cs mcp call manage__approval_wait '{"approval_id": "…"}'
```

Read [Error handling](/docs/errors) for what to do with each error code.