Skip to main content
Glama
binodrajpandey

MCP Server Example

add

Add two numbers together to calculate their sum using this arithmetic tool from the MCP Server Example.

Instructions

Add two numbers.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
aYes
bYes

Implementation Reference

  • server.py:20-23 (handler)
    The 'add' tool handler function. It's registered as an MCP tool via the @mcp.tool() decorator and implements the logic to add two float numbers and return the result.
    @mcp.tool()
    def add(a: float, b: float) -> float:
        """Add two numbers."""
        return a + b
  • server.py:20-20 (registration)
    The @mcp.tool() decorator registers the 'add' function as an MCP tool, making it available for Claude to invoke.
    @mcp.tool()
  • The schema is defined via Python type hints: accepts two float parameters (a, b) and returns a float. The docstring provides the tool description.
    def add(a: float, b: float) -> float:
        """Add two numbers."""
        return a + b
Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/binodrajpandey/mcp-example'

If you have feedback or need assistance with the MCP directory API, please join our Discord server