Skip to main content
Glama

MCP Python Server

by jatindera
mcp_server.py906 B
# server.py from mcp.server.fastmcp import FastMCP # Create an MCP server mcp = FastMCP("Demo") # Add an addition tool @mcp.tool() def add(a: int, b: int) -> int: """Add two numbers""" print(f"Adding {a} and {b}") return a + b @mcp.resource("resource://static_data") def get_static_resource() -> str: """Static resource data""" return "This is a static text" @mcp.resource("greeting://{name}") def get_greeting(name: str) -> str: """Get the personlized greeting""" return f"Hello, {name}!" @mcp.prompt() def review_code(code: str) -> str: return f"Please review this code:\n\n{code}" @mcp.prompt() def debug_error(error: str) -> list[tuple]: return [ ("user", "I'm seeing this error"), ("user", error), ("assistant", "I'll help debug that. What have you tried so far?"), ] if __name__ == "__main__": mcp.run(transport="sse")

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/jatindera/MCPBasic'

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