Skip to main content
Glama

get_crypto_prices

Fetch live BTC, ETH, and SOL prices along with top 24-hour gainers and losers. Data sourced from CoinGecko, with a micropayment of 0.001 USDC per call.

Instructions

Get live cryptocurrency prices and top 24h movers. Returns BTC, ETH, SOL prices plus top gainers/losers. Costs 0.001 USDC per call (x402 micropayment on Base). Data sourced live from CoinGecko.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • src/index.ts:246-258 (registration)
    Tool registered in the TOOLS array with name 'get_crypto_prices', description, and an empty inputSchema (no parameters required).
    const TOOLS = [
      {
        name: 'get_crypto_prices',
        description:
          'Get live cryptocurrency prices and top 24h movers. Returns BTC, ETH, SOL prices plus top gainers/losers. ' +
          'Costs 0.001 USDC per call (x402 micropayment on Base). ' +
          'Data sourced live from CoinGecko.',
        inputSchema: {
          type: 'object',
          properties: {},
          required: [],
        },
      },
  • Handler case in CallToolRequestSchema: calls callApi('/api/price-feed') which fetches live crypto prices via the x402 payment API.
    case 'get_crypto_prices':
      result = await callApi('/api/price-feed');
      break;
  • The callApi helper function handles all API requests, including x402 payment negotiation (auto-pay via wallet or manual 402 response) and 30-second timeout.
    async function callApi(
      endpoint: string,
      params: Record<string, string | number | undefined> = {}
    ): Promise<ApiResponse> {
      const url = new URL(`${API_BASE_URL}${endpoint}`);
      for (const [key, value] of Object.entries(params)) {
        if (value !== undefined && value !== '') {
          url.searchParams.set(key, String(value));
        }
      }
    
      const fetchFn = await getX402Fetch();
    
      let response: Response;
      const controller = new AbortController();
      const fetchTimeout = setTimeout(() => controller.abort(), 30_000);
      try {
        response = await fetchFn(url.toString(), {
          headers: {
            'Accept': 'application/json',
            'User-Agent': `x402-api-mcp/${SERVER_VERSION}`,
          },
          signal: controller.signal,
        });
      } catch (err) {
        const isTimeout = err instanceof Error && err.name === 'AbortError';
        throw new McpError(
          ErrorCode.InternalError,
          isTimeout
            ? `Request to ${endpoint} timed out after 30 seconds`
            : `Network error calling ${endpoint}: ${err instanceof Error ? err.message : String(err)}`
        );
      } finally {
        clearTimeout(fetchTimeout);
      }
    
      if (response.status === 402) {
        // Clone before reading so we can fall back to text() if JSON parsing fails.
        // Without the clone, calling response.json() consumes the body; a subsequent
        // response.text() call then throws "body already used".
        const cloned = response.clone();
        let paymentDetails: unknown;
        try {
          paymentDetails = await response.json();
        } catch {
          paymentDetails = await cloned.text();
        }
        return { status: 402, data: null, paymentRequired: true, paymentDetails };
      }
    
      if (!response.ok) {
        const errorText = await response.text();
        if (response.status === 400 || response.status === 422) {
          throw new McpError(
            ErrorCode.InvalidParams,
            `Invalid request to ${endpoint}: ${errorText}`
          );
        }
        throw new McpError(
          ErrorCode.InternalError,
          `API error ${response.status} from ${endpoint}: ${errorText}`
        );
      }
    
      const data = await response.json();
      return { status: response.status, data };
    }
  • The ApiResponse interface used by the handler to structure the return value.
    interface ApiResponse {
      status: number;
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full burden. It discloses cost, data source, and return contents (prices plus top movers). Could add error handling or update frequency but sufficient for a simple 0-param tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three concise sentences: what it does, what it returns, cost/source. No wasted words, front-loaded with purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema and no annotations, the description covers purpose, cost, data source, and output content. Could mention rate limits or error scenarios, but adequate for a simple call.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

No parameters in schema (100% coverage). Baseline 4 applies as description adds no parameter info, but none needed.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states it gets live cryptocurrency prices and top 24h movers, naming specific coins (BTC, ETH, SOL). Distinguishes from siblings like get_dex_quotes or get_funding_rates by focusing on price data and movers.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Mentions cost (0.001 USDC per call) and data source (CoinGecko), implying usage for price lookups, but does not explicitly state when not to use or mention alternatives among siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/fernsugi/x402-api-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server