This document provides solutions for common issues with the AutoCAD MCP implementation.
Symptoms:
- Errors like "LOAD failed" or "Function cancelled"
- Only some functions work but others do not
Solutions:
- Ensure AutoCAD is running and has a drawing open
- Make sure the command line in AutoCAD is visible and not hidden
- Check that AutoCAD is not in the middle of another command
- Verify file paths are correct (using absolute paths with forward slashes)
- Try loading files manually in AutoCAD to check for syntax errors
Symptoms:
- Window focus errors like "SetForegroundWindow timed out"
- Commands not being sent to AutoCAD
- AutoCAD window is not responding to commands
Solutions:
- Make sure AutoCAD is not minimized and is visible on screen
- Click on the AutoCAD window manually to ensure it's active before starting the server
- Try running both AutoCAD and the server as Administrator
- Close any dialog boxes or popups in AutoCAD
- Make sure no command is currently active in AutoCAD (press ESC multiple times)
- On Windows 10/11, try disabling the "Focus Assist" feature which can block window focus changes
- Try setting AutoCAD as the foreground window manually before starting the server
Symptoms:
- "Function cancelled" errors when loading LISP files
- LISP functions load but cannot be executed
Solutions:
- Check if the LISP file has dependencies that were not loaded
- Ensure the dependency order is correct (error_handling.lsp should load first)
- Try pressing ESC in AutoCAD several times to clear any pending commands
- Increase the delay times in the server script to give AutoCAD more processing time
Symptoms:
- "AutoCAD LT window not found" errors
- Commands seem to be sent but not executed
Solutions:
- Make sure AutoCAD window title contains "AutoCAD" or "Drawing"
- Verify the AutoCAD window is not minimized
- Check if any dialog boxes or popups in AutoCAD need to be closed
- Try running the server script as Administrator
To verify that the implementation is working correctly:
- Start AutoCAD and open a drawing
- Make sure the AutoCAD window is visible and active (click on it once)
- Run the MCP server using
start_lisp_server.bat
- Use the
run_test
tool to perform a basic functionality test - If the test fails, check the AutoCAD command line for specific error messages
- You can also use the
test_connection.bat
script to run a simple line creation test
If automatic loading fails, you can try loading the files manually in AutoCAD:
- In AutoCAD, type
(load "C:/Users/hvksh/mcp-servers/autocad-mcp/lisp-code/error_handling.lsp")
and press Enter - Check for any errors in the command line
- Continue with other files in the correct dependency order
- After loading all files, test a simple function like
(c:create-line 0 0 100 100)
The LISP files must be loaded in the following order due to dependencies:
- error_handling.lsp
- basic_shapes.lsp
- drafting_helpers.lsp
- block_id_helpers.lsp
- selection_and_file.lsp
- advanced_geometry.lsp
- annotation_helpers.lsp
- layout_management.lsp
If problems persist:
- Try creating a new, empty LISP file with a simple function and test loading it
- Enable more verbose logging in the server script
- Check AutoCAD's security settings - it may be blocking the execution of external LISP files
- Consider running AutoCAD as Administrator to avoid permission issues
- Try disabling any antivirus or security software that might be blocking the communication
Window focus issues are common with AutoCAD automation. Here are additional steps to debug:
- Check process isolation: Windows may prevent one application from controlling another for security reasons
- Try UI Automation API: If keyboard input fails, try alternative automation methods
- Test with simple commands: Use
(princ "TEST")
in AutoCAD to check if basic communication works - Verify keyboard input isn't blocked: Some system settings or applications can block programmatic keyboard input
- Check if AutoCAD is in modal dialog mode: If AutoCAD is waiting for input from a dialog, it won't accept commands
If all else fails:
- Try using a different version of AutoCAD
- Create a simplified version of the MCP server that only has basic functionality
- Check if other automation tools (like AutoHotkey) can successfully control AutoCAD
- Consider using AutoCAD's COM interface instead of keyboard simulation
- Restart both AutoCAD and the MCP server with all other applications closed