Merge pull request #1 from jlowin/echo

Add echo server
This commit is contained in:
Jeremiah Lowin 2024-11-30 09:07:21 -05:00 committed by GitHub
commit 67ad3441b2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 0 deletions

19
examples/echo.py Normal file
View file

@ -0,0 +1,19 @@
"""
FastMCP Echo Server
"""
from fastmcp import FastMCP
# Create server
mcp = FastMCP("Echo Server")
@mcp.tool()
def echo(text: str) -> str:
"""Echo the input text"""
return text
if __name__ == "__main__":
mcp.run()

View file

@ -279,6 +279,7 @@ class FastMCP:
async def run_stdio_async(self) -> None:
"""Run the server using stdio transport."""
async with stdio_server() as (read_stream, write_stream):
print(f'Starting "{self.name}"...')
await self._mcp_server.run(
read_stream,
write_stream,