UNPKG

infura-mcp-server

Version:

Model Context Protocol (MCP) server providing comprehensive read-only Ethereum blockchain access through Infura's infrastructure. Connect Claude Desktop, VS Code, and Cursor to 29 secure Ethereum JSON-RPC tools across 30+ networks including Ethereum, Poly

60 lines (57 loc) 1.77 kB
import { callInfura } from "../lib/infura-client.js"; /** * Function to get block information by hash from the Ethereum network using Infura. * * @param {Object} args - Arguments for the block retrieval. * @param {string} args.blockHash - The 32-byte hash of the block to retrieve. * @param {boolean} args.fullTransactions - If true, returns full transaction objects; if false, returns transaction hashes. * @param {string} [args.network="mainnet"] The network to query. * @returns {Promise<Object>} - The result of the block retrieval. */ const executeFunction = async ({ blockHash, fullTransactions, network = "mainnet", }) => { return callInfura( "eth_getBlockByHash", [blockHash, fullTransactions], network ); }; /** * Tool configuration for retrieving block information by hash from Infura. * @type {Object} */ const apiTool = { function: executeFunction, definition: { type: "function", function: { name: "eth_getBlockByHash", description: "Retrieve block information by hash from a specified Ethereum network.", parameters: { type: "object", properties: { blockHash: { type: "string", description: "The 32-byte hash of the block to retrieve.", }, fullTransactions: { type: "boolean", description: "If true, returns full transaction objects; if false, returns transaction hashes.", }, network: { type: "string", description: "The Ethereum network to query, e.g., 'mainnet' or 'sepolia'.", default: "mainnet", }, }, required: ["blockHash", "fullTransactions"], }, }, }, }; export { apiTool };