CtrEditor/Documentation/MCP/MCP_LLM_Guide.md

5.5 KiB

CtrEditor MCP Server - LLM Guide

MCP 2025-06-18 compliant | Compatible: Claude Desktop + Cursor

Command Efficiency Tiers

🚀 Ultra-Fast (Use Liberally)

  • get_simulation_status → ~25 tokens, instant
  • get_ctreditor_status → ~20 tokens, instant
  • start/stop_simulation → ~15 tokens, 2-3 sec

🟡 Medium (Use When Needed)

  • search_debug_log → 50-200 tokens (max_lines=3-10)
  • build_project → 100-500 tokens (errors only)
  • execute_python → 50-500 tokens (depends on script)
  • python_help → 100-300 tokens

🔴 Heavy (Use Sparingly)

  • list_objects → 500-2000+ tokens
  • take_screenshot → 100-300 tokens + file

🔧 Core Operations

Process Management

{"tool": "start_ctreditor", "parameters": {}}
{"tool": "get_ctreditor_status", "parameters": {}}
{"tool": "stop_ctreditor", "parameters": {}}

Build & Debug

Para los Debug se usa DebugTraceListener que es soportado por WPF

{"tool": "build_project", "parameters": {}}
{"tool": "start_debug_listener", "parameters": {}}
{"tool": "search_debug_log", "parameters": {"pattern": "error|exception", "max_lines": 5}}
{"tool": "stop_debug_listener", "parameters": {}}

Simulation Control

{"tool": "get_simulation_status", "parameters": {}}
{"tool": "start_simulation", "parameters": {}}
{"tool": "stop_simulation", "parameters": {}}

Object Management

{"tool": "list_objects", "parameters": {}}
{"tool": "create_object", "parameters": {"type": "osHydPump", "x": 10, "y": 5}}
{"tool": "update_object", "parameters": {"id": "123", "properties": {"PumpHead": 75.0}}}
{"tool": "delete_objects", "parameters": {"ids": ["123", "456"]}}

Python Debug Scripts NEW

{"tool": "execute_python", "parameters": {"code": "print(f'Total objects: {len(objects)}')"}}
{"tool": "execute_python", "parameters": {
  "code": "result = [obj for obj in objects if 'Pump' in str(type(obj))]",
  "return_variables": ["result"]
}}
{"tool": "python_help", "parameters": {"object_name": "app"}}

Optimal Workflows

Quick Development Cycle

{"tool": "get_ctreditor_status", "parameters": {}}
{"tool": "build_project", "parameters": {}}
{"tool": "start_simulation", "parameters": {}}
{"tool": "execute_python", "parameters": {"code": "print(f'Objects: {len(objects)}, Running: {app.IsSimulationRunning}')"}}
{"tool": "get_simulation_status", "parameters": {}}

Bug Investigation

{"tool": "search_debug_log", "parameters": {"pattern": "error|exception", "max_lines": 3}}
{"tool": "execute_python", "parameters": {"code": "print([type(obj).__name__ for obj in objects[:5]])"}}
{"tool": "get_simulation_status", "parameters": {}}

System Recovery

{"tool": "stop_ctreditor", "parameters": {}}
{"tool": "start_ctreditor", "parameters": {}}

📊 Key Object Properties

Python Debug Variables

  • app: MainViewModel (simulation state, canvas, objects)
  • canvas: MainCanvas (Width, Height, visual elements)
  • objects: ObservableCollection of all simulable objects
  • get_objects(): Returns List