rdms_download_image
Download images from the RDMS system via URL and optionally analyze them for AI processing. Specify a filename for saved images or enable analysis directly.
Instructions
Download and optionally analyze image from RDMS system
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| analyze | No | Whether to return image for AI analysis | |
| filename | No | Optional filename for saved image | |
| imageUrl | Yes | Image URL from RDMS |
Implementation Reference
- index.js:686-762 (handler)The main handler function that executes the rdms_download_image tool. Downloads the image from the provided RDMS URL using axios, converts to base64 if analyze=true (for AI vision), or saves to file if filename provided.async downloadImage(imageUrl, filename, analyze = true) { await this.ensureLoggedIn(); try { const response = await this.client.get(imageUrl, { responseType: 'arraybuffer' }); const imageBuffer = Buffer.from(response.data); const contentType = response.headers['content-type'] || 'image/png'; const imageType = contentType.split('/')[1] || 'png'; if (analyze) { // Return image data for AI analysis const base64Image = imageBuffer.toString('base64'); return { content: [ { type: 'text', text: JSON.stringify({ success: true, imageUrl, type: imageType, size: imageBuffer.length, message: `Image downloaded successfully (${Math.round(imageBuffer.length / 1024)}KB)` }) }, { type: 'image', data: base64Image, mimeType: contentType } ] }; } else { // Save to file if filename provided if (filename) { const filepath = path.resolve(filename); fs.writeFileSync(filepath, imageBuffer); return { content: [{ type: 'text', text: JSON.stringify({ success: true, imageUrl, savedTo: filepath, type: imageType, size: imageBuffer.length, message: `Image saved to ${filepath}` }) }] }; } else { return { content: [{ type: 'text', text: JSON.stringify({ success: true, imageUrl, type: imageType, size: imageBuffer.length, message: 'Image downloaded successfully' }) }] }; } } } catch (error) { return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: error.message, imageUrl }) }] }; } }
- index.js:123-135 (schema)Input schema definition for the rdms_download_image tool, specifying parameters: imageUrl (required), filename (optional), analyze (default true).{ name: 'rdms_download_image', description: 'Download and optionally analyze image from RDMS system', inputSchema: { type: 'object', properties: { imageUrl: { type: 'string', description: 'Image URL from RDMS' }, filename: { type: 'string', description: 'Optional filename for saved image' }, analyze: { type: 'boolean', description: 'Whether to return image for AI analysis', default: true } }, required: ['imageUrl'] } }
- index.js:152-153 (registration)Tool handler registration in the CallToolRequestSchema switch statement, dispatching calls to the downloadImage method.case 'rdms_download_image': return await this.downloadImage(args.imageUrl, args.filename, args.analyze);