get_nft_collection
Get detailed NFT collection data: floor price, market cap, volume, unique holders, total supply, and links. Provide a CoinGecko NFT ID to receive current metrics and market insights.
Instructions
Get detailed data for a single NFT collection: floor price, market cap, volume, holders, links.
Args:
nft_id: CoinGecko NFT collection ID, e.g. "bored-ape-yacht-club",
"cryptopunks". Use search or list_nfts to find IDs.
Returns:
NFT collection object with floor_price, market_cap, volume_24h,
floor_price_in_usd_24h_percentage_change, number_of_unique_addresses,
total_supply, links, image, etc.
Note: nft_id is validated against ^[a-z0-9][a-z0-9._-]{0,127}$.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| nft_id | Yes |
Implementation Reference
- coin_mcp/coingecko.py:514-531 (handler)The actual handler function for the get_nft_collection tool. Validates nft_id then calls CoinGecko API GET /nfts/{nft_id}.
async def get_nft_collection(nft_id: str) -> Any: """Get detailed data for a single NFT collection: floor price, market cap, volume, holders, links. Args: nft_id: CoinGecko NFT collection ID, e.g. "bored-ape-yacht-club", "cryptopunks". Use `search` or `list_nfts` to find IDs. Returns: NFT collection object with `floor_price`, `market_cap`, `volume_24h`, `floor_price_in_usd_24h_percentage_change`, `number_of_unique_addresses`, `total_supply`, `links`, `image`, etc. Note: `nft_id` is validated against `^[a-z0-9][a-z0-9._-]{0,127}$`. """ err = _validate_id(nft_id, "nft_id") if err is not None: return err return await _cg_get(f"/nfts/{nft_id}") - coin_mcp/coingecko.py:513-514 (registration)Registration of get_nft_collection via @mcp.tool() decorator from the shared FastMCP instance.
@mcp.tool() async def get_nft_collection(nft_id: str) -> Any: - coin_mcp/coingecko.py:20-33 (helper)Helper function _validate_id used to validate nft_id input against path-injection regex.
def _validate_id(value: str, kind: str = "id") -> dict | None: """Return None when valid, or a JSON error dict when not. Used to harden tools that interpolate caller-supplied strings into URL paths against path traversal / query-param smuggling. """ if not isinstance(value, str) or not _ID_RE.match(value): return { "error": ( f"invalid {kind}: must match ^[a-z0-9][a-z0-9._-]{{0,127}}$, " f"got {value!r}" ) } return None - coin_mcp/core.py:220-225 (helper)Core HTTP helper _cg_get that constructs the CoinGecko API URL and makes the request for the handler.
async def _cg_get(path: str, params: dict[str, Any] | None = None) -> Any: return await _http_get( f"{_coingecko_base()}{path}", params=params, headers=_coingecko_headers(), ) - coin_mcp/coingecko.py:518-527 (schema)Schema documentation for the tool's input parameter nft_id and return type.
nft_id: CoinGecko NFT collection ID, e.g. "bored-ape-yacht-club", "cryptopunks". Use `search` or `list_nfts` to find IDs. Returns: NFT collection object with `floor_price`, `market_cap`, `volume_24h`, `floor_price_in_usd_24h_percentage_change`, `number_of_unique_addresses`, `total_supply`, `links`, `image`, etc. Note: `nft_id` is validated against `^[a-z0-9][a-z0-9._-]{0,127}$`. """