Skip to main content
Glama
CoinStatsHQ

CoinStats MCP Server

Official

get-wallet-transactions

Retrieve transaction history for a cryptocurrency wallet, including details like amounts, dates, and types, after ensuring data synchronization.

Instructions

Get transaction data for a specific wallet. Ensure transactions are synced by calling PATCH /transactions first.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesWallet address
connectionIdYesThe identifier of connection, which you received from /wallet/blockchains call response.
pageNoPage number
limitNoNumber of results per page
fromNoStart date in ISO 8601 format
toNoEnd date in ISO 8601 format
currencyNoCurrency for price dataUSD
typesNoTransaction types, comma separated (deposit,withdraw,approve,executed,balance,fee)
txIdNoTo search with transaction hash

Implementation Reference

  • Defines the schema and configuration for the 'get-wallet-transactions' tool, including Zod parameter validation, endpoint, method, and description.
    { name: 'get-wallet-transactions', description: 'Get transaction data for a specific wallet. Ensure transactions are synced by calling PATCH /transactions first.', endpoint: '/wallet/transactions', method: 'GET', parameters: { address: z.string().describe('Wallet address'), connectionId: z.string().describe('The identifier of connection, which you received from /wallet/blockchains call response.'), page: z.number().optional().describe('Page number').default(1), limit: z.number().optional().describe('Number of results per page').default(20), from: z.string().optional().describe('Start date in ISO 8601 format'), to: z.string().optional().describe('End date in ISO 8601 format'), currency: z.string().optional().describe('Currency for price data').default('USD'), types: z.string().optional().describe('Transaction types, comma separated (deposit,withdraw,approve,executed,balance,fee)'), txId: z.string().optional().describe('To search with transaction hash'), }, },
  • Registers the 'get-wallet-transactions' tool (and others) with the MCP server using the configuration from toolConfigs.ts. Includes the generic handler logic that routes to universalApiHandler for API endpoints.
    export function registerTools(server: McpServer, toolConfigs: ToolConfig<any>[]) { toolConfigs.forEach((config) => { server.tool(config.name, config.description, config.parameters, async (params: Record<string, any>) => { // Handle local operations if (config.isLocal) { // Handle specific local tools if (config.name === 'save-share-token') { await saveToCache('shareToken', params.shareToken); return { content: [ { type: 'text', text: 'Share token saved successfully', }, ], }; } if (config.name === 'get-share-token') { const shareToken = await getFromCache('shareToken'); return { content: [ { type: 'text', text: shareToken ? shareToken : 'No share token found in cache', isError: !shareToken, }, ], }; } // Future local tools can be added here // Default response for unhandled local tools return { content: [ { type: 'text', text: 'Operation completed', }, ], }; } // Handle API operations const basePath = config.basePath || COINSTATS_API_BASE; const method = config.method || 'GET'; // Methods that typically have a request body const bodyMethods = ['POST', 'PUT', 'PATCH', 'DELETE']; // For GET/DELETE requests, all params go in the URL // For POST/PUT/PATCH, send params as the body if (bodyMethods.includes(method.toUpperCase())) { return universalApiHandler(basePath, config.endpoint, method, {}, params); } else { return universalApiHandler(basePath, config.endpoint, method, params); } }); }); }
  • Core handler function that processes parameters, handles path substitution, constructs the API URL, makes the HTTP request via makeRequestCsApi, and formats the MCP response. This is invoked for the get-wallet-transactions tool.
    export async function universalApiHandler<T>( basePath: string, endpoint: string, method: string = 'GET', params: Record<string, any> = {}, body?: any ): Promise<{ content: Array<{ type: 'text'; text: string; isError?: boolean }>; }> { try { // Handle path parameters - replace {paramName} in endpoint with actual values let processedEndpoint = endpoint; let processedParams = { ...params }; // Find all path parameters in the endpoint (e.g., {coinId}, {id}, {type}) const pathParamMatches = endpoint.match(/\{([^}]+)\}/g); if (pathParamMatches) { for (const match of pathParamMatches) { const paramName = match.slice(1, -1); // Remove { and } if (processedParams[paramName] !== undefined) { // Replace the placeholder with the actual value processedEndpoint = processedEndpoint.replace(match, processedParams[paramName]); // Remove the parameter from query params since it's now part of the path delete processedParams[paramName]; } else { throw new Error(`Required path parameter '${paramName}' is missing`); } } } // MCP clients might not support '~' in parameter names, so we replace '-' with '~' specifically for the /coins endpoint before making the request. if (endpoint === '/coins') { processedParams = Object.entries(processedParams).reduce((acc, [key, value]) => { acc[key.replace(/-/g, '~')] = value; return acc; }, {} as Record<string, any>); } const url = `${basePath}${processedEndpoint}`; const data = await makeRequestCsApi<T>(url, method, processedParams, body); if (!data) { return { content: [{ type: 'text', text: 'Something went wrong', isError: true }], }; } return { content: [ { type: 'text', text: JSON.stringify(data), }, ], }; } catch (error) { return { content: [{ type: 'text', text: `Error: ${error}`, isError: true }], }; } }
  • src/index.ts:17-18 (registration)
    Entry point registration that invokes registerTools with the array containing the get-wallet-transactions configuration.
    // Register all tools from configurations registerTools(server, allToolConfigs);
  • Low-level HTTP request maker used by universalApiHandler to perform the actual fetch to CoinStats API.
    export async function makeRequestCsApi<T>(url: string, method: string = 'GET', params: Record<string, any> = {}, body?: any): Promise<T | null> { const headers = { 'X-API-KEY': COINSTATS_API_KEY, 'Content-Type': 'application/json', }; try { // Build request options const options: RequestInit = { method, headers }; // Add body for non-GET requests if provided if (method !== 'GET' && body) { options.body = JSON.stringify(body); } // Add query params for all requests const queryParams = new URLSearchParams(params); const queryString = queryParams.toString(); const urlWithParams = queryString ? `${url}?${queryString}` : url; const response = await fetch(urlWithParams, options); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } return (await response.json()) as T; } catch (error) { return null; } }

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/CoinStatsHQ/coinstats-mcp'

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