cg-api-mcp
v0.1.0-alpha.2
Published
The official MCP Server for the Cg API API
Readme
Cg API TypeScript MCP Server
It is generated with Stainless.
Installation
Direct invocation
You can run the MCP Server directly via npx:
export CG_API_API_KEY="My API Key"
npx -y cg-api-mcp@latestVia MCP Client
There is a partial list of existing clients at modelcontextprotocol.io. If you already have a client, consult their documentation to install the MCP server.
For clients with a configuration JSON, it might look something like this:
{
"mcpServers": {
"cg_api_test_api": {
"command": "npx",
"args": ["-y", "cg-api-mcp", "--client=claude", "--tools=dynamic"],
"env": {
"CG_API_API_KEY": "My API Key"
}
}
}
}Exposing endpoints to your MCP Client
There are two ways to expose endpoints as tools in the MCP server:
- Exposing one tool per endpoint, and filtering as necessary
- Exposing a set of tools to dynamically discover and invoke endpoints from the API
Filtering endpoints and tools
You can run the package on the command line to discover and filter the set of tools that are exposed by the MCP Server. This can be helpful for large APIs where including all endpoints at once is too much for your AI's context window.
You can filter by multiple aspects:
--toolincludes a specific tool by name--resourceincludes all tools under a specific resource, and can have wildcards, e.g.my.resource*--operationincludes just read (get/list) or just write operations
Dynamic tools
If you specify --tools=dynamic to the MCP server, instead of exposing one tool per endpoint in the API, it will
expose the following tools:
list_api_endpoints- Discovers available endpoints, with optional filtering by search queryget_api_endpoint_schema- Gets detailed schema information for a specific endpointinvoke_api_endpoint- Executes any endpoint with the appropriate parameters
This allows you to have the full set of API endpoints available to your MCP Client, while not requiring that all of their schemas be loaded into context at once. Instead, the LLM will automatically use these tools together to search for, look up, and invoke endpoints dynamically. However, due to the indirect nature of the schemas, it can struggle to provide the correct properties a bit more than when tools are imported explicitly. Therefore, you can opt-in to explicit tools, the dynamic tools, or both.
See more information with --help.
All of these command-line options can be repeated, combined together, and have corresponding exclusion versions (e.g. --no-tool).
Use --list to see the list of available tools, or see below.
Specifying the MCP Client
Different clients have varying abilities to handle arbitrary tools and schemas.
You can specify the client you are using with the --client argument, and the MCP server will automatically
serve tools and schemas that are more compatible with that client.
--client=<type>: Set all capabilities based on a known MCP client- Valid values:
openai-agents,claude,claude-code,cursor - Example:
--client=cursor
- Valid values:
Additionally, if you have a client not on the above list, or the client has gotten better over time, you can manually enable or disable certain capabilities:
--capability=<name>: Specify individual client capabilities- Available capabilities:
top-level-unions: Enable support for top-level unions in tool schemasvalid-json: Enable JSON string parsing for argumentsrefs: Enable support for $ref pointers in schemasunions: Enable support for union types (anyOf) in schemasformats: Enable support for format validations in schemas (e.g. date-time, email)tool-name-length=N: Set maximum tool name length to N characters
- Example:
--capability=top-level-unions --capability=tool-name-length=40 - Example:
--capability=top-level-unions,tool-name-length=40
- Available capabilities:
Examples
- Filter for read operations on cards:
--resource=cards --operation=read- Exclude specific tools while including others:
--resource=cards --no-tool=create_cards- Configure for Cursor client with custom max tool name length:
--client=cursor --capability=tool-name-length=40- Complex filtering with multiple criteria:
--resource=cards,accounts --operation=read --tag=kyc --no-tool=create_cardsImporting the tools and server individually
// Import the server, generated endpoints, or the init function
import { server, endpoints, init } from "cg-api-mcp/server";
// import a specific tool
import checkStatusPing from "cg-api-mcp/tools/ping/check-status-ping";
// initialize the server and all endpoints
init({ server, endpoints });
// manually start server
const transport = new StdioServerTransport();
await server.connect(transport);
// or initialize your own server with specific tools
const myServer = new McpServer(...);
// define your own endpoint
const myCustomEndpoint = {
tool: {
name: 'my_custom_tool',
description: 'My custom tool',
inputSchema: zodToJsonSchema(z.object({ a_property: z.string() })),
},
handler: async (client: client, args: any) => {
return { myResponse: 'Hello world!' };
})
};
// initialize the server with your custom endpoints
init({ server: myServer, endpoints: [checkStatusPing, myCustomEndpoint] });Available Tools
The following tools are available in this MCP server.
Resource ping:
check_status_ping(read): This endpoint allows you to check the API server status
Resource key:
retrieve_key(read): This endpoint allows you to monitor your account's API usage, including rate limits, monthly total credits, remaining credits, and more
Resource simple:
get_price_simple(read): This endpoint allows you to query the prices of one or more coins by using their unique Coin API IDsget_token_price_simple(read): This endpoint allows you to query one or more token prices using their token contract addresseslist_supported_currencies_simple(read): This endpoint allows you to query all the supported currencies on CoinGecko
Resource coins:
list_top_gainers_losers_coins(read): This endpoint allows you to query the top 30 coins with largest price gain and loss by a specific time durationlist_with_market_data_coins(read): This endpoint allows you to query all the supported coins with price, market cap, volume and market related dataretrieve_by_id_coins(read): This endpoint allows you to query all the metadata (image, websites, socials, description, contract address, etc.) and market data (price, ATH, exchange tickers, etc.) of a coin from the CoinGecko coin page based on a particular coin IDretrieve_historical_data_by_id_coins(read): This endpoint allows you to query the historical data (price, market cap, 24hrs volume, ...) at a given date for a coin based on a particular coin IDretrieve_tickers_by_id_coins(read): This endpoint allows you to query the coin tickers on both centralized exchange (CEX) and decentralized exchange (DEX) based on a particular coin ID
Resource coins.list:
get_all_coins_list(read): This endpoint allows you to query all the supported coins on CoinGecko with coins ID, name and symbolget_recently_added_coins_list(read): This endpoint allows you to query the latest 200 coins that recently listed on CoinGecko
Resource coins.market_chart:
retrieve_by_id_coins_market_chart(read): This endpoint allows you to get the historical chart data of a coin including time in UNIX, price, market cap and 24hr volume based on particular coin IDretrieve_range_by_id_coins_market_chart(read): This endpoint allows you to get the historical chart data of a coin within certain time range in UNIX along with price, market cap and 24hr volume based on particular coin ID
Resource coins.ohlc:
retrieve_by_id_coins_ohlc(read): This endpoint allows you to get the OHLC chart (Open, High, Low, Close) of a coin based on particular coin IDretrieve_range_by_id_coins_ohlc(read): This endpoint allows you to get the OHLC chart (Open, High, Low, Close) of a coin within a range of timestamp based on particular coin ID
Resource coins.contract:
get_by_address_coins_contract(read): This endpoint allows you to query all the metadata (image, websites, socials, description, contract address, etc.) and market data (price, ATH, exchange tickers, etc.) of a coin from the CoinGecko coin page based on an asset platform and a particular token contract address
Resource coins.contract.market_chart:
retrieve_by_address_contract_coins_market_chart(read): This endpoint allows you to get the historical chart data including time in UNIX, price, market cap and 24hr volume based on asset platform and particular token contract addressretrieve_range_by_address_contract_coins_market_chart(read): This endpoint allows you to get the historical chart data within certain time range in UNIX along with price, market cap and 24hr volume based on asset platform and particular token contract address
Resource coins.circulating_supply_chart:
retrieve_by_id_coins_circulating_supply_chart(read): This endpoint allows you to query historical circulating supply of a coin by number of days away from now based on provided coin IDretrieve_range_by_id_coins_circulating_supply_chart(read): This endpoint allows you to query historical circulating supply of a coin, within a range of timestamp based on the provided coin ID
Resource coins.total_supply_chart:
retrieve_by_id_coins_total_supply_chart(read): This endpoint allows you to query historical total supply of a coin by number of days away from now based on provided coin IDretrieve_range_by_id_coins_total_supply_chart(read): This endpoint allows you to query historical total supply of a coin, within a range of timestamp based on the provided coin ID
Resource coins.categories:
list_all_coins_categories(read): This endpoint allows you to query all the coins categories on CoinGeckolist_with_market_data_coins_categories(read): This endpoint allows you to query all the coins categories with market data (market cap, volume, ...) on CoinGecko
Resource asset_platforms:
list_asset_platforms(read): This endpoint allows you to query all the asset platforms on CoinGecko
Resource token_lists:
retrieve_all_token_lists(read): This endpoint allows you to get full list of tokens of a blockchain network (asset platform) that is supported by Ethereum token list standard
Resource exchanges:
retrieve_exchanges(read): This endpoint allows you to query exchange’s data (name, year established, country, ...), exchange volume in BTC and top 100 tickers based on exchange’s IDlist_exchanges(read): This endpoint allows you to query all the supported exchanges with exchanges’ data (ID, name, country, ...) that have active trading volumes on CoinGeckolist_id_map_exchanges(read): This endpoint allows you to query all the exchanges with ID and nameretrieve_tickers_exchanges(read): This endpoint allows you to query exchange's tickers based on exchange’s ID
Resource exchanges.volume_chart:
retrieve_exchanges_volume_chart(read): This endpoint allows you to query the historical volume chart data with time in UNIX and trading volume data in BTC based on exchange’s IDretrieve_range_exchanges_volume_chart(read): This endpoint allows you to query the historical volume chart data in BTC by specifying date range in UNIX based on exchange’s ID
Resource derivatives:
list_derivatives(read): This endpoint allows you to query all the tickers from derivatives exchanges on CoinGecko
Resource derivatives.exchanges:
retrieve_derivatives_exchanges(read): This endpoint allows you to query the derivatives exchange’s related data (ID, name, open interest, ...) based on the exchanges’ IDlist_derivatives_exchanges(read): This endpoint allows you to query all the derivatives exchanges with related data (ID, name, open interest, ...) on CoinGeckoid_map_derivatives_exchanges(read): This endpoint allows you to query all the derivatives exchanges with ID and name on CoinGecko
Resource nfts:
retrieve_nfts(read): This endpoint allows you to query all the NFT data (name, floor price, 24hr volume ...) based on the NFT collection IDlist_nfts(read): This endpoint allows you to query all supported NFTs with ID, contract address, name, asset platform ID and symbol on CoinGeckolist_with_market_data_nfts(read): This endpoint allows you to query all the supported NFT collections with floor price, market cap, volume and market related data on CoinGeckoretrieve_market_chart_nfts(read): This endpoint allows you query historical market data of a NFT collection, including floor price, market cap, and 24hr volume, by number of days away from nowretrieve_tickers_nfts(read): This endpoint allows you to query the latest floor price and 24hr volume of a NFT collection, on each NFT marketplace, e.g. OpenSea and LooksRare
Resource nfts.contract:
retrieve_nfts_contract(read): This endpoint allows you to query all the NFT data (name, floor price, 24hr volume ...) based on the NFT collection contract address and respective asset platformretrieve_market_chart_nfts_contract(read): This endpoint allows you query historical market data of a NFT collection, including floor price, market cap, and 24hr volume, by number of days away from now based on the provided contract address
Resource exchange_rates:
list_exchange_rates(read): This endpoint allows you to query BTC exchange rates with other currencies
Resource search:
query_search(read): This endpoint allows you to search for coins, categories and markets listed on CoinGeckotrending_search(read): This endpoint allows you query trending search coins, NFTs and categories on CoinGecko in the last 24 hours
Resource global:
retrieve_global(read): This endpoint allows you query cryptocurrency global data including active cryptocurrencies, markets, total crypto market cap and etcretrieve_decentralized_finance_global(read): This endpoint allows you query top 100 cryptocurrency global decentralized finance (DeFi) data including DeFi market cap, trading volumeretrieve_market_cap_chart_global(read): This endpoint allows you to query historical global market cap and volume data by number of days away from now
Resource companies:
retrieve_public_treasury_companies(read): This endpoint allows you query public companies’ Bitcoin or Ethereum holdings
