Skip to main content
Glama
reference.md9.65 kB
# Chainlink MCP Server Reference ## Overview The Chainlink MCP (Model Context Protocol) server provides AI developers with seamless access to Chainlink's decentralized oracle network services. This server follows the Smithery team's established patterns and will be hosted on the Smithery platform. ## Purpose Enable AI developers to easily integrate with Chainlink's ecosystem including: - **Data Feeds**: Access to real-time and historical price feeds, market data, and economic indicators - **Functions**: Serverless compute for custom off-chain logic execution - **Automation**: Trigger smart contract executions based on conditions - **VRF (Verifiable Random Function)**: Generate provably fair random numbers - **CCIP (Cross-Chain Interoperability Protocol)**: Cross-chain messaging and token transfers - **Proof of Reserve**: Verify collateral backing for various assets ## Server Structure Following the Smithery modular pattern due to the complexity and breadth of Chainlink services: ``` chainlink/ ├── package.json ├── smithery.yaml ├── tsconfig.json ├── .gitignore ├── README.md └── src/ ├── index.ts # Main server entry point ├── types/ │ ├── feeds.ts # Data feed type definitions │ ├── functions.ts # Functions type definitions │ ├── automation.ts # Automation type definitions │ ├── vrf.ts # VRF type definitions │ └── ccip.ts # CCIP type definitions ├── tools/ │ ├── feeds.ts # Data feed tools │ ├── functions.ts # Functions tools │ ├── automation.ts # Automation tools │ ├── vrf.ts # VRF tools │ ├── ccip.ts # CCIP tools │ └── proof-of-reserve.ts # Proof of Reserve tools ├── utils/ │ ├── api-client.ts # Chainlink API client wrapper │ ├── formatters.ts # Data formatting utilities │ └── validators.ts # Input validation helpers └── resources/ └── network-configs.ts # Network configuration data ``` ## Dependencies ```json { "dependencies": { "@modelcontextprotocol/sdk": "^1.12.1", "zod": "^3.24.2", "axios": "^1.6.0", "ethers": "^6.8.0", "@chainlink/contracts": "^0.8.0" } } ``` ## Configuration Schema ```typescript export const configSchema = z.object({ // Optional: For premium data access chainlinkApiKey: z.string().optional().describe("Chainlink API key for premium features"), // Network configurations networks: z.record(z.object({ rpcUrl: z.string(), chainId: z.number(), })).optional().describe("Custom network configurations"), // Default network defaultNetwork: z.string().default("ethereum").describe("Default network for operations"), }) ``` ## Core Tool Categories ### 1. Data Feeds Tools (`tools/feeds.ts`) **Tools:** - `get_price_feed`: Get current price for a trading pair - `get_price_feeds_batch`: Get multiple price feeds at once - `get_historical_price`: Get historical price data for a feed - `list_available_feeds`: List all available data feeds for a network - `get_feed_metadata`: Get metadata for a specific price feed - `get_round_data`: Get specific round data from a price feed - `search_feeds`: Search for feeds by asset, category, or description **Example Implementation:** ```typescript export function registerFeedTools(server: McpServer, apiClient: ChainlinkApiClient) { server.tool( "get_price_feed", "Get the latest price data for a specific trading pair from Chainlink Data Feeds", { pair: z.string().describe("Trading pair (e.g., 'ETH/USD', 'BTC/USD')"), network: z.string().optional().describe("Blockchain network (default: ethereum)"), format: z.enum(["raw", "formatted"]).default("formatted").describe("Response format") }, async ({ pair, network, format }) => { // Implementation } ) } ``` ### 2. Chainlink Functions Tools (`tools/functions.ts`) **Tools:** - `deploy_function`: Deploy a new Chainlink Function - `call_function`: Execute a Chainlink Function - `get_function_result`: Get the result of a function execution - `list_user_functions`: List deployed functions for a user - `estimate_function_cost`: Estimate the cost of running a function - `get_function_logs`: Get execution logs for debugging - `update_function_config`: Update function configuration ### 3. Automation Tools (`tools/automation.ts`) **Tools:** - `create_automation`: Create a new automation job - `list_automations`: List existing automation jobs - `get_automation_status`: Check status of an automation job - `pause_automation`: Pause an automation job - `resume_automation`: Resume a paused automation job - `cancel_automation`: Cancel an automation job - `get_automation_history`: Get execution history ### 4. VRF Tools (`tools/vrf.ts`) **Tools:** - `request_random_words`: Request verifiable random numbers - `get_random_result`: Get the result of a VRF request - `verify_randomness`: Verify the randomness proof - `get_vrf_config`: Get VRF configuration for a network - `estimate_vrf_cost`: Estimate cost for VRF request ### 5. CCIP Tools (`tools/ccip.ts`) **Tools:** - `send_cross_chain_message`: Send a message across chains - `transfer_tokens_cross_chain`: Transfer tokens between chains - `get_message_status`: Check cross-chain message status - `list_supported_networks`: List CCIP supported networks - `estimate_ccip_fees`: Estimate cross-chain transaction fees - `get_ccip_lanes`: Get available CCIP lanes between networks ### 6. Proof of Reserve Tools (`tools/proof-of-reserve.ts`) **Tools:** - `get_proof_of_reserve`: Get latest proof of reserve data - `verify_reserve_proof`: Verify a proof of reserve - `list_supported_assets`: List assets with proof of reserve - `get_reserve_history`: Get historical reserve data ## Utility Functions ### API Client (`utils/api-client.ts`) ```typescript export class ChainlinkApiClient { constructor(private config: ConfigType) {} async getPriceFeed(pair: string, network: string): Promise<PriceFeedData> async getNetworkConfig(network: string): Promise<NetworkConfig> async makeRequest(endpoint: string, params: any): Promise<any> } ``` ### Formatters (`utils/formatters.ts`) ```typescript export function formatPrice(price: bigint, decimals: number): string export function formatTimestamp(timestamp: number): string export function formatAddress(address: string): string export function formatGas(gasUsed: bigint): string ``` ## Error Handling Implement comprehensive error handling for: - Network connectivity issues - Invalid contract addresses - Insufficient funds for operations - Rate limiting from APIs - Invalid parameters - Chain-specific errors ## Testing Strategy 1. **Unit Tests**: Test individual tool functions 2. **Integration Tests**: Test with actual Chainlink contracts on testnets 3. **Mock Tests**: Test with mocked API responses 4. **Error Scenarios**: Test error handling and edge cases ## Security Considerations 1. **API Key Management**: Secure handling of Chainlink API keys 2. **Input Validation**: Strict validation of all inputs using Zod 3. **Rate Limiting**: Implement client-side rate limiting 4. **Network Security**: Validate network configurations 5. **Data Sanitization**: Sanitize all output data ## Performance Optimizations 1. **Caching**: Cache frequently requested data feeds 2. **Batch Requests**: Group multiple requests when possible 3. **Connection Pooling**: Reuse HTTP connections 4. **Lazy Loading**: Load network configs on demand ## Documentation ### README.md Structure - Quick start guide - Available tools list with examples - Configuration instructions - Network support matrix - Common use cases - Troubleshooting guide ### Tool Documentation Each tool should include: - Purpose and use cases - Parameter descriptions with examples - Return value format - Error scenarios - Usage examples ## Deployment Configuration ### smithery.yaml ```yaml runtime: typescript ``` ### package.json Scripts ```json { "scripts": { "build": "npx @smithery/cli build", "dev": "npx @smithery/cli dev", "check": "npx @biomejs/biome check --write --unsafe" } } ``` ## Future Enhancements 1. **Real-time Subscriptions**: WebSocket support for live data feeds 2. **Advanced Analytics**: Statistical analysis tools for price data 3. **Multi-chain Aggregation**: Aggregate data across multiple chains 4. **Custom Alerts**: Set up custom price/condition alerts 5. **Portfolio Tracking**: Track portfolio values using Chainlink feeds 6. **DeFi Integration**: Direct integration with major DeFi protocols ## Use Cases for AI Developers 1. **Trading Bots**: Access real-time price data for algorithmic trading 2. **Portfolio Management**: Track and rebalance portfolios automatically 3. **Risk Assessment**: Use price feeds for risk calculation 4. **DeFi Applications**: Build DeFi dApps with reliable price data 5. **Gaming**: Use VRF for provably fair gaming mechanics 6. **Automation**: Automate smart contract interactions based on conditions 7. **Cross-chain Applications**: Build applications spanning multiple blockchains 8. **Research & Analytics**: Analyze historical price and market data This MCP server will provide AI developers with a comprehensive toolkit for integrating Chainlink's oracle services into their applications, following the established Smithery patterns for reliability and ease of use.

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/goldk3y/chainlink-mcp-server'

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