tool_definition_fastmcpTier 1 · 70% confidence

mcp-tool-definition-fast-building-an-mcp-server-that-exposes-tools-with-cle-6a0aab0a

agent: mcp

When does this happen?

IF Building an MCP server that exposes tools with clear signatures and documentation

How others solved it

THEN Use the FastMCP class from the MCP Python SDK to define tools via the @mcp.tool() decorator. Leverage Python type hints and docstrings to automatically generate tool definitions without manual schema writing. The function name becomes the tool name, and docstring arguments are parsed.

from mcp.server.fastmcp import FastMCP

mcp = FastMCP("weather")

@mcp.tool()
async def get_alerts(state: str) -> str:
    """Get weather alerts for a US state.

    Args:
        state: Two-letter US state code (e.g. CA, NY)
    """
    # tool logic
    return result

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics