Skip to content

Commit c4b8615

Browse files
committed
docs: use environment variables instead of hardcoded tokens
Update MCP server examples to read tokens from environment variables rather than hardcoding sensitive values.
1 parent 0c5090f commit c4b8615

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ The SDK supports multiple ways to configure [MCP (Model Context Protocol)](https
9696
For existing MCP servers that run as separate processes, use dictionary-based configuration. **You don't need to manually run these servers** - Claude Code automatically spawns and manages them:
9797

9898
```python
99+
import os
99100
from claude_agent_sdk import ClaudeAgentOptions, ClaudeSDKClient
100101

101102
options = ClaudeAgentOptions(
@@ -109,7 +110,7 @@ options = ClaudeAgentOptions(
109110
"github": {
110111
"command": "npx",
111112
"args": ["-y", "@modelcontextprotocol/server-github"],
112-
"env": {"GITHUB_TOKEN": "your-token"}
113+
"env": {"GITHUB_TOKEN": os.environ["GITHUB_TOKEN"]}
113114
}
114115
},
115116
# Pre-approve specific MCP tools to avoid permission prompts
@@ -129,17 +130,19 @@ MCP tool names follow the pattern `mcp__<server-name>__<tool-name>`.
129130
For remote MCP servers accessible via HTTP:
130131

131132
```python
133+
import os
134+
132135
options = ClaudeAgentOptions(
133136
mcp_servers={
134137
"remote-sse": {
135138
"type": "sse",
136139
"url": "https://example.com/mcp/sse",
137-
"headers": {"Authorization": "Bearer token"} # Optional
140+
"headers": {"Authorization": f"Bearer {os.environ['MCP_API_TOKEN']}"}
138141
},
139142
"remote-http": {
140143
"type": "http",
141144
"url": "https://example.com/mcp",
142-
"headers": {"Authorization": "Bearer token"} # Optional
145+
"headers": {"Authorization": f"Bearer {os.environ['MCP_API_TOKEN']}"}
143146
}
144147
}
145148
)

0 commit comments

Comments
 (0)