Skip to main content

Transform Strands Agents into MCP servers, exposing agent tools to any MCP-compatible client

Project description

strands-mcp-server

PyPI

Bidirectional MCP integration for Strands Agents. Expose agents as MCP servers or connect to any MCP server.

pip install strands-mcp-server

Overview

Two Python tools + CLI for Model Context Protocol (MCP):

  • mcp_server: Expose your agent's tools as MCP server
  • mcp_client: Connect to and use remote MCP servers
  • CLI: stdio server for Claude Desktop/Kiro
graph TD
    A[Your Strands Agent<br/>tools: calculator, shell, file_read] --> B[mcp_server tool]
    B --> C[MCP Protocol<br/>HTTP/stdio]
    C --> D[MCP Clients]
    D --> E[Claude Desktop]
    D --> F[Other Agents]
    D --> G[Custom Clients]
    
    style A fill:#2d3748,stroke:#4a5568,color:#fff
    style B fill:#2b6cb0,stroke:#2c5282,color:#fff
    style C fill:#38a169,stroke:#2f855a,color:#fff
    style D fill:#805ad5,stroke:#6b46c1,color:#fff
    style E fill:#d69e2e,stroke:#b7791f,color:#fff
    style F fill:#d69e2e,stroke:#b7791f,color:#fff
    style G fill:#d69e2e,stroke:#b7791f,color:#fff

Quick Start

1. Expose Your Agent (Server)

from strands import Agent
from strands_tools import calculator, shell
from strands_mcp_server import mcp_server

agent = Agent(tools=[calculator, shell, mcp_server])
agent("start mcp server on port 8000")
# Server running at http://localhost:8000/mcp

Stateless mode (production):

agent.tool.mcp_server(action="start", stateless=True, agent=agent)

2. Connect to Servers (Client)

from strands import Agent
from strands_mcp_server import mcp_client

agent = Agent(tools=[mcp_client])

# Connect
agent.tool.mcp_client(
    action="connect",
    connection_id="server1",
    transport="http",
    server_url="http://localhost:8000/mcp"
)

# Call remote tool
agent.tool.mcp_client(
    action="call_tool",
    connection_id="server1",
    tool_name="calculator",
    tool_args={"expression": "42 * 89"}
)

3. Claude Desktop Integration

Local mode (expose ./tools/ directory):

{
  "mcpServers": {
    "my-tools": {
      "command": "uvx",
      "args": [
        "strands-mcp-server",
        "--cwd", "/absolute/path/to/project"
      ]
    }
  }
}

Proxy mode (bridge to HTTP server):

{
  "mcpServers": {
    "my-agent": {
      "command": "uvx",
      "args": [
        "strands-mcp-server",
        "--upstream-url", "http://localhost:8000/mcp"
      ],
      "autoApprove": ["tool_name"]
    }
  }
}

API Reference

mcp_server

Parameter Type Default Description
action str required start, stop, status, list
transport str http http (background) or stdio (foreground)
port int 8000 HTTP port
tools list[str] None Tools to expose (None = all)
expose_agent bool True Enable invoke_agent tool
stateless bool False Multi-node ready (no session state)

Examples:

# Basic
agent("start mcp server")

# Specific tools only
agent.tool.mcp_server(action="start", tools=["calculator"], agent=agent)

# Production
agent.tool.mcp_server(action="start", stateless=True, agent=agent)

mcp_client

Parameter Type Description
action str connect, disconnect, list_tools, call_tool, list_connections
connection_id str Connection identifier
transport str http, stdio, sse
server_url str URL (http/sse)
tool_name str Tool to call
tool_args dict Tool arguments

Transports:

# HTTP
agent.tool.mcp_client(
    action="connect", connection_id="s1",
    transport="http", server_url="http://localhost:8000/mcp"
)

# stdio (subprocess)
agent.tool.mcp_client(
    action="connect", connection_id="s2",
    transport="stdio", command="python", args=["server.py"]
)

# SSE
agent.tool.mcp_client(
    action="connect", connection_id="s3",
    transport="sse", server_url="http://localhost:8000/sse"
)

invoke_agent Tool

When expose_agent=True (default), clients get full conversational access to the agent:

# Basic usage via mcp_client
agent.tool.mcp_client(
    action="call_tool",
    connection_id="remote",
    tool_name="invoke_agent",
    tool_args={"prompt": "Calculate 2 + 2 and explain your reasoning"}
)

Parameters:

  • prompt (required): Natural language query for the agent

The agent will process the prompt using its configured model and tools, returning a complete response.


CLI

uvx strands-mcp-server [OPTIONS]
Option Description
--cwd PATH Working directory (local mode)
--upstream-url URL Upstream server (proxy mode)
--system-prompt TEXT Custom system prompt
--no-agent-invocation Disable invoke_agent
--debug Debug logging

Local mode: Exposes ./tools/ directory with hot reload Proxy mode: Bridges stdio ↔ HTTP server

Examples:

# Local mode
uvx strands-mcp-server --cwd /path/to/project

# Proxy mode
uvx strands-mcp-server --upstream-url http://localhost:8000/mcp

# With debug logging
uvx strands-mcp-server --cwd /path/to/project --debug

Troubleshooting

Tools not loading:

uvx strands-mcp-server --cwd /absolute/path --debug

Connection refused:

curl http://localhost:8000/mcp

Port in use:

lsof -i :8000
kill -9 <PID>

Check Claude Desktop logs:

tail -f ~/Library/Logs/Claude/mcp*.log

Testing

pytest              # All tests
pytest --cov        # With coverage

Links


License

Apache 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

strands_mcp_server-0.1.2.tar.gz (36.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

strands_mcp_server-0.1.2-py3-none-any.whl (25.6 kB view details)

Uploaded Python 3

File details

Details for the file strands_mcp_server-0.1.2.tar.gz.

File metadata

  • Download URL: strands_mcp_server-0.1.2.tar.gz
  • Upload date:
  • Size: 36.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.5

File hashes

Hashes for strands_mcp_server-0.1.2.tar.gz
Algorithm Hash digest
SHA256 3346eebda1782a055f33d11e0679ea4d9d106e48051fdf261b95fc8c83abd329
MD5 b7e00bed8fdde87b7cab2bce52b117e1
BLAKE2b-256 5e906f52d8eebd4c1874f153e2bfc448657149024f6d9281b3cb96c953f23f1c

See more details on using hashes here.

File details

Details for the file strands_mcp_server-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for strands_mcp_server-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5f4f8b2fa78bd1f448847d04352e101d0c68860521cba85f1350809a956ffd30
MD5 17fd11ed386d45a94588f42627e25f96
BLAKE2b-256 13e65ff1e61e8092c6e273e2d994b7c5c1d323efcb4b2dfd50b7b98ceff78a3c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page