Connect to external tools with MCP changedagent-sdk/mcp
Nearest release: v2.1.309, published 2 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 22 Oct 2026 17:46 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 30 Oct 2026 18:07 UTC.
Upstream edited
Recorded here
Lines+98added
Lines−98removed
From line
382
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits23to this page, all time
The whole hunk
from line 382, old and new numbered
/
from line 382
382382
383383Use the `env` field to pass API keys, tokens, and other credentials to the MCP server:
384384
385**In code**
385> [tab] In code
386>
387> ```typescript TypeScript hidelines={1,-1} theme={null}
388> const _ = {
389> options: {
390> mcpServers: {
391> "api-server": {
392> command: "npx",
393> args: ["-y", "@your-org/api-mcp-server"],
394> env: {
395> API_KEY: process.env.API_KEY
396> }
397> }
398> },
399> allowedTools: ["mcp__api-server__*"]
400> }
401> };
402> ```
403>
404> ```python Python theme={null}
405> options = ClaudeAgentOptions(
406> mcp_servers={
407> "api-server": {
408> "command": "npx",
409> "args": ["-y", "@your-org/api-mcp-server"],
410> "env": {"API_KEY": os.environ["API_KEY"]},
411> }
412> },
413> allowed_tools=["mcp__api-server__*"],
414> )
415> ```
386416
387```typescript TypeScript hidelines={1,-1} theme={null}
388const _ = {
389 options: {
390 mcpServers: {
391 "api-server": {
392 command: "npx",
393 args: ["-y", "@your-org/api-mcp-server"],
394 env: {
395 API_KEY: process.env.API_KEY
396 }
397 }
398 },
399 allowedTools: ["mcp__api-server__*"]
400 }
401};
402```
417> [tab] .mcp.json
418>
419> ```json theme={null}
420> {
421> "mcpServers": {
422> "api-server": {
423> "command": "npx",
424> "args": ["-y", "@your-org/api-mcp-server"],
425> "env": {
426> "API_KEY": "${API_KEY}"
427> }
428> }
429> }
430> }
431> ```
432>
433> The `${API_KEY}` syntax expands environment variables at runtime.
403434
404```python Python theme={null}
405options = ClaudeAgentOptions(
406 mcp_servers={
407 "api-server": {
408 "command": "npx",
409 "args": ["-y", "@your-org/api-mcp-server"],
410 "env": {"API_KEY": os.environ["API_KEY"]},
411 }
412 },
413 allowed_tools=["mcp__api-server__*"],
414)
415```
416
417**.mcp.json**
418
419```json theme={null}
420{
421 "mcpServers": {
422 "api-server": {
423 "command": "npx",
424 "args": ["-y", "@your-org/api-mcp-server"],
425 "env": {
426 "API_KEY": "${API_KEY}"
427 }
428 }
429 }
430}
431```
432
433The `${API_KEY}` syntax expands environment variables at runtime.
434
435435### HTTP headers for remote servers
436436
437437For HTTP and SSE servers, pass authentication headers directly in the server configuration:
438438
439**In code**
439> [tab] In code
440>
441> ```typescript TypeScript hidelines={1,-1} theme={null}
442> const _ = {
443> options: {
444> mcpServers: {
445> "secure-api": {
446> type: "http",
447> url: "https://api.example.com/mcp",
448> headers: {
449> Authorization: `Bearer ${process.env.API_TOKEN}`
450> }
451> }
452> },
453> allowedTools: ["mcp__secure-api__*"]
454> }
455> };
456> ```
457>
458> ```python Python theme={null}
459> options = ClaudeAgentOptions(
460> mcp_servers={
461> "secure-api": {
462> "type": "http",
463> "url": "https://api.example.com/mcp",
464> "headers": {"Authorization": f"Bearer {os.environ['API_TOKEN']}"},
465> }
466> },
467> allowed_tools=["mcp__secure-api__*"],
468> )
469> ```
440470
441```typescript TypeScript hidelines={1,-1} theme={null}
442const _ = {
443 options: {
444 mcpServers: {
445 "secure-api": {
446 type: "http",
447 url: "https://api.example.com/mcp",
448 headers: {
449 Authorization: `Bearer ${process.env.API_TOKEN}`
450 }
451 }
452 },
453 allowedTools: ["mcp__secure-api__*"]
454 }
455};
456```
457
458```python Python theme={null}
459options = ClaudeAgentOptions(
460 mcp_servers={
461 "secure-api": {
462 "type": "http",
463 "url": "https://api.example.com/mcp",
464 "headers": {"Authorization": f"Bearer {os.environ['API_TOKEN']}"},
465 }
466 },
467 allowed_tools=["mcp__secure-api__*"],
468)
469```
470
471**.mcp.json**
472
473```json theme={null}
474{
475 "mcpServers": {
476 "secure-api": {
477 "type": "http",
478 "url": "https://api.example.com/mcp",
479 "headers": {
480 "Authorization": "Bearer ${API_TOKEN}"
481 }
482 }
483 }
484}
485```
486
487The `${API_TOKEN}` syntax expands environment variables at runtime.
471> [tab] .mcp.json
472>
473> ```json theme={null}
474> {
475> "mcpServers": {
476> "secure-api": {
477> "type": "http",
478> "url": "https://api.example.com/mcp",
479> "headers": {
480> "Authorization": "Bearer ${API_TOKEN}"
481> }
482> }
483> }
484> }
485> ```
486>
487> The `${API_TOKEN}` syntax expands environment variables at runtime.
488488
489489For a complete working example of a remote server authenticated with headers, see [List issues from a repository](#list-issues-from-a-repository).
490490
No line in this hunk matches that.