Back to snippets

fastmcp_server_with_hello_greeting_tool.py

python

A simple FastMCP server that defines a "hello" tool for greeting users by name.

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