mcp-server-sample

linbiaowen/mcp-server-sample

3.2

If you are the rightful owner of mcp-server-sample and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

This is a simple MCP server that provides cryptocurrency prices using the CoinGecko API.

Tools
  1. get_crypto_price

    Fetches the current price of a specified cryptocurrency in a given currency.

MCP Crypto Price Server

This is a simple MCP server exposing a tool to get the current price of a cryptocurrency in a specified currency using the CoinGecko API.

Setup

  1. Clone this repo or copy the files.
  2. Install dependencies:
    pip install -r requirements.txt
    
  3. Set up your CoinGecko API key:
    • Get your API key from CoinGecko.
    • Preferred: Edit api_key.txt and put your API key in it using the following format (key=value):
      COINGECKO_API_KEY=your_actual_api_key_here
      
    • Alternative: If api_key.txt is missing or empty, you can set the COINGECKO_API_KEY environment variable:
      export COINGECKO_API_KEY=your_actual_api_key_here
      
    • Priority: The server will use the key in api_key.txt if present and non-empty. Only if that file is missing or empty will it use the environment variable.

Running the Server

You can run the server in dev mode (recommended for local testing):

uv run mcp dev server.py

Or run directly:

python server.py

Usage

The server exposes a tool:

  • get_crypto_price(crypto_id: str, currency: str = "usd") -> float

Example call:

  • get_crypto_price("bitcoin", "usd") # returns BTC price in USD
  • get_crypto_price("ethereum", "eur") # returns ETH price in EUR

Notes

  • Requires a valid CoinGecko API key. The server will use api_key.txt (in key=value format) if present and non-empty, otherwise it will use the COINGECKO_API_KEY environment variable.
  • See CoinGecko API docs for valid crypto IDs and currencies.