Follow Discord
Sweep 22 Oct 2026 · 21:04Z Build v2.1.309 528 read Stable v2.1.308 Latest v2.1.309 Next v2.1.309 Feeds RSS JSON llms.txt llms-full.txt Unofficial
One change · claude-code

Agent SDK reference - TypeScript changedagent-sdk/typescript

Nearest release: v2.1.293, published 11 hours after upstream edited the page. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.

Upstream edited this page at 7 Oct 2026 05:48 UTC, give or take a minute or two: the time comes from Anthropic’s own sitemap rather than from a commit. This site recorded the change at 7 Oct 2026 06:07 UTC.

Upstream edited
Recorded here
Lines+3added
Lines−3removed
From line 631 where the diff opens
First seen 14 Aug 2026 this site's first read of the page
Recorded edits114to this page, all time

The whole hunk

from line 631, old and new numbered
/
lines

This page is larger than the 256 KiB this site keeps, so one side of the diff below stops where the stored text does.

from line 631
631631| `accountInfo()` | Returns account information |
632632| `reconnectMcpServer(serverName)` | Reconnect an MCP server by name. If the name also matches an entry in a settings file such as `.mcp.json` or `~/.claude.json`, Claude Code reconnects the server you configured through [`mcpServers`](#options) or `setMcpServers()`, not the settings-file entry. That resolution order requires Claude Code v2.1.257 or later |
633633| `toggleMcpServer(serverName, enabled)` | Enable or disable an MCP server by name, with the same name resolution as `reconnectMcpServer()`. Disabling a server disconnects it and removes its tools. See [`toggleMcpServer()`](#togglemcpserver) for the Claude Code version this needs for each kind of server |
634| `setMcpServers(servers)` | Dynamically replace the set of MCP servers for this session. Resolves with an [`McpSetServersResult`](#mcpsetserversresult) naming which servers were added and removed, and any errors |
634| `setMcpServers(servers)` | Replace the MCP servers this method manages: servers added through it and [in-process SDK servers](#createsdkmcpserver). Resolves with an [`McpSetServersResult`](#mcpsetserversresult) naming which servers were added and removed, and any errors; that section says which other servers stay connected |
635635| `readMcpResource(serverName, uri)` | *Alpha.* Reads one MCP Apps `ui://` resource from a connected MCP server so your application can render a tool's widget. Resolves with an [`SDKControlMcpReadResourceResponse`](#sdkcontrolmcpreadresourceresponse). Requires TypeScript Agent SDK v0.3.280 or later |
636636| `streamInput(stream)` | Stream input messages to the query for multi-turn conversations |
637637| `stopTask(taskId)` | Stop a running background task by ID |
from line 5034
50345034 
50355035When you call `setMcpServers()`, Claude Code applies these rules:
50365036 
5037* **Servers the call doesn't name**: Claude Code keeps plugin-provided servers running. Requires Agent SDK v0.3.210 or later.
5038* **Servers the call names**: except for built-in servers the CLI started at startup, Claude Code replaces a running server only when its config differs from the one you passed.
5037* **Servers the call doesn't name**: outside a [cloud session](/docs/en/claude-code-on-the-web), Claude Code disconnects the servers an earlier `setMcpServers()` call added and the in-process SDK servers, and lists them in `removed`. Other servers keep running and aren't listed in `removed`, among them the stdio, HTTP, and SSE servers from the [`mcpServers`](#options) option, servers from settings files, and plugin-provided servers.
5038* **Servers the call names**: Claude Code replaces a stdio, HTTP, or SSE server that an earlier `setMcpServers()` call added only when its config differs from the one you passed. An in-process SDK server already registered under that name stays as it is, so to swap one, leave it out of one call and add it in the next.
50395039* **Built-in servers the CLI started at startup**: if the call names one, Claude Code drops that entry and reports it in `errors`.
50405040 
50415041The promise resolves after newly added stdio, HTTP, and SSE servers connect or fail, so tools from servers that connected are available on the next turn.
from line 5387
53875387type SDKFilesPersistedEvent = {
53885388 type: "system";
53895389 subtype: "files_persisted";
5390 files: { filename: string; file_id: string }[];
5391 failed: { filename: string; error: string }[];
5392 processed_at: string;
5393 uuid: UUID;
5394 session_id: string;
5395};
5396```
5397 
5398### `SDKRateLimitEvent`
5399 
5400Emitted when the session encounters a rate limit.
5401 
5402```typescript theme={null}
5403type SDKRateLimitEvent = {
5404 type: "rate_limit_event";
5405 rate_limit_info: {
5406 status: "allowed" | "allowed_warning" | "rejected";
5407 resetsAt?: number;
5408 utilization?: number;
5409 errorCode?: "credits_required";
5410 canUserPurchaseCredits?: boolean;
5411 hasChargeableSavedPaymentMethod?: boolean;
5412 };
5413 uuid: UUID;
5414 session_id: string;
5415 
5390 files: { filename: string; file_id: string }
Feedback