visualreasoning
Create and manipulate diagrams to solve problems, generate insights, and test hypotheses through visual thinking and structured reasoning.
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 |
|---|---|---|---|
| operation | Yes | ||
| elements | No | ||
| transformationType | No | ||
| diagramId | Yes | ||
| diagramType | Yes | ||
| iteration | Yes | ||
| observation | No | ||
| insight | No | ||
| hypothesis | No | ||
| nextOperationNeeded | Yes |
Implementation Reference
- Main handler function that validates input, processes visual reasoning data, formats and logs output, and returns structured JSON content 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)Tool definition including name, description, and detailed inputSchema for validating visualreasoning tool inputs.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:990-1012 (registration)Registers the visualreasoning tool (line 1008) in the MCP server capabilities alongside other tools.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)Dispatch handler in CallToolRequestSchema switch that routes visualreasoning calls to the VisualReasoningServer.processVisualReasoning method.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 data against VisualOperationData requirements.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; }