blob: 9a46e7c6eb5dc1c40c1568657e6c29a9d37a673d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
"""Test MCP server that echoes messages back.
Usage:
python scripts/echo_server.py # stdio transport
python scripts/echo_server.py streamable-http # HTTP transport
"""
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("echo")
@mcp.tool()
def echo(message: str) -> str:
"""Echo back the provided message unchanged."""
return message
@mcp.tool()
def reverse(message: str) -> str:
"""Return the message reversed."""
return message[::-1]
if __name__ == "__main__":
import sys
transport = sys.argv[1] if len(sys.argv) > 1 else "stdio"
port = int(sys.argv[2]) if len(sys.argv) > 2 else 9000
mcp.settings.port = port
mcp.run(transport=transport)
|