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
| Name | Required | Description | Default |
|---|---|---|---|
| shareToken | Yes | The portfolio share token to save locally. |
Implementation Reference
- src/tools/toolFactory.ts:25-35 (handler)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', }, ], }; }
- src/tools/toolConfigs.ts:435-447 (schema)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);
- src/utils/cache.ts:38-47 (helper)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 } }