Skip to main content
Glama

API Docs MCP Server

server.py1.87 kB
from mcp.server.fastmcp import FastMCP, Context # Create an MCP server specifically for basic math operations mcp = FastMCP( "Basic Math Calculator", dependencies=[] # No external dependencies needed for basic math ) # Basic mathematical operations @mcp.tool() def add(a: float, b: float) -> float: """ Add two numbers together. Args: a: First number b: Second number Returns: The sum of a and b """ return a + b @mcp.tool() def subtract(a: float, b: float) -> float: """ Subtract the second number from the first. Args: a: Number to subtract from b: Number to subtract Returns: The result of a - b """ return a - b @mcp.tool() def multiply(a: float, b: float) -> float: """ Multiply two numbers together. Args: a: First number b: Second number Returns: The product of a and b """ return a * b @mcp.tool() def divide(a: float, b: float) -> str: """ Divide the first number by the second. Args: a: Numerator b: Denominator Returns: The result of a / b """ if b == 0: return "Error: Division by zero is not allowed" return str(a / b) # A resource with basic calculator instructions @mcp.resource("calculator://help") def calculator_help() -> str: """Basic calculator help information.""" return """ # Basic Math Calculator This calculator provides the following operations: - Addition: Use the `add` tool with two numbers - Subtraction: Use the `subtract` tool with two numbers - Multiplication: Use the `multiply` tool with two numbers - Division: Use the `divide` tool with two numbers Example: - To add 5 and 3, use: `add(5, 3)` """

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/ShotaNagafuchi/api-docs-mcp'

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