返回市场
线程代理MCP

线程代理MCP

作者:imgaray7 星标更新:2025-05-26

项目介绍

Strands Agent MCP

这是一个用于执行Strands代理的模型上下文协议(MCP)服务器。该项目提供了一种简单的方法来将Strands代理与Amazon Q和其他兼容MCP的系统集成。

<a href="https://glama.ai/mcp/servers/@imgaray/strands-agents-mcp"> <img width="380" height="200" src="https://gips3.baidu.com/it/u=3821839914,2316155393&fm=3081&app=3081&f=PNG?w=760&h=400" alt="Strands Agent MCP 服务器" /> </a>

重要提示:此项目目前处于Alpha阶段,尚未发布到PyPI。

概述

Strands Agent MCP是Strands代理框架与模型上下文协议(MCP)之间的桥梁。它允许您:

  • 将Strands代理注册为MCP工具
  • 通过MCP执行Strands代理
  • 根据特定技能查找代理

该项目使用插件架构,使得添加新代理无需修改核心代码变得容易。

安装

注意:此包尚未在PyPI上可用。您需要从源代码安装。

# 克隆仓库
git clone https://github.com/yourusername/strands-agent-mcp.git
cd strands-agent-mcp

# 安装包
pip install -e .

使用

启动MCP服务器

strands-agent-mcp

这将启动MCP服务器。

环境变量

服务器支持以下环境变量:

  • PLUGIN_PATH:自定义查找插件的路径(默认值:".")
  • PLUGIN_NAMESPACE:自定义插件命名空间前缀(默认值:'sap_mcp_plugin')

创建代理插件

要创建一个新的代理插件,请创建一个以sap_mcp_plugin_开头的Python包(sap代表Strands代理插件)。您的包应实现一个返回AgentEntry对象列表的build_agents函数:

from typing import List
from boto3 import Session
from strands import Agent
from strands.models import BedrockModel

from strands_agent_mcp.registry import AgentEntry

def build_agents() -> List[AgentEntry]:
    return [
        AgentEntry(
            name="my-agent",
            agent=Agent(
                model=BedrockModel(boto_session=Session(region_name="us-west-2"))
            ),
            skills=["general-knowledge", "coding"]
        )
    ]

与Amazon Q一起使用

一旦MCP服务器运行起来,您可以将其连接到Amazon Q。请参阅Amazon Q文档以获取正确的连接参数。

以下MCP工具将可用:

  • execute_agent:使用参数agent_nameprompt执行代理
  • list_agents:列出所有可用代理

架构

该项目由三个主要组件组成:

  1. 服务器:暴露代理执行API的MCP服务器
  2. 注册表:管理可用代理及其技能的注册表
  3. 插件:动态发现的模块,向注册表注册代理

服务器会自动发现所有遵循命名约定的已安装插件,并注册它们的代理。

依赖项

  • fastmcp>=2.3.4:用于实现MCP服务器
  • strands-agents>=0.1.1:核心Strands代理框架
  • strands-agents-builder>=0.1.0:构建Strands代理的工具
  • strands-agents-tools>=0.1.0:额外的Strands代理工具

开发

此项目使用uv进行依赖管理。要设置开发环境:

  1. 克隆仓库
  2. 如果还没有安装uv,请安装:pip install uv
  3. 创建虚拟环境并安装依赖项:
    uv venv
    uv sync
    

示例插件

仓库中包含一个示例插件(sap_mcp_plugin_simple),演示如何创建和注册一个简单的代理:

from typing import List
from boto3 import Session
from strands import Agent
from strands.models import BedrockModel

from strands_agent_mcp.registry import AgentEntry

def build_agents() -> List[AgentEntry]:
    return [
        AgentEntry(
            name="simple-agent",
            agent=Agent(
                model=BedrockModel(boto_session=Session(region_name="us-west-2"))
            ),
            skills=["general-knowledge"]
        )
    ]

许可证

本项目根据仓库中的LICENSE文件的条款授权。