返回市场
线程-mcp服务器

线程-mcp服务器

作者:cagataycali5 星标更新:2025-11-11

项目介绍

strands-mcp-server

PyPI

双向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>

概述

  • mcp_server - 将代理作为MCP服务器公开
  • mcp_client - 连接到MCP服务器
  • CLI - 标准输入输出用于Claude桌面
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"]
    }
  }
}

API

mcp_server

参数默认值描述
action必填启动停止状态列出
transporthttphttp标准输入输出
port8000端口
toolsNone要公开的工具(None = 全部)
expose_agentTrue包括调用代理
statelessFalse多节点就绪

mcp_client

参数描述
action连接断开连接列出工具调用工具
connection_id连接ID
transporthttp标准输入输出SSE
server_url服务器URL
tool_name要调用的工具
tool_args工具参数

invoke_agent

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