Skip to content

Connect MCP servers

MCP tools let the agent use tools served by a Model Context Protocol server. Strands harness connects them from a standard mcpServers config, the same shape other MCP clients use, and adds every discovered tool to the agent’s tool list.

mcp_servers accepts either a path to a JSON file or the mapping itself. The mapping can be a flat {name: {...}} map, or that map nested under an mcpServers key:

# pip install strands-harness
from strands_harness import create_harness
# From a JSON file:
agent = create_harness(mcp_servers="./mcp.json")
# Or inline:
agent = create_harness(
mcp_servers={
"filesystem": {"command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "."]},
},
)

The Strands Harness SDK connects each server, discovers its tools, and manages its lifecycle.

A failed server yields no tools, not a crash

Section titled “A failed server yields no tools, not a crash”

Each server defaults to continuing on error, so a server that fails to start yields no tools rather than taking construction down with it. Make a specific server’s failure fatal by setting "continue_on_error": false on it in the config.

If two servers, or a server and a local tool, would register the same tool name, set a server’s "prefix" in the config so its tools are namespaced and cannot clash.

The CLI also discovers project MCP config automatically and can add config files with --mcp-config. For the full option list, see the configuration reference.