One change
Connect to external tools with MCP
agent-sdk/mcp
Nearest release: v2.1.238, published an hour before this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
agent-sdk/mcp Changed · +31 / -52 lines
from line 300
### HTTP/SSE servers -Use HTTP or SSE for cloud-hosted MCP servers and remote APIs: +Use HTTP or SSE for cloud-hosted MCP servers and remote APIs. For the `.mcp.json` form, use the same fields as the example at [HTTP headers for remote servers](#http-headers-for-remote-servers), with `"type": "sse"` for an SSE server. In code, pass the server's URL: -<Tabs> - <Tab title="In code"> - <CodeGroup> - ```typescript TypeScript hidelines={1,-1} theme={null} - const _ = { - options: { - mcpServers: { - "remote-api": { - type: "sse", - url: "https://api.example.com/mcp/sse", - headers: { - Authorization: `Bearer ${process.env.API_TOKEN}` - } - } - }, - allowedTools: ["mcp__remote-api__*"] - } - }; - ``` - - ```python Python theme={null} - options = ClaudeAgentOptions( - mcp_servers={ - "remote-api": { - "type": "sse", - "url": "https://api.example.com/mcp/sse", - "headers": {"Authorization": f"Bearer {os.environ['API_TOKEN']}"}, - } - }, - allowed_tools=["mcp__remote-api__*"], - ) - ``` - </CodeGroup> - </Tab> - - <Tab title=".mcp.json"> - ```json theme={null} - { - "mcpServers": { +<CodeGroup> + ```typescript TypeScript hidelines={1,-1} theme={null} + const _ = { + options: { + mcpServers: { "remote-api": { - "type": "sse", - "url": "https://api.example.com/mcp/sse", - "headers": { - "Authorization": "Bearer ${API_TOKEN}" + type: "sse", + url: "https://api.example.com/mcp/sse", + headers: { + Authorization: `Bearer ${process.env.API_TOKEN}` } } - } + }, + allowedTools: ["mcp__remote-api__*"] } - ``` - </Tab> -</Tabs> + }; + ``` + ```python Python theme={null} + options = ClaudeAgentOptions( + mcp_servers={ + "remote-api": { + "type": "sse", + "url": "https://api.example.com/mcp/sse", + "headers": {"Authorization": f"Bearer {os.environ['API_TOKEN']}"}, + } + }, + allowed_tools=["mcp__remote-api__*"], + ) + ``` +</CodeGroup> + For the streamable HTTP transport, use `"type": "http"` instead. In `.mcp.json` and other JSON config files, `"streamable-http"` is accepted as an alias for `"http"`. The programmatic `mcpServers` option accepts only `"http"`. ### SDK MCP servers
from line 850
### Tool output exceeds maximum allowed tokens -The SDK applies the same MCP output limit as Claude Code. When a tool result is larger than 25,000 tokens, the full output is saved to a file and the tool result is replaced with an error message that names the file path, so the agent can read the output back in portions. Raise the limit with the [`MAX_MCP_OUTPUT_TOKENS`](/docs/en/env-vars) environment variable. See [MCP output limits and warnings](/docs/en/mcp#mcp-output-limits-and-warnings) for the full behavior, including how a server can declare a higher per-tool limit. +The SDK applies the same MCP output limit as Claude Code. When a tool result is larger than 25,000 tokens, the full output is saved to a file and the tool result is replaced with an error message that names the file path, so the agent can read the output back in portions. Raise the limit with the [`MAX_MCP_OUTPUT_TOKENS`](/docs/en/env-vars) environment variable. See [MCP output limits and warnings](/docs/en/mcp#mcp-output-limits-and-warnings) for the full behavior, including how a server can declare a higher per-tool limit with the `anthropic/maxResultSizeChars` annotation. ## Related resources * **[Custom tools guide](/docs/en/agent-sdk/custom-tools)**: Build your own MCP server that runs in-process with your SDK application * **[Permissions](/docs/en/agent-sdk/permissions)**: Control which MCP tools your agent can use with `allowedTools` and `disallowedTools` -* **[MCP output limits and warnings](/docs/en/mcp#mcp-output-limits-and-warnings)**: How the SDK handles tool results that exceed `MAX_MCP_OUTPUT_TOKENS`, including the persist-to-disk fallback and the `anthropic/maxResultSizeChars` per-tool annotation * **[TypeScript SDK reference](/docs/en/agent-sdk/typescript)**: Full API reference including MCP configuration options * **[Python SDK reference](/docs/en/agent-sdk/python)**: Full API reference including MCP configuration options * **[MCP server directory](https://github.com/modelcontextprotocol/servers)**: Browse available MCP servers for databases, APIs, and more