# MCP

> Let an MCP client search a workspace, read requests, list environments, and send and run requests through Porticol.

Canonical: https://porticol.app/docs/mcp

[View as Markdown](https://porticol.app/docs/mcp.md)

An MCP server lets an MCP client, such as Claude Code, use a team's collections through Porticol: search the workspace, read requests and examples, list environments, send and run requests, with secrets resolved inside Porticol and masked before they leave. Two transports serve the one tool table: standard input and output on the machine, and streamable HTTP on a server. There are no server-sent events and no server-initiated messages.

## Tools

| Tool | Scope | What it does |
| --- | --- | --- |
| `search` | Read | Search collections, requests and history for a query |
| `read` | Read | Read a collection with its requests and examples, or one request of it |
| `environments` | Read | List the environments, or read one by id |
| `send` | Read | Send a request and return what came back |
| `run` | Read | Run a collection and wait for it, returning the finished run |
| `history` | Read | List recent sends, or read one by id |
| `import_openapi` | Read | Preview an OpenAPI document as a collection, without importing it |
| `create_request` | Write | Add a request or folder to a collection |
| `update_request` | Write | Replace what a request or folder holds |
| `commands` | Read | List the app's commands an agent may run, and what each does |
| `command` | Read or write | Run one of the app's commands by name; the target command's scope decides |

`import_openapi` only previews; bringing the collection into the workspace stays a person's decision. `run` starts the run, waits for it, and returns it finished; when the wait runs out it returns the run still going instead.

## Resources

Beside the desktop, the workspace is also readable as MCP resources, so an agent can read context without spending a tool call on discovery:

- `porticol://workspace/collections`
- `porticol://workspace/collection/{id}`
- `porticol://workspace/environments`
- `porticol://workspace/history`
- `porticol://workspace/run/{id}`

Every resource is masked the same way a tool result is.

## Prompts

`prompts/list` names the built-in workflows: `run-collection`, `debug-request` and `import-openapi`. Each takes the person's arguments and tells the agent which tools to call and which guardrails to keep, so a client can show them in its slash menu.

## Scopes and guardrails

The standard input server serves the dedicated tools and the command bridge, including the two write tools. The streamable HTTP transport lists what its token's scope allows: a read-only token lists the read tools only, and `collection:write` adds the two write tools. Either way, a call outside the scope is refused.

`commands` lists every command the app has, with `use` set to `tool`, `handoff` or `excluded`, and a note for the last two. `command` runs one by name through the same dispatcher as the app, so the plan, the workspace role and every other check apply exactly as they do when a person does it. A `handoff` means ask the person to do it in Porticol; an `excluded` means do not try.

Secrets resolved inside Porticol never leave it in the clear: every tool result that can carry a secret is masked with the same redaction history relies on, over every secret value the workspace holds.

## Guard and approvals

Every `send` and `run` goes through Porticol Guard's policy: the agent's ceiling for the environment, then the first matching rule, then the default. The [Guard page](https://porticol.app/guard) has the three levels and the policy schema.

When a call needs a person, `send` or `run` holds it for up to 45 seconds and returns:

```json
{
  "status": "pending",
  "approval_id": "8f0c…",
  "reason": "DELETE to production needs a person.",
  "message": "A person must approve this call in Porticol. Call send again with the same request and approval_id once they have. Do not loop and do not ask for a secret."
}
```

A person approves the exact request in the app's approval card, or with `porticol-cli approve <id>` and the four-letter code shown on the card. The approval is bound to a SHA-256 of the request the policy decided: the method, URL, environment, headers, auth, protocol, settings and body. It is single use and expires after 10 minutes. Retry once with the same request and `approval_id`; a changed request does not match. **Allow for today** makes a rule-scoped allowance until local midnight.

A denied call returns `{"status": "denied", "reason": "…", "rule": "…"}` and is not retried. A call above the agent's ceiling is denied before any rule. Both `send` and `run` accept an optional `approval_id` and `reason`.

An agent's send is recorded with the client's name, which is self-reported.

## Connect a client

For install, agent setup and every client in one place, see [AI agents](https://porticol.app/docs/ai-agents).

The Mac install puts `porticol-cli` in `/usr/local/bin`, `/opt/homebrew/bin` or `~/.local/bin`, whichever it can write; `~/.local/bin` is not on macOS's `PATH` by default, so the script prints the line to add if it chose that folder. On Windows and Linux take the archive from the [download page](https://porticol.app/download#cli).

Each client starts it with `porticol-cli mcp`; add `--read-only` to serve the read tools alone.

Claude Code:

```sh
claude mcp add porticol -- porticol-cli mcp
```

Cursor, in `~/.cursor/mcp.json` (`%USERPROFILE%\.cursor\mcp.json` on Windows):

```json
{ "mcpServers": { "porticol": { "command": "porticol-cli", "args": ["mcp"] } } }
```

Codex, in `~/.codex/config.toml` (`%USERPROFILE%\.codex\config.toml` on Windows):

```toml
[mcp_servers.porticol]
command = "porticol-cli"
args = ["mcp"]
```

VS Code, in `.vscode/mcp.json` in the folder you open (`%USERPROFILE%\.vscode\mcp.json` to have it everywhere):

```json
{ "servers": { "porticol": { "type": "stdio", "command": "porticol-cli", "args": ["mcp"] } } }
```

## Standard input and output

`porticol-cli mcp` serves the workspace on the machine, with no account:

```
porticol-cli mcp [--data-dir <path>] [--read-only]
```

It speaks MCP JSON-RPC over standard input and output: `initialize`, `notifications/initialized`, `tools/list`, `tools/call`, `resources/list`, `resources/read`, `prompts/list`, `prompts/get` and `ping`. Without `--read-only` the server serves the whole MCP tool table, including the write tools; with it, the two write tools are left out. The workspace served is `--data-dir`, `PORTICOL_DATA_DIR`, or the desktop's data folder. Secret values live in the machine's keychain under the desktop; a workspace served here resolves the secrets created through it.

## Streamable HTTP

`POST /api/v1/mcp` serves the dedicated tools on a server, with the API token's scope: a read-only token lists the read tools only, and `collection:write` adds the two write tools. It answers `initialize`, `tools/list` and `tools/call` as plain JSON responses. Every `tools/call` writes one audit entry named `mcp.<tool>` with the token's id. A command that only runs beside the user, such as sending, is refused over HTTP; agents send through the standard input transport beside the workspace.
