Skip to main content
Glama
CoinStatsHQ

CoinStats MCP Server

Official

get-fiat-currencies

Retrieve a list of fiat currencies supported by CoinStats for cryptocurrency market data and portfolio tracking.

Instructions

Get a list of fiat currencies supported by CoinStats.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Generic tool handler registered for each tool config, including get-fiat-currencies. Dispatches to universalApiHandler for API calls.
    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);
        }
    });
  • Schema and configuration for the get-fiat-currencies tool, defining parameters (none), description, endpoint, and method.
    {
        name: 'get-fiat-currencies',
        description: 'Get a list of fiat currencies supported by CoinStats.',
        endpoint: '/fiats',
        method: 'GET',
        parameters: {},
    },
  • src/index.ts:17-18 (registration)
    Registers the get-fiat-currencies tool (along with others) by calling registerTools with the MCP server.
    // Register all tools from configurations
    registerTools(server, allToolConfigs);
  • Helper function that handles HTTP requests to the CoinStats API, processes path and query parameters, and formats response for MCP.
    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 }],
            };
        }
    }
  • Low-level HTTP request maker using fetch with CoinStats API key, handles query params and body.
    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;
        }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden for behavioral disclosure. It only states what the tool does ('Get a list'), without mentioning any traits like rate limits, authentication needs, response format, or potential errors. This leaves significant gaps in understanding how the tool behaves in practice.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without any unnecessary words. It is appropriately sized and front-loaded, with every part earning its place by clearly conveying the essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (0 parameters, no output schema), the description is minimally complete for a simple read operation. However, without annotations or output schema, it lacks details on response format or behavioral constraints, which could be helpful for an agent. It meets basic needs but leaves room for improvement in context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters, and schema description coverage is 100%, so no parameter information is needed. The description does not add param semantics beyond the schema, but with no parameters, this is acceptable. Baseline score for 0 params is 4, as the description need not compensate for any gaps.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Get') and resource ('list of fiat currencies supported by CoinStats'), making the purpose specific and unambiguous. It distinguishes from siblings like 'get-currencies' by specifying 'fiat' currencies, which is a meaningful differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for retrieving supported fiat currencies, but does not explicitly state when to use this tool versus alternatives like 'get-currencies' or other data-fetching tools. No exclusions or prerequisites are mentioned, leaving usage context somewhat implied rather than clearly defined.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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