You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi!
I'm trying to learn a bit about mcp.
I did some toy example which are trival. Like:
importsysfromtypingimportAny, Dictfrommcp.server.fastmcpimportFastMCPmcp=FastMCP("Cats")
print("MCP Server initialized", file=sys.stderr)
@mcp.tool()asyncdefmcp_endpoint_cat_data()->Dict[str, Any]:
""" Fetch Cat data. Returns a mapping with name, species, and features. """return {
'Name':'Lucyfier',
'Animal':'Cat',
'Features':['cute','fluffy','Green eyes']
}
if__name__=="__main__":
# python main.py# else: # uvx mcpo --port 3001 -- python main.pyprint("Running MCP with stdio")
mcp.run(transport="stdio")
and
fromlangchain_mcp_adapters.clientimportMultiServerMCPClientfromlangchain_ollamaimportChatOllamafromlanggraph.prebuiltimportcreate_react_agentimportasyncioasyncdefrun_tool():
llm=ChatOllama(model="mistral")
client=MultiServerMCPClient(
{
"Cats": {
"command": "python",
# Make sure to update to the full absolute path to your math_server.py file"args": ["./mcp_servers/cats.py"],
"transport": "stdio",
},
}
)
tools=awaitclient.get_tools()
print(tools)
agent=create_react_agent(llm, tools)
msg=r"""Provide me a name of cat. Keep format like {'name':'xxx'} Example Output: {'name':'yyy'}"""use_tool_msg=Trueifuse_tool_msg:
msg=msg+r"\n Use tools. Don't tell me how to do it."response=awaitagent.ainvoke({"messages": msg})
formsginresponse['messages']:
print(msg.content)
print("---\n")
asyncio.run(run_tool())
But it is just using native mcp capabilities.
How do i integrate langChain/langGraph with mcpo as it is a REST layer, but MultiServerMPClient takes only 'stdio','streamable_http','sse' as transport parameter?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
I'm trying to learn a bit about mcp.
I did some toy example which are trival. Like:
and
But it is just using native mcp capabilities.
How do i integrate langChain/langGraph with mcpo as it is a REST layer, but MultiServerMPClient takes only 'stdio','streamable_http','sse' as transport parameter?
Beta Was this translation helpful? Give feedback.
All reactions