CO
OfficialFinance

CoinGecko MCP Server: Crypto Prices and Market Data

Access CoinGecko's MCP server for real-time crypto prices and market data across 200+ blockchains and 8M+ tokens.

Quick Install
npx -y @packages/mcp-server

Overview

The CoinGecko MCP Server exposes CoinGecko’s market data to model-driven agents and developer tools via the Model Context Protocol (MCP). It provides programmatic access to real-time prices, market caps, liquidity and other market data for millions of tokens across 200+ blockchains, making it straightforward for agents to fetch, analyze and act on crypto price information.

This server is designed for two common deployment patterns: run locally or launch as a remote HTTP-backed MCP server. It runs in “Code Mode”, where agents can execute TypeScript code against a sandboxed CoinGecko TypeScript SDK and also query SDK documentation. This combination enables deterministic, repeatable operations (for example: compute portfolio value, fetch historical series, validate price feeds) without giving agents unrestricted network or filesystem access.

Features

  • Real-time price and market data for 8M+ tokens across 200+ blockchains
  • Code Mode: sandboxed TypeScript SDK execution for deterministic agent actions
  • Documentation search tool to help agents discover SDK APIs and examples
  • Works locally via npx or integrated with MCP-compatible clients (Cursor, VS Code, Claude, etc.)
  • Can be run as a remote HTTP MCP server with header-based API key authorization
  • Secure sandbox: no arbitrary web or filesystem access during code execution

Installation / Configuration

Requirements: Node 18+ (for npx invocation) and your CoinGecko API keys (pro/demo) if you need paid endpoints or rate-limited features.

Direct invocation (quick start)

export COINGECKO_PRO_API_KEY="MyProApiKey"
export COINGECKO_DEMO_API_KEY="MyDemoApiKey"
export COINGECKO_ENVIRONMENT="pro"   # or "demo" / "production" depending on setup

# Run the MCP server via npx
npx -y @coingecko/coingecko-mcp@latest

Example MCP client configuration (local or embedded client)

{
  "mcpServers": {
    "coingecko_api": {
      "command": "npx",
      "args": ["-y", "@coingecko/coingecko-mcp"],
      "env": {
        "COINGECKO_PRO_API_KEY": "MyProApiKey",
        "COINGECKO_DEMO_API_KEY": "MyDemoApiKey",
        "COINGECKO_ENVIRONMENT": "pro"
      }
    }
  }
}

Run as a remote HTTP MCP server

# launch server with HTTP transport on port 3000
npx -y @coingecko/coingecko-mcp --transport=http --port=3000

Client-side remote configuration example (server at http://localhost:3000)

{
  "mcpServers": {
    "coingecko_coingecko_typescript_api": {
      "url": "http://localhost:3000",
      "headers": {
        "x-cg-pro-api-key": "MyProApiKey"
      }
    }
  }
}

Authorization headers (when using remote HTTP transport)

HTTP HeaderClient option keyPurpose / security
x-cg-pro-api-keyproAPIKeyPro API key (pro endpoints)
x-cg-demo-api-keydemoAPIKeyDemo API key (demo endpoints)

Integration tips

  • Cursor, VS Code and other MCP-compatible clients let you add this server to their UI; supply the same environment variables in the client-specific mcp.json or settings.
  • For headless or CI usage, include API keys as environment variables and avoid exposing secrets in public repositories.

Available Tools / Resources

This MCP server implements the Code Mode pattern and exposes two primary tools to agents:

  • Documentation Search Tool: query API and SDK docs so agents can discover available functions, parameter shapes and examples.
  • Code Execution Tool (TypeScript Sandbox): agents can submit TypeScript code that uses the bundled CoinGecko TypeScript SDK. Code runs in an isolated sandbox (no external HTTP, no filesystem); whatever the code prints or returns becomes the tool response.

Sandbox constraints:

  • No arbitrary network access
  • No filesystem read/write
  • Deterministic execution environment (useful for model-driven reasoning)

GitHub repository

  • https://github.com/coingecko/coingecko-typescript/tree/main/packages/mcp-server

Example TypeScript snippet (agent sandbox)

This is an illustrative example of the sort of TypeScript code an agent would execute inside the sandbox to fetch a token price. Exact SDK method names may vary in the SDK version bundled with the server.

// Example executed inside the sandbox provided by the MCP server
async function main() {
  // Construct client - SDK constructor and options depend on the shipped SDK
  const client = new CoinGeckoClient({ environment: process.env.COINGECKO_ENVIRONMENT });

  // Fetch the latest USD price for a token by chain and contract
  const resp = await client.prices.get({
    chain: "ethereum",
    contractAddress: "0x...tokenContract",
    vsCurrency: "usd"
  });

  console.log(JSON.stringify(resp, null, 2));
  return resp;
}

main();

Use Cases

Tags:finance