from mcp.server.fastmcp import FastMCP
# Create a new FastMCP server instance
# We enable stateless_http=True and json_response=True for easier testing/deployment
# We set streamable_http_path="/" so that when mounted, it doesn't add an extra path segment.
mcp = FastMCP("My Awesome Server", stateless_http=True, json_response=True, streamable_http_path="/")
@mcp.tool()
def add(a: int, b: int) -> int:
"""Add two integers and return the result."""
return a + b
@mcp.resource("greeting://{name}")
def get_greeting(name: str) -> str:
"""Get a personalized greeting."""
return f"Hello, {name}!"
@mcp.prompt()
def stock_analyst_prompt(question: str) -> str:
"""Answer a question as a stock market analyst."""
return f"You are a helpful AI assistant. You can help with general queries and questions about the stock market. Answer the following question: {question}"
if __name__ == "__main__":
mcp.run(transport='stdio')