-
Notifications
You must be signed in to change notification settings - Fork 0
Troubleshooting
Symptom: ImportError: No module named 'matlab.engine' or Engine start timeout
Likely Cause: MATLAB Engine for Python is not installed or not on Python's path.
Solution:
-
Verify MATLAB Engine API is installed:
python -c "import matlab.engine; print('OK')" -
Install the Engine API from MATLAB installation directory:
-
macOS:
cd /Applications/MATLAB_R2024a.app/extern/engines/python pip install .
-
Windows:
cd "C:\Program Files\MATLAB\R2024a\extern\engines\python" pip install .
-
macOS:
-
Verify MATLAB version is 2020b or later:
matlab -version
-
If MATLAB is not on PATH, set
matlab_rootin config:pool: matlab_root: "/Applications/MATLAB_R2024a.app"
Symptom: python: command not found or version error during installation
Likely Cause: Project requires Python 3.10–3.12; you may have Python 2.7 or 3.9.
Solution:
-
Check Python version:
python3 --version
-
Create virtual environment with correct version:
python3.10 -m venv venv source venv/bin/activate # macOS/Linux # or: venv\Scripts\activate # Windows
-
Reinstall the package:
pip install matlab-mcp-python
Symptom: Could not find wheel ... or No matching distribution found
Likely Cause: Bundled vendor wheels don't match your platform (e.g., Windows ARM64 vs x64).
Solution:
-
Check your platform:
import platform print(platform.platform())
-
Regenerate vendor wheels for your platform:
.\update_vendor.bat # Windows # or: sh update_vendor.sh # macOS/Linux (if available)
-
Reinstall from updated vendor directory:
pip install --no-index --find-links ./vendor matlab-mcp-python
Symptom: Pool shows 0/0 available engines or jobs queue indefinitely
Likely Cause: Engine startup timeout too short, or MATLAB is slow to start.
Solution:
-
Increase engine startup timeout:
pool: engine_start_timeout: 300 # 5 minutes (default 60s)
-
Check pool status:
# In agent, call get_pool_status tool # or check /health endpoint if monitoring enabled
-
Check logs:
server: log_level: "debug" log_file: "./logs/server.log"
-
On macOS, reduce
max_engines(MATLAB limit ~4 concurrent):pool: max_engines: 4
Symptom: Job never completes, progress stops updating, or times out
Likely Cause: Code has infinite loop, is blocked on I/O, or execution time exceeds hard limit.
Solution:
-
Cancel the job immediately:
Agent: call cancel_job with the stuck job_id -
Check execution timeout:
execution: sync_timeout: 30 # Promote to async after 30s max_execution_time: 86400 # Hard limit 24h
If your job legitimately takes >24h, increase
max_execution_time. -
Add progress reporting to your MATLAB code to debug:
for i = 1:1000000 mcp_progress(__mcp_job_id__, 100*i/1000000, sprintf('Iteration %d', i)); % ... computation ... end
-
Check MATLAB code for infinite loops or deadlocks:
- Remove
pause()commands - Add timeout guards to waiting loops
- Remove
Symptom: BlockedFunctionError: Function 'system' is blocked or 'eval' is blocked
Likely Cause: Security validator is preventing dangerous function calls.
Solution:
-
Use MATLAB-native alternatives (recommended):
- Instead of
system(): usedir,mkdir,copyfile,movefile - Instead of
eval(): usefeval(), function handles, orstr2func() - Instead of
!cmd: usesystem()alternatives above
- Instead of
-
Disable specific blocklist entries (if necessary):
security: blocked_functions_enabled: true blocked_functions: - "unix" - "dos" # - "system" # Remove to allow system() - "!" - "eval"
-
Disable all blocking (not recommended for shared servers):
security: blocked_functions_enabled: false
Symptom: Custom tools don't appear in agent, or custom_tools.yaml not found error
Likely Cause: Config points to wrong path, or YAML syntax error.
Solution:
-
Check YAML syntax:
python -c "import yaml; yaml.safe_load(open('custom_tools.yaml'))" -
Verify config path is absolute or relative to config file:
server: custom_tools_file: "/absolute/path/to/custom_tools.yaml" # or relative to current working directory: # custom_tools_file: "./custom_tools.yaml"
-
Check file permissions:
ls -la custom_tools.yaml # Should be readable -
Enable debug logging to see load errors:
server: log_level: "debug"
Symptom: Environment variable override has no effect
Likely Cause: Variable name format incorrect, or config reloading issue.
Solution:
-
Check format: Variables must be
MATLAB_MCP_<SECTION>_<KEY>in UPPERCASE:export MATLAB_MCP_POOL_MIN_ENGINES=2 export MATLAB_MCP_POOL_MAX_ENGINES=8 export MATLAB_MCP_SERVER_LOG_LEVEL=debug
-
Verify format:
# Nested keys use underscore: MATLAB_MCP_EXECUTION_SYNC_TIMEOUT=60 # Not: MATLAB_MCP_EXECUTION.SYNC_TIMEOUT
-
Reload server after setting environment variables:
matlab-mcp --config config.yaml
Symptom: Connection refused or ERR_CONNECTION_TIMED_OUT when connecting to SSE endpoint
Likely Cause: Server not running, wrong host/port, or firewall blocking.
Solution:
-
Verify server is running:
ps aux | grep matlab-mcp # or: curl http://localhost:8765/health
-
Check configured host/port:
server: transport: "sse" host: "0.0.0.0" # Listen on all interfaces port: 8765 # Default port
-
Test connectivity:
curl http://127.0.0.1:8765/health # Expected: {"status": "healthy"} -
Check firewall:
- macOS: System Preferences → Security & Privacy → Firewall
- Windows: Windows Defender Firewall → Allow an app
- Linux:
sudo ufw allow 8765
Symptom: 401 Unauthorized when behind reverse proxy
Likely Cause: Proxy auth not configured.
Solution:
-
Disable proxy auth requirement (if auth handled by reverse proxy):
security: require_proxy_auth: false
-
Or add proxy headers from your reverse proxy:
X-Forwarded-For: <client-ip> X-Forwarded-Proto: https -
Check agent SSE client is sending auth headers (e.g., Bearer token in Authorization).
Symptom: Plot returned as static PNG only, no interactive Plotly JSON
Likely Cause: Figure type not supported by converter, or Plotly conversion disabled.
Solution:
-
Check supported plot types:
- ✅ Line plots, scatter, bar, histogram
- ✅ 3D surface, image
- ❌ Complex custom graphics, annotations with arrows/text boxes
-
Enable Plotly conversion in config:
output: plotly_conversion: true
-
Simplify the plot to use basic MATLAB commands:
plot(x, y, 'b-'); % Works % vs. plot(x, y); set(gca, 'XScale', 'log'); % May not convert
-
Check debug logs for conversion errors:
server: log_level: "debug"
Symptom: Output shows [Output truncated, saved to file: /path/to/result.txt]
Likely Cause: Result exceeds inline text limit.
Solution:
-
Increase inline limits:
output: max_inline_text_length: 100000 # default: 50000 chars large_result_threshold: 50000 # default: 10000 elements
-
Use file reading tools to access saved results:
Agent: call list_files to see output files Agent: call read_data("result.txt") to fetch full content -
Reduce output size in your MATLAB code:
- Use
summary()instead ofdisp(huge_array) - Use
head()/tail()for large tables - Save results to
.matfile instead of printing
- Use
Symptom: [Thumbnail generation failed] or image not rendering
Likely Cause: Pillow not installed, or unsupported image format.
Solution:
-
Install Pillow:
pip install Pillow
-
Check image format is PNG, JPEG, or GIF:
saveas(gcf, 'plot.png'); % Use PNG
-
Check image size is reasonable:
set(gcf, 'Position', [0 0 800 600]); % Set before saveas
Symptom: Upload failed: File exceeds maximum size or Invalid filename
Likely Cause: File too large, or forbidden characters in filename.
Solution:
-
Check upload size limit:
security: max_upload_size_mb: 100 # default
Increase if needed:
security: max_upload_size_mb: 500
-
Validate filename:
- ✅ Allowed:
data.csv,signal_2024.mat,my-image.png - ❌ Blocked:
../../../etc/passwd,file;rm -rf,con.txt(Windows reserved)
- ✅ Allowed:
-
Use Base64 encoding in upload tool:
Agent: call upload_data with content_base64 (use base64 encoding)
Solution:
-
Set log level in config:
server: log_level: "debug" # verbose output log_file: "./logs/server.log"
-
Or via environment variable:
export MATLAB_MCP_SERVER_LOG_LEVEL=debug matlab-mcp --config config.yaml -
Check log file:
tail -f ./logs/server.log
-
Log levels:
debug,info,warning,error,critical
For bug reports, gather:
-
Server version:
pip show matlab-mcp-python
-
Config (sanitized):
cat config.yaml | grep -v password -
MATLAB version:
matlab -version
-
Python version:
python --version
-
System info:
python -c "import platform; print(platform.platform())" -
Relevant log lines (last 100):
tail -100 ./logs/server.log > diagnostic.log -
Job details (from tracker):
Agent: call list_jobs Agent: call get_job_status(job_id) -
Pool status:
Agent: call get_pool_status Agent: call get_server_health (if monitoring enabled)
-
Via monitoring dashboard (if enabled):
http://localhost:8766/dashboard -
Via health check endpoint:
curl http://localhost:8765/health # Expected: {"status": "healthy"} -
Via metrics tool (in agent):
Agent: call get_server_metrics Agent: call get_server_health -
Check metrics database:
sqlite3 monitoring/metrics.db "SELECT * FROM events ORDER BY timestamp DESC LIMIT 20;"
graph TD
A["Issue Encountered"] --> B{Check Type}
B -->|Can't Start| C["→ Installation Issues section"]
B -->|Runs Slow/Hangs| D["→ Runtime Issues section"]
B -->|Wrong Output| E["→ Output & Conversion section"]
B -->|Connection Error| F["→ Networking Issues section"]
B -->|Security Block| G["→ Security section"]
C --> H["Enable debug logging"]
D --> H
E --> H
F --> H
G --> H
H --> I["Collect diagnostics"]
I --> J["Check GitHub Issues"]
J --> K{Found Match?}
K -->|Yes| L["Review solution"]
K -->|No| M["Open new issue with diagnostics"]
L --> N["Resolved ✓"]
M --> O["Community Response"]
O --> N
- GitHub Issues: https://github.com/your-org/matlab-mcp-server/issues
- Discussions: https://github.com/your-org/matlab-mcp-server/discussions
- Wiki: https://github.com/your-org/matlab-mcp-server/wiki
- README: https://github.com/your-org/matlab-mcp-server
- MATLAB Documentation: https://www.mathworks.com/help/matlab/
- MCP Protocol: https://modelcontextprotocol.io/
-
Report a bug: Open a GitHub Issue with
[BUG]prefix and diagnostics -
Request a feature: Open a GitHub Issue with
[FEATURE]prefix - Ask a question: Start a GitHub Discussion or check FAQ
- Contribute: See CONTRIBUTING.md for development guidelines
| Error | Likely Cause | Fix |
|---|---|---|
Engine start timeout |
MATLAB slow, or not found | Increase engine_start_timeout, verify MATLAB path |
BlockedFunctionError: system |
Security policy | Use alternatives or adjust blocklist |
Job exceeded max execution time |
Code too slow, infinite loop | Cancel job, optimize code, increase timeout |
File exceeds maximum size |
Upload limit | Use max_upload_size_mb config, split files |
Connection refused: 8765 |
Server not running | Start with matlab-mcp --transport sse
|
Plotly conversion failed |
Unsupported plot type | Check supported types, simplify plot |
[Output truncated] |
Result too large | Increase limits or read from file |
Invalid MATLAB_MCP_* variable |
Wrong environment variable name | Use SECTION_KEY uppercase format |