claude-agent-sdk-python icon indicating copy to clipboard operation
claude-agent-sdk-python copied to clipboard

Please allow passing a json file for the mcp-config like the standard command

Open gerrywastaken opened this issue 7 months ago • 2 comments

The CLI tool allows you to provide a JSON file supplying the config within the command https://docs.anthropic.com/en/docs/claude-code/sdk#mcp-configuration

claude -p 'yo' --mcp-config mcp-servers.json

However, this SDK builds and supplies the entire mcp config via the command line directly, including any auth keys that need to be there:

claude -p 'yo' --mcp-config '{"mcpServers": {"github": {"command": "npx", "args": ["-y", "@modelcontextprotocol/server-github"], "env": {"GITHUB_TOKEN": "Your super secret token"}}}}'

I know you are currently not including the generated command in the debug output, but I think you should as it greatly helps with understanding errors. But having mcp-config json in the command makes this not possible without exposing tokens.

gerrywastaken avatar Jul 28 '25 11:07 gerrywastaken

https://github.com/anthropics/claude-code-sdk-python/pull/111 introduced extra_args where you can specify --mcp-config with the type that you want.

dicksontsai avatar Aug 05 '25 05:08 dicksontsai

Thank you, that sounds like a great improvement. :)

gerrywastaken avatar Nov 08 '25 22:11 gerrywastaken