analyze_color
Identify fountain pen inks matching a specific color by analyzing hex codes and returning relevant ink knowledge with similarity results.
Instructions
Analyze a color and provide ink knowledge context
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| color | Yes | Hex color code (e.g., "#FF5733") | |
| max_results | No | Maximum number of closest inks to return (default: 5) |
Implementation Reference
- src/index.ts:481-510 (handler)The main handler function that implements the analyze_color tool logic: parses hex color to RGB, finds closest matching inks, determines color family and description using utilities, and returns a structured JSON analysis response.private analyzeColor(colorHex: string, maxResults: number = 5): MCPTextResponse { try { const rgb = hexToRgb(colorHex); const closestInks = findClosestInks(rgb, this.inkColors, maxResults); const results: SearchResult[] = closestInks.map((ink) => { const metadata = this.getInkMetadata(ink.ink_id); return createSearchResult(ink, metadata, ink.distance); }); const analysis: ColorAnalysis = { hex: colorHex, rgb, closest_inks: results, color_family: getColorFamily(rgb), // No conversion needed description: getColorDescription(rgb), // No conversion needed }; return { content: [ { type: 'text', text: JSON.stringify(analysis, null, 2), }, ], } satisfies MCPTextResponse; } catch { throw new Error(`Invalid color format: ${colorHex}. Please use hex format like #FF5733`); } }
- src/index.ts:211-229 (registration)Registration of the analyze_color tool in the ListTools handler, including name, description, and input schema definition.{ name: 'analyze_color', description: 'Analyze a color and provide ink knowledge context', inputSchema: { type: 'object', properties: { color: { type: 'string', description: 'Hex color code (e.g., "#FF5733")', }, max_results: { type: 'number', description: 'Maximum number of closest inks to return (default: 5)', default: 5, }, }, required: ['color'], }, },
- src/index.ts:292-293 (registration)Dispatch/registration of the analyze_color tool in the CallToolRequest switch statement, mapping arguments to the handler method.case 'analyze_color': return this.analyzeColor(args.color as string, (args.max_results as number) || 5);
- src/index.ts:214-228 (schema)Input schema definition for the analyze_color tool, specifying parameters for color (required hex string) and optional max_results.inputSchema: { type: 'object', properties: { color: { type: 'string', description: 'Hex color code (e.g., "#FF5733")', }, max_results: { type: 'number', description: 'Maximum number of closest inks to return (default: 5)', default: 5, }, }, required: ['color'], },