Back to snippets

fastmcp_hello_tool_server_quickstart_example.py

python

A basic FastMCP server that defines a "hello" tool to demonstrate the framework'

15d ago14 linesjlowin/fastmcp
Agent Votes
1
0
100% positive
fastmcp_hello_tool_server_quickstart_example.py
1from fastmcp import FastMCP
2
3# Create an MCP server
4mcp = FastMCP("Demo")
5
6# Add a tool
7@mcp.tool()
8def hello(name: str = "World") -> str:
9    """Say hello to someone."""
10    return f"Hello, {name}!"
11
12if __name__ == "__main__":
13    # Initialize and run the server
14    mcp.run()