You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for loading MCP server configurations from a JSON config file, allowing users to define multiple MCP servers declaratively instead of programmatically. This extends the existing experimental agent_config.py to support an mcp_servers field that creates and manages MCPClient instances automatically.
Note: Multiple MCP servers and automatic lifecycle management already work programmatically (see tests_integ/mcp/test_mcp_tool_provider.py::test_mcp_client_multiple_servers). This feature request is specifically about configuration file support.
Add mcp_servers to the existing AGENT_CONFIG_SCHEMA JSON schema. The configuration format should be compatible with the Claude Desktop / Cursor / VS Code mcpServers convention where possible.
Config-to-MCPClient mapping: Convert each server config entry into an MCPClient instance with the appropriate transport callable
Per-server configuration options:
Field
Type
Required
Description
command
string
For stdio
Command to run the MCP server
args
string[]
No
Arguments for the command
env
object
No
Environment variables for the subprocess
cwd
string
No
Working directory for stdio subprocess
transport
string
No
Transport type: "stdio", "sse", "streamable-http" (auto-detected if omitted)
url
string
For sse/http
URL of the remote MCP server
headers
object
No
HTTP headers for sse/http transports
prefix
string
No
Prefix for tool names to avoid collisions
startup_timeout
int
No
Timeout for server initialization (default: 30)
tool_filters
object
No
Tool filter config with allowed and rejected arrays of string/regex patterns
3. Integrate with config_to_agent
Update config_to_agent() in agent_config.py to:
Parse the mcp_servers field from config
Create MCPClient instances using the new config module
Append MCPClient instances to the tools list passed to Agent()
Let existing ToolProvider handling in ToolRegistry.process_tools() manage lifecycle
4. Also Provide Standalone Config Loading
In addition to config_to_agent integration, provide a standalone function to load MCP clients from config for users who want to use them independently:
fromstrands.tools.mcpimportMCPClientfromstrands.tools.mcp.mcp_configimportload_mcp_clients_from_config# Load from fileclients=load_mcp_clients_from_config("mcp_config.json")
# Or from dictclients=load_mcp_clients_from_config({
"aws_docs": {
"command": "uvx",
"args": ["awslabs.aws-documentation-mcp-server@latest"]
}
})
# Use with agentagent=Agent(tools=list(clients.values()))
5. Testing
Unit tests (tests/strands/tools/mcp/test_mcp_config.py):
Config parsing and validation for each transport type
Overview
Add support for loading MCP server configurations from a JSON config file, allowing users to define multiple MCP servers declaratively instead of programmatically. This extends the existing experimental
agent_config.pyto support anmcp_serversfield that creates and managesMCPClientinstances automatically.Note: Multiple MCP servers and automatic lifecycle management already work programmatically (see
tests_integ/mcp/test_mcp_tool_provider.py::test_mcp_client_multiple_servers). This feature request is specifically about configuration file support.Implementation Requirements
1. Extend Agent Config Schema (
src/strands/experimental/agent_config.py)Add
mcp_serversto the existingAGENT_CONFIG_SCHEMAJSON schema. The configuration format should be compatible with the Claude Desktop / Cursor / VS CodemcpServersconvention where possible.Target config format:
{ "name": "my_agent", "model": "us.anthropic.claude-3-5-sonnet-20241022-v2:0", "prompt": "You are a helpful assistant.", "tools": ["strands_tools.file_read"], "mcp_servers": { "aws_docs": { "command": "uvx", "args": ["awslabs.aws-documentation-mcp-server@latest"], "env": { "AWS_PROFILE": "default" }, "prefix": "aws", "startup_timeout": 30, "tool_filters": { "allowed": ["search_.*"], "rejected": ["dangerous_tool"] } }, "remote_service": { "transport": "sse", "url": "http://localhost:8000/sse", "headers": { "Authorization": "Bearer token123" }, "prefix": "remote" }, "http_service": { "transport": "streamable-http", "url": "http://localhost:8000/mcp", "headers": {}, "prefix": "http" } } }2. Create MCP Config Module (
src/strands/tools/mcp/mcp_config.py)Create a new module that handles parsing MCP server configuration and creating
MCPClientinstances.Key components:
stdioifcommandis present, otherwise infer fromurlor explicittransportfield)stdio— usesmcp.client.stdio.stdio_clientwithStdioServerParameterssse— usesmcp.client.sse.sse_clientstreamable-http— usesmcp.client.streamable_http.streamablehttp_clientMCPClientinstance with the appropriate transport callablePer-server configuration options:
commandargsenvcwdtransport"stdio","sse","streamable-http"(auto-detected if omitted)urlheadersprefixstartup_timeouttool_filtersallowedandrejectedarrays of string/regex patterns3. Integrate with
config_to_agentUpdate
config_to_agent()inagent_config.pyto:mcp_serversfield from configMCPClientinstances using the new config moduleMCPClientinstances to the tools list passed toAgent()ToolProviderhandling inToolRegistry.process_tools()manage lifecycle4. Also Provide Standalone Config Loading
In addition to
config_to_agentintegration, provide a standalone function to load MCP clients from config for users who want to use them independently:5. Testing
Unit tests (
tests/strands/tools/mcp/test_mcp_config.py):Unit tests (
tests/strands/experimental/test_agent_config.py):config_to_agentwithmcp_serversfieldIntegration tests (
tests_integ/mcp/test_mcp_config.py):echo_server.pyFiles to Create/Modify
src/strands/tools/mcp/mcp_config.pysrc/strands/tools/mcp/__init__.pysrc/strands/experimental/agent_config.pymcp_serversto schema and processingtests/strands/tools/mcp/test_mcp_config.pytests/strands/experimental/test_agent_config.pytests_integ/mcp/test_mcp_config.pyAGENTS.mdAcceptance Criteria
config_to_agent()correctly creates agents with MCP tools from configload_mcp_clients_from_config()function works independentlyprefix,startup_timeout,tool_filters,env,headersAgent(tools=[mcp_client])) is unaffectedAssumptions
envfield for stdio only)experimental/agent_config.pyand is subject to API changesPrior Art & References
mcp_from_config.py— can reference for patternsmcpServersJSON formatagent_config.pyfor JSON schema validation,MCPClientfor transport handlingNotes for Future Improvement
${ENV_VAR}) for sensitive valuesfail_openoption when [FEATURE] Graceful MCP server startup failures - fail open #1481 is implementedAGENTS.mddirectory structure should be updated to reflect the newmcp_config.pyfileREADME.mdMCP section could be updated with config file example