visualreasoning
Create, manipulate, and interpret diagrams, graphs, and visual representations to facilitate insight generation, hypothesis testing, and problem-solving. Supports various visual elements and operations for structured reasoning and decision-making.
Instructions
A tool for visual thinking, problem-solving, and communication. This tool enables models to create, manipulate, and interpret diagrams, graphs, and other visual representations. It supports various visual elements and operations to facilitate insight generation and hypothesis testing.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| diagramId | Yes | ||
| diagramType | Yes | ||
| elements | No | ||
| hypothesis | No | ||
| insight | No | ||
| iteration | Yes | ||
| nextOperationNeeded | Yes | ||
| observation | No | ||
| operation | Yes | ||
| transformationType | No |
Implementation Reference
- The primary handler function that executes the visualreasoning tool logic: validates input as VisualOperationData, formats a detailed chalk-colored console output, logs it, and returns a structured text content block with JSON-serialized results or error.public processVisualReasoning(input: unknown): { content: Array<{ type: string; text: string }>; isError?: boolean } { try { const validatedData = this.validateInputData(input); const processedData: VisualOperationData = { ...validatedData, elements: validatedData.elements || [] }; const formattedOutput = this.formatOutput(processedData); console.error(formattedOutput); return { content: [{ type: "text", text: JSON.stringify({ operation: processedData.operation, diagramId: processedData.diagramId, diagramType: processedData.diagramType, iteration: processedData.iteration, nextOperationNeeded: processedData.nextOperationNeeded, elementCount: processedData.elements ? processedData.elements.length : 0, status: 'success' }, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: JSON.stringify({ error: error instanceof Error ? error.message : String(error), status: 'failed' }, null, 2) }], isError: true }; } }
- src/index.ts:911-975 (schema)Defines the complete Tool metadata and inputSchema for the 'visualreasoning' tool, specifying required fields like operation, diagramId, diagramType, iteration, nextOperationNeeded, and optional elements, observations, etc.const VISUAL_REASONING_TOOL: Tool = { name: "visualreasoning", description: `A tool for visual thinking, problem-solving, and communication. This tool enables models to create, manipulate, and interpret diagrams, graphs, and other visual representations. It supports various visual elements and operations to facilitate insight generation and hypothesis testing.`, inputSchema: { type: "object", properties: { operation: { type: "string", enum: ["create", "update", "delete", "transform", "observe"], }, elements: { type: "array", items: { type: "object", properties: { id: { type: "string" }, type: { type: "string", enum: ["node", "edge", "container", "annotation"], }, label: { type: "string" }, properties: { type: "object", additionalProperties: true, }, source: { type: "string" }, target: { type: "string" }, contains: { type: "array", items: { type: "string" } }, }, required: ["id", "type", "properties"], }, }, transformationType: { type: "string", enum: ["rotate", "move", "resize", "recolor", "regroup"], }, diagramId: { type: "string" }, diagramType: { type: "string", enum: [ "graph", "flowchart", "stateDiagram", "conceptMap", "treeDiagram", "custom", ], }, iteration: { type: "number", minimum: 0 }, observation: { type: "string" }, insight: { type: "string" }, hypothesis: { type: "string" }, nextOperationNeeded: { type: "boolean" }, }, required: [ "operation", "diagramId", "diagramType", "iteration", "nextOperationNeeded", ], }, };
- src/index.ts:989-1012 (registration)Registers the 'visualreasoning' tool in the MCP server's capabilities.tools object during server initialization.const server = new Server( { name: "clear-thought-mcp-server", version: "1.1.2", }, { capabilities: { tools: { sequentialthinking: SEQUENTIAL_THINKING_TOOL, mentalmodel: MENTAL_MODEL_TOOL, designpattern: DESIGN_PATTERN_TOOL, programmingparadigm: PROGRAMMING_PARADIGM_TOOL, debuggingapproach: DEBUGGING_APPROACH_TOOL, collaborativereasoning: COLLABORATIVE_REASONING_TOOL, decisionframework: DECISION_FRAMEWORK_TOOL, metacognitivemonitoring: METACOGNITIVE_MONITORING_TOOL, scientificmethod: SCIENTIFIC_METHOD_TOOL, structuredargumentation: STRUCTURED_ARGUMENTATION_TOOL, visualreasoning: VISUAL_REASONING_TOOL, }, }, } );
- src/index.ts:1164-1176 (registration)Registers the runtime dispatch handler for 'visualreasoning' tool calls in the CallToolRequestSchema handler's switch statement.case "visualreasoning": { const result = visualReasoningServer.processVisualReasoning( request.params.arguments ); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; }
- Helper method to validate the input against VisualOperationData structure, checking required fields and types.private validateInputData(input: unknown): VisualOperationData { const data = input as VisualOperationData; if (!data.operation || !data.diagramId || !data.diagramType) { throw new Error("Invalid input for VisualReasoning: Missing required fields."); } if (typeof data.iteration !== 'number' || data.iteration < 0) { throw new Error("Invalid iteration value for VisualOperationData."); } if (typeof data.nextOperationNeeded !== 'boolean') { throw new Error("Invalid nextOperationNeeded value for VisualOperationData."); } return data; }