Skip to main content
Glama
CoinStatsHQ

CoinStats MCP Server

Official

save-share-token

Store portfolio share tokens locally to maintain access across sessions for tracking cryptocurrency investments.

Instructions

Saves the provided portfolio share token to a local cache for future use across sessions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
shareTokenYesThe portfolio share token to save locally.

Implementation Reference

  • The handler function specifically for the 'save-share-token' tool. It calls saveToCache to store the shareToken in local cache and returns a success message.
    if (config.name === 'save-share-token') {
        await saveToCache('shareToken', params.shareToken);
        return {
            content: [
                {
                    type: 'text',
                    text: 'Share token saved successfully',
                },
            ],
        };
    }
  • Tool configuration and Zod schema defining the input parameters (shareToken) for the 'save-share-token' tool, marked as a local operation.
    {
        name: 'save-share-token',
        description: 'Saves the provided portfolio share token to a local cache for future use across sessions.',
        // This tool operates locally and does not call an external API endpoint.
        // The logic to call saveToCache('shareToken', shareToken) will be handled
        // by the tool execution mechanism based on this tool's name.
        endpoint: '', // Empty string since this is a local operation
        method: 'POST', // Using POST since we're saving data
        parameters: {
            shareToken: z.string().describe('The portfolio share token to save locally.'),
        },
        isLocal: true, // Flag indicating this is a local operation that doesn't use an API
    },
  • src/index.ts:17-18 (registration)
    Registration of all tools, including 'save-share-token', by calling registerTools with the allToolConfigs array which contains its configuration.
    // Register all tools from configurations
    registerTools(server, allToolConfigs);
  • Helper function saveToCache used by the tool handler to persist the shareToken to a local JSON cache file.
    export async function saveToCache(key: string, value: any): Promise<void> {
        try {
            const cacheData = await readCache();
            cacheData[key] = value;
            await fs.writeFile(cacheFilePath, JSON.stringify(cacheData, null, 2), 'utf-8');
        } catch (error) {
            console.error(`Error saving '${key}' to cache:`, error);
            return undefined; // Return undefined on error instead of throwing
        }
    }

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