Skip to main content
Glama
kukapay

chainlink-feeds-mcp

listSupportedFeedsByChain

Get available Chainlink price feeds for a specific blockchain network to identify supported data sources for decentralized applications.

Instructions

Returns a comma-separated list of price feed names for a specified blockchain network

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function that destructures the 'chain' parameter, validates it using the schema, retrieves the list of feed names from feedsData for that chain, joins them into a comma-separated string, and returns it as text content. Handles errors by returning an error message.
    async ({ chain }) => {
      try {
        // Validate inputs
        const chainKey = chain.toLowerCase();
        listSupportedFeedsByChainSchema.parse({ chain });
    
        // Get feed names as comma-separated string
        const feedNames = feedsData[chainKey].feeds.map((feed) => feed.name).join(',');
    
        return {
          content: [{
            type: 'text',
            text: feedNames
          }]
        };
      } catch (error) {
        return {
          content: [{
            type: 'text',
            text: `Error: ${error.message}`
          }],
          isError: true
        };
      }
    }
  • Zod schema defining the input parameters for the tool: an object with a required 'chain' string that must correspond to a key in feedsData (validated via refine). Includes description.
    const listSupportedFeedsByChainSchema = z.object({
      chain: z.string().refine((val) => feedsData[val.toLowerCase()], {
        message: 'Unsupported chain'
      }).describe('The blockchain network, e.g., ethereum or base')
    });
  • index.js:196-225 (registration)
    Registers the 'listSupportedFeedsByChain' tool with the MCP server via server.tool(), providing the tool name, description, input schema, and inline asynchronous handler function.
    server.tool(
      'listSupportedFeedsByChain',
      'Returns a comma-separated list of price feed names for a specified blockchain network',
      listSupportedFeedsByChainSchema,
      async ({ chain }) => {
        try {
          // Validate inputs
          const chainKey = chain.toLowerCase();
          listSupportedFeedsByChainSchema.parse({ chain });
    
          // Get feed names as comma-separated string
          const feedNames = feedsData[chainKey].feeds.map((feed) => feed.name).join(',');
    
          return {
            content: [{
              type: 'text',
              text: feedNames
            }]
          };
        } catch (error) {
          return {
            content: [{
              type: 'text',
              text: `Error: ${error.message}`
            }],
            isError: true
          };
        }
      }
    );

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