We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/whitmanca/mcp-crypto-price'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
server.py•1.27 kB
from typing import Dict
from mcp.server.fastmcp import FastMCP
from src.api import make_coin_gecko_request
from src.config import settings
from src.schemas import CurrencyPrice
# Initialize FastMCP server
mcp = FastMCP("crypto")
# Define MCP tools
@mcp.tool()
async def get_crypto_price_by_name(coin_name: str) -> Dict[str, CurrencyPrice] | str:
"""Get latest price for a coin by its name
Args:
coin_name: str = The name of the coin (e.g. Bitcoin)
"""
url = f"{settings.COIN_GECKO_BASE}?vs_currencies=usd&names={coin_name}"
data = await make_coin_gecko_request(url)
if not data:
return "Unable to fetch current price data for this coin."
return data
@mcp.tool()
async def get_crypto_price_by_symbol(
coin_symbol: str,
) -> Dict[str, CurrencyPrice] | str:
"""Get latest price for a coin by its symbol
Args:
coin_symbol: str = The symbol of the coin (e.g. BTC)
"""
url = f"{settings.COIN_GECKO_BASE}?vs_currencies=usd&symbols={coin_symbol}"
data = await make_coin_gecko_request(url)
if not data:
return "Unable to fetch current price data for this coin."
return data
if __name__ == "__main__":
# Initialize and run the server
mcp.run(transport="stdio")