Skip to main content
Glama
kukapay

chainlink-feeds-mcp

queryPriceByRound

Retrieve historical price data for cryptocurrency pairs by specifying round ID and chain, enabling analysis of past market conditions through Chainlink's decentralized feeds.

Instructions

Queries the price for a given pair and round ID on a specified chain (placeholder due to historical data limitations)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'queryPriceByRound' tool. It validates inputs, finds the price feed, connects to the blockchain provider, fetches decimals and latest round data (placeholder for specific round), formats the price, and returns structured data or error.
      async ({ roundId, pair, chain }) => {
        try {
          // Validate inputs
          const chainKey = chain.toLowerCase();
          queryPriceSchema.parse({ roundId, pair, chain });
    
          // Find feed by pair
          const feed = feedsData[chainKey].feeds.find((f) => f.name.toLowerCase() === pair.toLowerCase());
          if (!feed) {
            throw new Error(`Pair ${pair} not found on chain ${chain}`);
          }
    
          // Initialize provider and contract
          const provider = new ethers.JsonRpcProvider(`${feedsData[chainKey].baseUrl}/${process.env.INFURA_API_KEY}`);
          const priceFeedContract = new ethers.Contract(feed.proxyAddress, priceFeedAbi, provider);
    
          // Note: getRoundData may not be supported for historical rounds
          const decimals = await priceFeedContract.decimals();
          const roundData = await priceFeedContract.latestRoundData(); // Placeholder
    
          const price = ethers.formatUnits(roundData.answer, decimals);
          const timestamp = Number(roundData.updatedAt) * 1000;
    
          return {
            content: [{
              type: 'text',
              text: JSON.stringify({
                chain,
                pair,
                price: Number(price),
                decimals: Number(decimals),
                roundId,
                timestamp: new Date(timestamp).toISOString(),
                proxyAddress: feed.proxyAddress,
                feedCategory: feed.feedCategory
              }, null, 2)
            }]
          };
        } catch (error) {
          return {
            content: [{
              type: 'text',
              text: `Error: ${error.message}`
            }],
            isError: true
          };
        }
      }
    );
  • Zod schema defining the input parameters for the 'queryPriceByRound' tool: roundId (string number), pair (string), chain (validated against feedsData).
    const queryPriceSchema = z.object({
      roundId: z.string().regex(/^\d+$/, 'Round ID must be a number').describe('The round ID for the price data'),
      pair: z.string().describe('The price feed pair, e.g., FIL/ETH or FDUSD/USD'),
      chain: z.string().refine((val) => feedsData[val.toLowerCase()], {
        message: 'Unsupported chain'
      }).describe('The blockchain network, e.g., ethereum or base')
    });
  • index.js:103-156 (registration)
    The server.tool registration call that registers the 'queryPriceByRound' tool with name, description, schema, and handler function.
    server.tool(
      'queryPriceByRound',
      'Queries the price for a given pair and round ID on a specified chain (placeholder due to historical data limitations)',
      queryPriceSchema,
      async ({ roundId, pair, chain }) => {
        try {
          // Validate inputs
          const chainKey = chain.toLowerCase();
          queryPriceSchema.parse({ roundId, pair, chain });
    
          // Find feed by pair
          const feed = feedsData[chainKey].feeds.find((f) => f.name.toLowerCase() === pair.toLowerCase());
          if (!feed) {
            throw new Error(`Pair ${pair} not found on chain ${chain}`);
          }
    
          // Initialize provider and contract
          const provider = new ethers.JsonRpcProvider(`${feedsData[chainKey].baseUrl}/${process.env.INFURA_API_KEY}`);
          const priceFeedContract = new ethers.Contract(feed.proxyAddress, priceFeedAbi, provider);
    
          // Note: getRoundData may not be supported for historical rounds
          const decimals = await priceFeedContract.decimals();
          const roundData = await priceFeedContract.latestRoundData(); // Placeholder
    
          const price = ethers.formatUnits(roundData.answer, decimals);
          const timestamp = Number(roundData.updatedAt) * 1000;
    
          return {
            content: [{
              type: 'text',
              text: JSON.stringify({
                chain,
                pair,
                price: Number(price),
                decimals: Number(decimals),
                roundId,
                timestamp: new Date(timestamp).toISOString(),
                proxyAddress: feed.proxyAddress,
                feedCategory: feed.feedCategory
              }, null, 2)
            }]
          };
        } catch (error) {
          return {
            content: [{
              type: 'text',
              text: `Error: ${error.message}`
            }],
            isError: true
          };
        }
      }
    );
Behavior2/5

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

With no annotations, the description carries the full burden but only vaguely hints at behavior ('placeholder due to historical data limitations'), without disclosing operational traits like error handling, data sources, or limitations. It fails to add meaningful context beyond the basic purpose.

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

Conciseness3/5

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

The description is brief but front-loaded with the core purpose. The second sentence ('placeholder due to historical data limitations') is somewhat redundant and doesn't add value, reducing efficiency. Overall, it's concise but could be more structured.

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

Completeness2/5

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

Given the lack of annotations and output schema, the description is incomplete for a query tool. It doesn't explain return values, error cases, or how it differs from siblings like 'getLatestPrice', leaving significant gaps in contextual understanding.

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?

The input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description mentions parameters ('pair', 'round ID', 'chain') but doesn't add semantics beyond what's implied, which is acceptable given the baseline. However, the placeholder note adds minor confusion.

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

Purpose3/5

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

The description states the tool 'queries the price for a given pair and round ID on a specified chain', which provides a clear verb ('queries') and resource ('price'), but it's vague about the specific context (e.g., what type of price or system). The phrase 'placeholder due to historical data limitations' adds confusion rather than clarity, making the purpose less definitive.

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

Usage Guidelines2/5

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

No explicit guidance is provided on when to use this tool versus alternatives like 'getLatestPrice' or other sibling tools. The description implies it's for historical data queries but doesn't specify scenarios or prerequisites, leaving the agent without clear usage context.

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/kukapay/chainlink-feeds-mcp'

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