File size: 1,137 Bytes
ada812e
711c130
ada812e
711c130
 
ada812e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
32
33
34
35
36
"""
  This is much simple MCP server  based on FastMCP amd transport streamable-http.
  
  Ref https://github.com/modelcontextprotocol/python-sdk/?tab=readme-ov-file#quickstart
  and    https://gofastmcp.com/deployment/running-server
  
Author: Alex Punnen
Status:  Demo

"""
from fastmcp import FastMCP

mcp = FastMCP()

# Assume that this is the tool you want to expose
# Give all the types and description
@mcp.tool()
def add(a: int, b: int) -> int:
    """Add two numbers"""
    return a + b

if __name__ == "__main__":
    # take host and port from command line
    import argparse
    parser = argparse.ArgumentParser(description="Run FastMCP server")
    parser.add_argument("--host", type=str, default="0.0.0.0", help="Host address (default: 0.0.0.0)")
    parser.add_argument("--port", type=int, default=7860, help="Port number (default: 7860)")

    args = parser.parse_args()
    mcp.run(
        transport="streamable-http", # https://github.com/modelcontextprotocol/python-sdk/?tab=readme-ov-file#streamable-http-transport
        host=args.host,
        port=args.port,
        path="/mcp",
        log_level="debug",
    )