weekly icon indicating copy to clipboard operation
weekly copied to clipboard

【开源自荐】mcpstore:轻松管理使用mcp服务,不绑定agent和llm框架,优雅调用mcp服务。

Open ip2a opened this issue 1 year ago • 0 comments

项目地址

https://github.com/whillhill/mcpstore

使用pip install 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()
# 或者
tools = store.for_store().for_langgraph().list_tools()
# 或者
tools = store.for_store().for_openai().list_tools()
#.....

几行代码就可以直接使用注册的mcp服务 这个产出的tool的列表完全和llm或者agent框架兼容使用 以下是一个可以直接运行的示例

from langchain.agents import create_tool_calling_agent, AgentExecutor
from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI
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()

llm = ChatOpenAI(
    temperature=0, model="deepseek-chat",
    openai_api_key="sk-****",
    openai_api_base="httpss://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框架都做好mcp的中间层

求推荐 还有agent模式 api模式 webdemo

ip2a avatar Sep 20 '25 04:09 ip2a