Skip to main content
Glama

Calculator MCP Server

main.py1.12 kB
from fastmcp import FastMCP import random import json # Create the MCP Server instance mcp = FastMCP("Simple Calculator Server") # Tool: Add two numbers @mcp.tool def add(a:int, b:int) -> dict: """Add two numbers together Args: a: First number b: Second number Returns: The sum of a and b """ return {"result": a + b} @mcp.tool def random_number(min: int=1, max: int=100) -> dict: """Generate a random number between min and max Args: min: Minimum value (default: 1) max: Maximum value (default: 100) Returns: A random number between min and max """ return {"result":random.randint(min, max)} @mcp.resource('info://server') def server_info()->str: """Get information about the server.""" info = { "name": mcp.name, "version": mcp.version, "tools": ['add', 'random_number'], "author": "Suraj Kumar" } return json.dumps(info, indent=1) if __name__ == "__main__": # mcp.run() mcp.run(transport="http", host="127.0.0.1", port=5000)

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/surajkumar0203/Calculator-using-MCP'

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