retrieve
Retrieve and decompress previously stored compressed data by key. Recovers original data after compression and storage, ensuring lossless access.
Instructions
Retrieve and decompress previously stored data by key.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | The key used when storing the data |
Implementation Reference
- index.js:463-487 (handler)The handleRetrieve function reads a compressed file and its metadata from disk, decompresses the data using the stored algorithm, and returns the original data along with metadata.
handleRetrieve(args) { const { key } = args; if (!key) return { error: 'Missing "key" parameter' }; const dataPath = join(STORE_DIR, `${key}.bin`); const metaPath = join(STORE_DIR, `${key}.json`); if (!existsSync(dataPath) || !existsSync(metaPath)) { return { error: `Key "${key}" not found` }; } const metadata = JSON.parse(readFileSync(metaPath, 'utf-8')); const compressed = readFileSync(dataPath); const original = this.decompressData(compressed.toString('base64'), metadata.algorithm); this.stats.operations++; return { key, data: original, original_size: metadata.originalSize, compressed_size: metadata.compressedSize, algorithm: metadata.algorithm, stored_at: metadata.storedAt }; } - index.js:606-615 (schema)The tool definition and input schema for 'retrieve' in getToolDefinitions(). It declares the tool name, description, and inputSchema requiring a 'key' (string).
{ name: 'retrieve', description: 'Retrieve and decompress previously stored data by key.', inputSchema: { type: 'object', properties: { key: { type: 'string', description: 'The key used when storing the data' } }, required: ['key'] } - index.js:687-687 (registration)The 'tools/call' handler dispatches the 'retrieve' tool name to the handleRetrieve method.
case 'retrieve': result = this.handleRetrieve(args); break;