@@ -296,17 +296,20 @@ from langgraph.prebuilt import create_react_agent
296296async def make_graph():
297297 client = MultiServerMCPClient(
298298 {
299+ " weather" : {
300+ # make sure you start your weather server on port 8000
301+ " url" : " http://localhost:8000/mcp" ,
302+ " transport" : " streamable_http" ,
303+ },
304+ # ATTENTION: MCP's stdio transport was designed primarily to support applications running on a user's machine.
305+ # Before using stdio in a web server context, evaluate whether there's a more appropriate solution.
306+ # For example, do you actually need MCP? or can you get away with a simple `@tool`?
299307 " math" : {
300308 " command" : " python" ,
301309 # Make sure to update to the full absolute path to your math_server.py file
302310 " args" : [" /path/to/math_server.py" ],
303311 " transport" : " stdio" ,
304312 },
305- " weather" : {
306- # make sure you start your weather server on port 8000
307- " url" : " http://localhost:8000/mcp" ,
308- " transport" : " streamable_http" ,
309- }
310313 }
311314 )
312315 tools = await client.get_tools()
@@ -324,28 +327,3 @@ In your [`langgraph.json`](https://langchain-ai.github.io/langgraph/cloud/refere
324327 }
325328}
326329```
327-
328- # # Add LangChain tools to a FastMCP server
329-
330- Use `to_fastmcp` to convert LangChain tools to FastMCP, and then add them to the `FastMCP` server via the initializer:
331-
332- > [! NOTE ]
333- > `tools` argument is only available in FastMCP as of `mcp >= 1.9 .1`
334-
335- ```python
336- from langchain_core.tools import tool
337- from langchain_mcp_adapters.tools import to_fastmcp
338- from mcp.server.fastmcp import FastMCP
339-
340-
341- @ tool
342- def add(a: int , b: int ) -> int :
343- """ Add two numbers"""
344- return a + b
345-
346-
347- fastmcp_tool = to_fastmcp(add)
348-
349- mcp = FastMCP(" Math" , tools = [fastmcp_tool])
350- mcp.run(transport = " stdio" )
351- ```
0 commit comments