yoelbassin/CryptoMCP
If you are the rightful owner of CryptoMCP 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.
Crypto MCP Server is a FastMCP server providing real-time cryptocurrency data from the API Ninjas Crypto API.
๐ช Crypto MCP Server
A FastMCP server providing real-time cryptocurrency data from the API Ninjas Crypto API.
This server exposes tools via the Model Context Protocol (MCP) allowing compatible clients (like Claude, Cursor, etc.) to easily query cryptocurrency symbols and their current prices.
โจ Features
- List Symbols: Get a list of all available cryptocurrency symbols.
- Get Price: Fetch the current price and timestamp for a specific symbol.
- MCP Compliant: Built using FastMCP for standard MCP communication.
- Async API Client: Uses
httpxfor efficient, non-blocking API calls. - Validated Data: Uses
pydanticfor robust data validation. - Tested: Includes unit and integration tests (
pytest).
๐ Getting Started
Follow these steps to set up and run the server locally.
Prerequisites
- Python 3.10 or higher
git- A virtual environment tool (like
venvoruv) - An API Key from API Ninjas (specifically for the Crypto API)
Installation & Setup
-
Clone the repository:
git clone https://github.com/<your-username>/crypto-mcp-server.git # Replace with actual repo URL cd crypto-mcp-server -
Create and activate a virtual environment: Using
venv(standard library):python3 -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`Using
uv(if installed):uv venv venv source venv/bin/activate -
Install dependencies: Using
pip(withvenv):pip install -e ".[dev]" # Installs in editable mode + dev dependencies*Using
uv:uv sync --all-features -
Create
.envfile: Create a file named.envin the project root directory and add your API key:API_NIINJAS_API_KEY="YOUR_API_NINJAS_CRYPTO_API_KEY"Replace
YOUR_API_NINJAS_CRYPTO_API_KEYwith the actual key you obtained.
Running the Server
Once set up, you can run the MCP server using the fastmcp command:
fastmcp run main.py
The server will typically start on http://127.0.0.1:8000.
You can then connect your MCP client to this address.
๐ ๏ธ Available Tools
The server exposes the following tools to MCP clients:
list_crypto_symbols():- Description: Fetches a list of all available cryptocurrency symbols from the API.
- Returns:
List[str]- A list of symbol strings (e.g.,['BTCUSD', 'ETHBTC', ...]).
get_crypto_price(symbol: str):- Description: Fetches the current price and timestamp for a specific cryptocurrency symbol.
- Args:
symbol(str): The cryptocurrency symbol (e.g., 'BTCUSD', 'ETHBTC'). Uselist_crypto_symbolsto find available symbols.
- Returns:
Dict[str, Any]- A dictionary containing the symbol, its price (as a string), and the Unix timestamp (e.g.,{'symbol': 'BTCUSD', 'price': '65432.10', 'timestamp': 1678886400}). - Raises:
ValueErrorif the symbol is not found or invalid.
๐งช Development & Testing
To run the tests:
- Ensure you have installed the development dependencies (
pip install -e ".[dev]"oruv sync --all-features). - Run pytest:
pytest -v
Integration tests require a valid API_NIINJAS_API_KEY in your .env file and will be skipped otherwise.
๐ Contributing
Contributions are welcome! Please feel free to open an issue or submit a pull request.
๐ License
This project is licensed under the MIT License - see the file for details (assuming MIT, create LICENSE file if needed).