retrieve_data
Retrieve cached data efficiently using a key from the Memory Cache Server, optimizing token usage during language model interactions for improved performance.
Instructions
Retrieve data from the cache
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | Key of the cached data to retrieve |
Implementation Reference
- src/index.ts:179-201 (handler)The handler function for the 'retrieve_data' tool. It extracts the 'key' from the request arguments, retrieves the cached value using this.cacheManager.get(key), and returns the JSON-stringified value if found, or an error response if not.case 'retrieve_data': { const { key } = request.params.arguments as { key: string }; const value = this.cacheManager.get(key); if (value === undefined) { return { content: [ { type: 'text', text: `No data found for key: ${key}`, }, ], isError: true, }; } return { content: [ { type: 'text', text: JSON.stringify(value, null, 2), }, ], }; }
- src/index.ts:124-133 (schema)Input schema definition for the 'retrieve_data' tool, specifying an object with a required 'key' string property.inputSchema: { type: 'object', properties: { key: { type: 'string', description: 'Key of the cached data to retrieve', }, }, required: ['key'], },
- src/index.ts:121-134 (registration)The tool registration object for 'retrieve_data' in the tools array passed to server.setTools(), including name, description, and input schema.{ name: 'retrieve_data', description: 'Retrieve data from the cache', inputSchema: { type: 'object', properties: { key: { type: 'string', description: 'Key of the cached data to retrieve', }, }, required: ['key'], }, },