Embed code snippets for README from executable examples (#1055)
This commit is contained in:
parent
7bc190bae8
commit
adf327164a
1 changed files with 1139 additions and 1131 deletions
16
examples/snippets/servers/basic_tool.py
Normal file
16
examples/snippets/servers/basic_tool.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
from mcp.server.fastmcp import FastMCP
|
||||
|
||||
mcp = FastMCP(name="Tool Example")
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def sum(a: int, b: int) -> int:
|
||||
"""Add two numbers together."""
|
||||
return a + b
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def get_weather(city: str, unit: str = "celsius") -> str:
|
||||
"""Get weather for a city."""
|
||||
# This would normally call a weather API
|
||||
return f"Weather in {city}: 22degrees{unit[0].upper()}"
|
||||
Loading…
Reference in a new issue