save-share-token
Store portfolio share tokens locally to maintain access across sessions for consistent cryptocurrency portfolio tracking and management.
Instructions
Saves the provided portfolio share token to a local cache for future use across sessions.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| shareToken | Yes | The portfolio share token to save locally. |
Input Schema (JSON Schema)
{
"properties": {
"shareToken": {
"description": "The portfolio share token to save locally.",
"type": "string"
}
},
"required": [
"shareToken"
],
"type": "object"
}
Implementation Reference
- src/tools/toolFactory.ts:25-35 (handler)The handler function that executes the 'save-share-token' tool: saves the provided shareToken to local cache using saveToCache 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', }, ], }; }
- src/tools/toolConfigs.ts:436-447 (schema)The tool configuration object defining the schema (parameters), description, and flags like isLocal for the 'save-share-token' tool.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/tools/toolFactory.ts:20-21 (registration)The registration loop where server.tool is called for each config, including 'save-share-token', registering the tool with MCP server.toolConfigs.forEach((config) => { server.tool(config.name, config.description, config.parameters, async (params: Record<string, any>) => {
- src/utils/cache.ts:38-47 (helper)The saveToCache helper function used by the handler to persist the share token 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 } }
- src/index.ts:18-18 (registration)The call to registerTools with allToolConfigs (imported from toolConfigs.ts), which includes the 'save-share-token' config, thus registering the tool.registerTools(server, allToolConfigs);