双向MCP集成用于Strands代理。
pip install strands-mcp-server
<a href="https://glama.ai/mcp/servers/@cagataycali/strands-mcp-server">
<img width="380" height="200" src="https://gips1.baidu.com/it/u=3412061658,1970003805&fm=3081&app=3081&f=PNG?w=760&h=400" alt="Strands Server MCP server" />
</a>
graph LR
subgraph "您的Strands代理"
A[工具:计算器、shell等]
B[mcp_server工具]
C[mcp_client工具]
A --> B
C --> A
end
subgraph "服务器模式"
B -->|HTTP/标准输入输出| D[MCP协议]
D --> E[Claude桌面]
D --> F[其他代理]
D --> G[自定义客户端]
end
subgraph "客户端模式"
H[远程MCP服务器] -->|HTTP/标准输入输出/SSE| I[MCP协议]
I --> C
end
subgraph "CLI"
J[uvx strands-mcp-server] -->|本地模式| D
J -->|代理模式| I
end
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 I 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
style H fill:#e53e3e,stroke:#c53030,color:#fff
style J fill:#48bb78,stroke:#38a169,color:#fff
服务器:
from strands import Agent
from strands_mcp_server import mcp_server
agent = Agent(tools=[..., mcp_server])
agent("在8000端口启动MCP服务器")
客户端:
from strands import Agent
from strands_mcp_server import mcp_client
agent = Agent(tools=[mcp_client])
agent.tool.mcp_client(
action="连接",
connection_id="远程",
transport="http",
server_url="http://localhost:8000/mcp"
)
agent.tool.mcp_client(
action="调用工具",
connection_id="远程",
tool_name="计算器",
tool_args={"表达式": "42 * 89"}
)
对于像Claude桌面/Kiro等代理:
{
"mcpServers": {
"my-agent": {
"命令": "uvx",
"参数": ["strands-mcp-server", "--cwd", "/path/to/project"]
}
}
}
| 参数 | 默认值 | 描述 |
|---|---|---|
action | 必填 | 启动、停止、状态、列出 |
transport | http | http 或 标准输入输出 |
port | 8000 | 端口 |
tools | None | 要公开的工具(None = 全部) |
expose_agent | True | 包括调用代理 |
stateless | False | 多节点就绪 |
| 参数 | 描述 |
|---|---|
action | 连接、断开连接、列出工具、调用工具 |
connection_id | 连接ID |
transport | http、标准输入输出、SSE |
server_url | 服务器URL |
tool_name | 要调用的工具 |
tool_args | 工具参数 |
当expose_agent=True时,完全访问代理:
agent.tool.mcp_client(
action="调用工具",
connection_id="远程",
tool_name="调用代理",
tool_args={"提示": "计算2 + 2"}
)
uvx strands-mcp-server [选项]
| 选项 | 描述 |
|---|---|
--cwd PATH | 工作目录 |
--upstream-url URL | 上游服务器(代理) |
--system-prompt TEXT | 系统提示 |
--no-agent-invocation | 禁用调用代理 |
--debug | 调试模式 |
示例:
# 本地
uvx strands-mcp-server --cwd /path/to/project
# 代理
uvx strands-mcp-server --upstream-url http://localhost:8000/mcp
# 调试
uvx strands-mcp-server --cwd /path --debug
# 检查连接
curl http://localhost:8000/mcp
# 端口被占用
lsof -i :8000 && kill -9 <PID>
# Claude日志
tail -f ~/Library/Logs/Claude/mcp*.log
许可证: Apache 2.0