CoinGecko MCP server

Integrates with CoinGecko Pro API to retrieve cryptocurrency data, enabling market analysis, portfolio tracking, and price monitoring applications.
Back to servers
Setup instructions
Provider
Dennison Bertram
Release date
Dec 31, 2024
Language
TypeScript
Stats
9 stars

The CoinGecko Server is a Model Context Protocol (MCP) server that provides structured access to cryptocurrency data from the CoinGecko Pro API. It can be used with Claude Desktop or integrated with OpenAI function calling to retrieve information about cryptocurrencies, historical prices, and market data.

Installation

Install the package using npm:

npm install coingecko-server

Then create a .env file in your project root with your CoinGecko API key:

COINGECKO_API_KEY=your_api_key_here

Setting Up with Claude Desktop

Claude Desktop offers full support for MCP features. To configure the server:

  1. Install Claude Desktop

  2. Add the server configuration to your Claude Desktop config file:

    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "coingecko": {
      "command": "node",
      "args": ["/path/to/coingecko-server/build/index.js"],
      "env": {
        "COINGECKO_API_KEY": "your-api-key-here"
      }
    }
  }
}
  1. Restart Claude Desktop

Available Tools

The MCP server provides the following tools:

  • get-coins: Retrieve a paginated list of supported cryptocurrencies
  • find-coin-ids: Look up CoinGecko IDs for specific coin names or symbols
  • get-historical-data: Get historical price, market cap, and volume data
  • get-ohlc-data: Retrieve OHLC (Open, High, Low, Close) candlestick data
  • refresh-cache: Refresh the local coin list cache

Integration with OpenAI Function Calling

You can also use the server with OpenAI's function calling capabilities:

import { CoinGeckoService } from 'coingecko-server';
import OpenAI from 'openai';

const openai = new OpenAI();
const coinGeckoService = new CoinGeckoService(process.env.COINGECKO_API_KEY);

// Get function definitions
const functions = CoinGeckoService.getOpenAIFunctionDefinitions();

// Example: Get historical data
const response = await openai.chat.completions.create({
  model: "gpt-4-turbo-preview",
  messages: [{ role: "user", content: "Get Bitcoin's price history for the last week" }],
  functions: [functions[2]], // get_historical_data function
  function_call: "auto",
});

if (response.choices[0].message.function_call) {
  const args = JSON.parse(response.choices[0].message.function_call.arguments);
  const history = await coinGeckoService.getHistoricalData(
    args.id,
    args.vs_currency,
    args.from,
    args.to,
    args.interval
  );
}

Data Types

OHLCData

interface OHLCData {
  timestamp: number;
  open: number;
  high: number;
  low: number;
  close: number;
}

HistoricalData

interface HistoricalData {
  prices: [number, number][];
  market_caps: [number, number][];
  total_volumes: [number, number][];
}

CoinInfo

interface CoinInfo {
  id: string;
  symbol: string;
  name: string;
  platforms?: Record<string, string>;
}

Rate Limits

For current rate limits and usage guidelines, refer to the CoinGecko Pro API documentation.

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "coingecko" '{"command":"node","args":["/path/to/coingecko-server/build/index.js"],"env":{"COINGECKO_API_KEY":"your-api-key-here"}}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "coingecko": {
            "command": "node",
            "args": [
                "/path/to/coingecko-server/build/index.js"
            ],
            "env": {
                "COINGECKO_API_KEY": "your-api-key-here"
            }
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "coingecko": {
            "command": "node",
            "args": [
                "/path/to/coingecko-server/build/index.js"
            ],
            "env": {
                "COINGECKO_API_KEY": "your-api-key-here"
            }
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later