File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -412,10 +412,13 @@ from mcp.server.fastmcp import FastMCP
412412
413413mcp = FastMCP(name = " EchoServer" , stateless_http = True )
414414
415+
415416@mcp.tool (description = " A simple echo tool" )
416417def echo (message : str ) -> str :
417418 return f " Echo: { message} "
419+ ```
418420
421+ ``` python
419422# main.py
420423from fastapi import FastAPI
421424from routers import echo
@@ -425,7 +428,6 @@ app = FastAPI()
425428# Use the session manager's lifespan
426429app = FastAPI(lifespan = lambda app : echo.mcp.session_manager.run())
427430app.mount(" /echo" , echo.mcp.streamable_http_app())
428-
429431```
430432
431433For low level server with Streamable HTTP implementations, see:
@@ -744,9 +746,13 @@ if __name__ == "__main__":
744746Clients can also connect using streamable HTTP transport:
745747
746748``` python
749+ from mcp.client.streamable_http import streamablehttp_client
750+ from mcp import ClientSession
751+
747752
748- # Connect to a streamable HTTP server
749- async with streamablehttp_client(http_server_url + " /mcp" ) as (
753+ async def main ():
754+ # Connect to a streamable HTTP server
755+ async with streamablehttp_client(" example/mcp" ) as (
750756 read_stream,
751757 write_stream,
752758 _,
You can’t perform that action at this time.
0 commit comments