pip install mcpstore
用户友好的mcp服务管理sdk,方便快速集成MCP服务,并集成了主流agent框架的适配器,简单几行代码就将MCP服务转为agent框架格式的tools对象
from mcpstore import MCPStore
store = MCPStore.setup_store()
store.for_store().add_service({"name":"mcpstore-wiki","url":"https://mcpstore.wiki/mcp"})
tools = store.for_store().for_langchain().list_tools()
到这里我们将一个mcp服务做成了langchain可以直接使用的tools对象 基于上面的代码 我们可以添加下面的代码运行
#需要添加上面的代码块
from langchain.agents import create_tool_calling_agent, AgentExecutor
from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
temperature=0, model="deepseek-chat",
openai_api_key="****",
openai_api_base="https://api.deepseek.com"
)
prompt = ChatPromptTemplate.from_messages([
("system", "你是一个助手,回答的时候带上表情"),
("human", "{input}"),
("placeholder", "{agent_scratchpad}"),
])
agent = create_tool_calling_agent(llm, tools, prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
# ===
query = "北京的天气怎么样?"
print(f"\n 🤔: {query}")
response = agent_executor.invoke({"input": query})
print(f" 🤖 : {response['output']}")
同时也适配了多种agent框架,比如langgraph autogen等等,通过for_XXX()方法可以快速获取对应的工具对象
目前支持了redis数据库 可以通过传入redis的配置或者redis的对象
redis_config = {
"url": "redis://localhost:6379/0",
"password": None,
"namespace": "demo_namespace"
}
store = MCPStore.setup_store(redis =redis_config)
只需要
pip install mcpstore[redis]
简单开源的Vue,支持通过SDK或API方式直观管理MCP服务
快速启动后端服务:
from mcpstore import MCPStore
prod_store = MCPStore.setup_store()
prod_store.start_api_server(host='0.0.0.0', port=18200)
store = MCPStore.setup_store()
store.for_store().add_service({"name":"mcpstore-wiki","url":"https://mcpstore.wiki/mcp"})
tools = store.for_store().list_tools()
store.for_store().call_tool(tools[0].name, {"query":'hi!'})
使用for_agent(agent_id)可以将mcp分组 方便不同的agent获取精确的有限上下文工具集 即将支持根据分组 一键生成a2a协议的card
store.for_store()
- 全局store空间store.for_agent("agent_id")
- 为指定Agent创建隔离空间
# 初始化Store
store = MCPStore.setup_store()
# 为“知识管理Agent”分配专用的Wiki工具
# 该操作在"knowledge" agent的私有上下文中进行
agent_id1 = "my-knowledge-agent"
knowledge_agent_context = store.for_agent(agent_id1).add_service(
{"name": "mcpstore-wiki", "url": "http://mcpstore.wiki/mcp"}
)
# 为“开发支持Agent”分配专用的开发工具
# 该操作在"development" agent的私有上下文中进行
agent_id2 = "my-development-agent"
dev_agent_context = store.for_agent(agent_id2).add_service(
{"name": "mcpstore-demo", "url": "http://mcpstore.wiki/mcp"}
)
# 各Agent的工具集完全隔离,互不影响
knowledge_tools = store.for_agent(agent_id1).list_tools()
dev_tools = store.for_agent(agent_id2).list_tools()
很直观的,你可以通过 store.for_store()
和 store.for_agent("agent_id")
使用几乎所有的函数 ✨
提供完整的RESTful API,一行命令启动Web服务:
pip install mcpstore
mcpstore run api
详细的接口文档看网页
# 服务管理
POST /for_store/add_service # 添加服务
GET /for_store/list_services # 获取服务列表
POST /for_store/delete_service # 删除服务
# 工具操作
GET /for_store/list_tools # 获取工具列表
POST /for_store/use_tool # 执行工具
# 监控统计
GET /for_store/get_stats # 系统统计
GET /for_store/health # 健康检查
欢迎社区贡献:
- ⭐ 给项目点Star
- 🐛 提交Issues报告问题
- 🔧 提交Pull Requests贡献代码
- 💬 分享使用经验和最佳实践
McpStore是一个还在频繁的更新的项目,恳求大家给小星并来指点