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.
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
Claude Desktop offers full support for MCP features. To configure the server:
Install Claude Desktop
Add the server configuration to your Claude Desktop config file:
~/Library/Application Support/Claude/claude_desktop_config.json
%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"
}
}
}
}
The MCP server provides the following tools:
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
);
}
interface OHLCData {
timestamp: number;
open: number;
high: number;
low: number;
close: number;
}
interface HistoricalData {
prices: [number, number][];
market_caps: [number, number][];
total_volumes: [number, number][];
}
interface CoinInfo {
id: string;
symbol: string;
name: string;
platforms?: Record<string, string>;
}
For current rate limits and usage guidelines, refer to the CoinGecko Pro API documentation.
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.
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.
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"
}
}
}
}
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.
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.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.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