server.py 859 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. """Pure MCP server over stdio."""
  2. from mcp.server.fastmcp import FastMCP
  3. import services
  4. from mcp_tools import MCP_TOOLS
  5. mcp = FastMCP("crypto-mcp")
  6. @mcp.tool()
  7. async def get_price(symbol: str):
  8. return await services.get_price(symbol)
  9. @mcp.tool()
  10. async def get_ohlcv(symbol: str, timeframe: str = "1h", limit: int = 100):
  11. return await services.get_ohlcv(symbol, timeframe, limit)
  12. @mcp.tool()
  13. async def get_indicator(symbol: str, indicator: str, timeframe: str = "1h", params: dict | None = None):
  14. return await services.get_indicator(symbol, indicator, timeframe, params or {})
  15. @mcp.tool()
  16. async def get_market_snapshot(symbol: str):
  17. return await services.get_market_snapshot(symbol)
  18. @mcp.tool()
  19. async def get_top_movers(limit: int = 10):
  20. return await services.get_top_movers(limit)
  21. if __name__ == "__main__":
  22. mcp.run()