Skip to main content
Glama

MCP Server Demo

by csc-0812
main.py1.11 kB
from mcp.server import FastMCP from typing import Dict, Any import logging from datetime import datetime # 配置日志(仅控制台输出) logging.basicConfig( level=logging.INFO, format='%(asctime)s - %(message)s', handlers=[logging.StreamHandler()] ) app = FastMCP() @app.tool() def add(a: int, b: int) -> Dict[str, Any]: """加法计算工具 参数: a: 第一个加数 b: 第二个加数 返回: 包含和的结果字典 """ logging.info(f"调用加法工具: {a} + {b}") result = a + b logging.info(f"加法结果: {result}") return {'result': result} @app.tool() def multiply(a: int, b: int) -> Dict[str, Any]: """乘法计算工具 参数: a: 被乘数 b: 乘数 返回: 包含积的结果字典 """ logging.info(f"调用乘法工具: {a} × {b}") result = a * b logging.info(f"乘法结果: {result}") return {'result': result} if __name__ == '__main__': logging.info("启动MCP工具服务器...") app.run(transport='streamable-http')

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/csc-0812/MCPServerDemo'

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