Skip to main content
Glama
chainfetch

ChainFETCH MCP Server

Official
by chainfetch

search_smart_contracts_json

Search smart contracts using JSON queries with 50+ parameters including verification status, programming language, proxy type, and optimization settings to filter blockchain data.

Instructions

JSON search for smart contracts with 50+ parameters

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
is_verifiedNoWhether the contract is verified
nameNoContract name
languageNoProgramming language (e.g., "solidity")
proxy_typeNoProxy type (e.g., "eip1967")
optimization_enabledNoWhether optimization is enabled
limitNoNumber of results to return (default: 10, max: 50)
offsetNoNumber of results to skip for pagination (default: 0)

Implementation Reference

  • Handler implementation for the 'search_smart_contracts_json' tool. It proxies the tool call to the ChainFETCH API endpoint '/api/v1/ethereum/smart-contracts/json_search' using the shared makeRequest helper.
    case 'search_smart_contracts_json': return await this.makeRequest('/api/v1/ethereum/smart-contracts/json_search', 'GET', args, null, token);
  • Input schema defining parameters for the search_smart_contracts_json tool, including filters like is_verified, name, language, proxy_type, optimization_enabled, limit, and offset.
    inputSchema: { type: 'object', properties: { is_verified: { type: 'boolean', description: 'Whether the contract is verified', }, name: { type: 'string', description: 'Contract name', }, language: { type: 'string', description: 'Programming language (e.g., "solidity")', }, proxy_type: { type: 'string', description: 'Proxy type (e.g., "eip1967")', }, optimization_enabled: { type: 'boolean', description: 'Whether optimization is enabled', }, limit: { type: 'integer', description: 'Number of results to return (default: 10, max: 50)', default: 10, }, offset: { type: 'integer', description: 'Number of results to skip for pagination (default: 0)', default: 0, }, }, required: [], },
  • index.js:526-565 (registration)
    Registration of the search_smart_contracts_json tool in the MCP server's listTools handler, including name, description, and input schema.
    { name: 'search_smart_contracts_json', description: 'JSON search for smart contracts with 50+ parameters', inputSchema: { type: 'object', properties: { is_verified: { type: 'boolean', description: 'Whether the contract is verified', }, name: { type: 'string', description: 'Contract name', }, language: { type: 'string', description: 'Programming language (e.g., "solidity")', }, proxy_type: { type: 'string', description: 'Proxy type (e.g., "eip1967")', }, optimization_enabled: { type: 'boolean', description: 'Whether optimization is enabled', }, limit: { type: 'integer', description: 'Number of results to return (default: 10, max: 50)', default: 10, }, offset: { type: 'integer', description: 'Number of results to skip for pagination (default: 0)', default: 0, }, }, required: [], }, },
  • Shared helper function makeRequest used by all tools (including search_smart_contracts_json) to make authenticated HTTP requests to the ChainFETCH API.
    async makeRequest(endpoint, method = 'GET', params = {}, body = null, token = null) { const chainfetchToken = token || process.env.CHAINFETCH_API_TOKEN; if (!chainfetchToken) { throw new McpError( ErrorCode.InvalidRequest, 'CHAINFETCH_API_TOKEN is required' ); } const url = new URL(`${API_BASE_URL}${endpoint}`); // Add query parameters for GET requests if (method === 'GET' && Object.keys(params).length > 0) { Object.entries(params).forEach(([key, value]) => { if (value !== undefined && value !== null) { if (Array.isArray(value)) { value.forEach(v => url.searchParams.append(`${key}[]`, v)); } else { url.searchParams.append(key, value.toString()); } } }); } const fetchOptions = { method, headers: { 'Authorization': `Bearer ${chainfetchToken}`, 'Content-Type': 'application/json', }, }; if (body && method !== 'GET') { fetchOptions.body = JSON.stringify(body); } const response = await fetch(url.toString(), fetchOptions); if (!response.ok) { const errorText = await response.text(); throw new McpError( ErrorCode.InternalError, `API request failed: ${response.status} ${response.statusText} - ${errorText}` ); } return await response.json(); }

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

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