@@ -121,7 +121,7 @@ mcp = FastMCP("Demo")
121121
122122# Add an addition tool
123123@mcp.tool ()
124- def add (a : int , b : int ) -> int :
124+ def sum (a : int , b : int ) -> int :
125125 """ Add two numbers"""
126126 return a + b
127127
@@ -246,13 +246,13 @@ from mcp.server.fastmcp import FastMCP
246246mcp = FastMCP(name = " Tool Example" )
247247
248248
249- @mcp.tool (description = " Add two numbers " )
250- def add (a : int , b : int ) -> int :
249+ @mcp.tool ()
250+ def sum (a : int , b : int ) -> int :
251251 """ Add two numbers together."""
252252 return a + b
253253
254254
255- @mcp.tool (description = " Get weather for a city " )
255+ @mcp.tool ()
256256def get_weather (city : str , unit : str = " celsius" ) -> str :
257257 """ Get weather for a city."""
258258 # This would normally call a weather API
@@ -440,7 +440,7 @@ from mcp.server.fastmcp import Context, FastMCP
440440mcp = FastMCP(name = " Progress Example" )
441441
442442
443- @mcp.tool (description = " Demonstrates progress reporting " )
443+ @mcp.tool ()
444444async def long_running_task (task_name : str , ctx : Context, steps : int = 5 ) -> str :
445445 """ Execute a task with progress updates."""
446446 await ctx.info(f " Starting: { task_name} " )
@@ -567,7 +567,7 @@ class BookingPreferences(BaseModel):
567567 )
568568
569569
570- @mcp.tool (description = " Book a restaurant table " )
570+ @mcp.tool ()
571571async def book_table (
572572 date : str ,
573573 time : str ,
@@ -612,7 +612,7 @@ from mcp.types import SamplingMessage, TextContent
612612mcp = FastMCP(name = " Sampling Example" )
613613
614614
615- @mcp.tool (description = " Uses sampling to generate content " )
615+ @mcp.tool ()
616616async def generate_poem (topic : str , ctx : Context) -> str :
617617 """ Generate a poem using LLM sampling."""
618618 prompt = f " Write a short poem about { topic} "
@@ -645,9 +645,9 @@ from mcp.server.fastmcp import Context, FastMCP
645645mcp = FastMCP(name = " Notifications Example" )
646646
647647
648- @mcp.tool (description = " Demonstrates logging at different levels " )
648+ @mcp.tool ()
649649async def process_data (data : str , ctx : Context) -> str :
650- """ Process data with comprehensive logging."""
650+ """ Process data with logging."""
651651 # Different log levels
652652 await ctx.debug(f " Debug: Processing ' { data} ' " )
653653 await ctx.info(" Info: Starting processing" )
@@ -785,8 +785,9 @@ from mcp.server.fastmcp import FastMCP
785785mcp = FastMCP(name = " EchoServer" , stateless_http = True )
786786
787787
788- @mcp.tool (description = " A simple echo tool " )
788+ @mcp.tool ()
789789def echo (message : str ) -> str :
790+ """ A simple echo tool"""
790791 return f " Echo: { message} "
791792```
792793
@@ -797,8 +798,9 @@ from mcp.server.fastmcp import FastMCP
797798mcp = FastMCP(name = " MathServer" , stateless_http = True )
798799
799800
800- @mcp.tool (description = " A simple add tool " )
801+ @mcp.tool ()
801802def add_two (n : int ) -> int :
803+ """ Tool to add two to the input"""
802804 return n + 2
803805```
804806
0 commit comments