Spaces:
Running
Running
Jeremiah Lowin commited on
Commit ·
b320cb1
1
Parent(s): f88f9cc
Add echo server
Browse files- examples/echo.py +19 -0
- src/fastmcp/server.py +1 -0
examples/echo.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
FastMCP Echo Server
|
| 3 |
+
"""
|
| 4 |
+
|
| 5 |
+
from fastmcp import FastMCP
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
# Create server
|
| 9 |
+
mcp = FastMCP("Echo Server")
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
@mcp.tool()
|
| 13 |
+
def echo(text: str) -> str:
|
| 14 |
+
"""Echo the input text"""
|
| 15 |
+
return text
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
if __name__ == "__main__":
|
| 19 |
+
mcp.run()
|
src/fastmcp/server.py
CHANGED
|
@@ -279,6 +279,7 @@ class FastMCP:
|
|
| 279 |
async def run_stdio_async(self) -> None:
|
| 280 |
"""Run the server using stdio transport."""
|
| 281 |
async with stdio_server() as (read_stream, write_stream):
|
|
|
|
| 282 |
await self._mcp_server.run(
|
| 283 |
read_stream,
|
| 284 |
write_stream,
|
|
|
|
| 279 |
async def run_stdio_async(self) -> None:
|
| 280 |
"""Run the server using stdio transport."""
|
| 281 |
async with stdio_server() as (read_stream, write_stream):
|
| 282 |
+
print(f'Starting "{self.name}"...')
|
| 283 |
await self._mcp_server.run(
|
| 284 |
read_stream,
|
| 285 |
write_stream,
|