Skip to content

MCP Tools Reference

github-actions[bot] edited this page Mar 18, 2026 · 13 revisions

MCP Tools Reference

The server exposes 21 built-in tools plus any custom tools defined in your custom_tools.yaml.

Execution & Workspace

execute_code

Execute MATLAB code in the session's engine.

Parameter Type Required Description
code string yes MATLAB code to execute

Behavior:

  • Runs synchronously if it completes within sync_timeout (default 30s)
  • Auto-promotes to async if it exceeds the timeout
  • Returns inline result for sync, or job_id for async

Example response (sync):

{
  "status": "completed",
  "output": "ans =\n    15",
  "execution_time": 0.23
}

Example response (async promotion):

{
  "status": "running",
  "job_id": "abc123-def456",
  "message": "Job promoted to async execution"
}

check_code

Lint MATLAB code using checkcode/mlint.

Parameter Type Required Description
code string yes MATLAB code to check

Example response:

{
  "issues": [
    {
      "line": 3,
      "column": 5,
      "message": "Variable 'x' might be unused",
      "severity": "warning"
    }
  ],
  "summary": "1 warning(s), 0 error(s)"
}

get_workspace

Get variables in the current MATLAB workspace.

Parameter Type Required Description
(none)

Returns the output of MATLAB's whos command, listing all variables with their sizes, classes, and memory usage.

Example response:

{
  "output": "  Name      Size            Bytes  Class     Attributes\n\n  A         3x3                72  double\n  B         1x5               120  double",
  "execution_time": 0.05
}

Job Management

get_job_status

Get status and progress of a running job.

Parameter Type Required Description
job_id string yes Job ID from execute_code

Example response:

{
  "job_id": "abc123",
  "status": "running",
  "progress": 65.0,
  "message": "Trial 650000/1000000",
  "elapsed_seconds": 120.5
}

get_job_result

Get the full result of a completed job.

Parameter Type Required Description
job_id string yes Job ID

Example response:

{
  "job_id": "abc123",
  "status": "completed",
  "output": "ans =\n    42",
  "variables": {
    "x": {"class": "double", "size": "1x1", "value": 42}
  },
  "execution_time": 2.45
}

cancel_job

Cancel a pending or running job.

Parameter Type Required Description
job_id string yes Job ID

Example response:

{
  "job_id": "abc123",
  "status": "cancelled",
  "message": "Job cancelled successfully"
}

list_jobs

List all jobs in the current session.

Parameter Type Required Description
(none)

Example response:

{
  "jobs": [
    {
      "job_id": "abc123",
      "status": "completed",
      "created_at": "2024-01-15T10:30:00Z",
      "completed_at": "2024-01-15T10:30:02Z",
      "execution_time": 2.45
    },
    {
      "job_id": "def456",
      "status": "running",
      "created_at": "2024-01-15T10:31:00Z",
      "progress": 42.5
    }
  ]
}

Discovery

list_toolboxes

List available MATLAB toolboxes (filtered by configuration).

Parameter Type Required Description
(none)

Example response:

{
  "toolboxes": [
    {
      "name": "MATLAB",
      "version": "R2023b"
    },
    {
      "name": "Signal Processing Toolbox",
      "version": "9.2"
    },
    {
      "name": "Statistics and Machine Learning Toolbox",
      "version": "12.4"
    }
  ],
  "output": "MATLAB Version 9.14.0.2206818 (R2023b) Update 3..."
}

list_functions

List functions in a specific toolbox.

Parameter Type Required Description
toolbox_name string yes Name of the toolbox

Example response:

{
  "toolbox_name": "Signal Processing Toolbox",
  "output": "Signal Processing Toolbox\n\nFiltering\n  butter           - Butterworth filter design\n  cheby1           - Chebyshev Type I filter design\n  fir1             - Window-based FIR filter design\n..."
}

get_help

Get MATLAB help text for any function.

Parameter Type Required Description
function_name string yes Name of the function

Example response:

{
  "function_name": "fft",
  "output": " FFT   Fast Fourier transform.\n    FFT(X) is the discrete Fourier transform of vector X.\n    FFT(X,N) pads (or truncates) X to length N before transforming.\n    FFT(X,[],DIM) or FFT(X,N,DIM) applies the FFT operation across\n    the dimension DIM of X.\n    For length N input vector x, FFT computes DFT as\n    Y(k) = sum_{j=1}^{N} x(j)*exp(-2*pi*i*(j-1)*(k-1)/N), 1 <= k <= N.\n    (MATLAB uses the convention that both sequences are indexed\n    starting from 1 rather than 0.)\n    See also IFFT, FFT2, FFTN, FFTSHIFT."
}

File Operations

upload_data

Upload a data file to the session's temporary directory.

Parameter Type Required Description
filename string yes Name of the file to create
content_base64 string yes Base64-encoded file content

Example response:

{
  "filename": "data.csv",
  "path": "/tmp/session_abc123/data.csv",
  "size_bytes": 1024,
  "message": "File uploaded successfully"
}

delete_file

Delete a file from the session's temporary directory.

Parameter Type Required Description
filename string yes Name of the file to delete

Example response:

{
  "filename": "data.csv",
  "message": "File deleted successfully"
}

list_files

List files in the session's temporary directory.

Parameter Type Required Description
(none)

Example response:

{
  "files": [
    {
      "filename": "data.csv",
      "path": "/tmp/session_abc123/data.csv",
      "size_bytes": 2048
    },
    {
      "filename": "results.mat",
      "path": "/tmp/session_abc123/results.mat",
      "size_bytes": 5120
    },
    {
      "filename": "plot.png",
      "path": "/tmp/session_abc123/plot.png",
      "size_bytes": 15360
    }
  ]
}

read_script

Read a MATLAB .m script file from the session's temporary directory.

Parameter Type Required Description
filename string yes Name of the .m file to read

Example response:

{
  "filename": "analysis.m",
  "content": "% Data analysis script\ndata = load('data.mat');\nx = data.x;\ny = data.y;\n\n% Compute statistics\nmean_x = mean(x);\nstd_x = std(x);\n\ndisp(['Mean: ' num2str(mean_x)]);\ndisp(['Std Dev: ' num2str(std_x)]);"
}

read_data

Read a data file (.mat, .csv, .json, .txt, .xlsx) from the session temp directory.

Parameter Type Required Description
filename string yes Name of the data file to read
format string no Format mode: summary (default for .mat), raw (base64)

Example response (summary mode for .mat):

{
  "filename": "results.mat",
  "format": "summary",
  "variables": [
    {
      "name": "x",
      "size": "1000x1",
      "class": "double",
      "bytes": 8000
    },
    {
      "name": "y",
      "size": "1000x1",
      "class": "double",
      "bytes": 8000
    }
  ]
}

Example response (text file):

{
  "filename": "data.csv",
  "content": "x,y,z\n1,2,3\n4,5,6\n7,8,9"
}

read_image

Read an image file (.png, .jpg, .gif) from the session temp directory.

Parameter Type Required Description
filename string yes Name of the image file to read

Returns: An inline content block that renders the image in agent UIs.

Admin

get_pool_status

Get the current status of the MATLAB engine pool.

Parameter Type Required Description
(none)

Example response:

{
  "pool_size": 4,
  "total_engines": 4,
  "available_engines": 2,
  "busy_engines": 2,
  "max_engines": 10,
  "pool_healthy": true
}

Monitoring

get_server_metrics

Get comprehensive server metrics including pool, jobs, sessions, and system stats.

Parameter Type Required Description
(none)

Example response:

{
  "pool": {
    "total_engines": 4,
    "available_engines": 2,
    "busy_engines": 2,
    "max_engines": 10
  },
  "jobs": {
    "total": 150,
    "running": 3,
    "completed": 145,
    "failed": 2,
    "cancelled": 0
  },
  "sessions": {
    "active": 5,
    "total": 25
  },
  "system": {
    "uptime_seconds": 3600,
    "memory_usage_percent": 45.2,
    "cpu_usage_percent": 12.5
  },
  "timestamp": "2024-01-15T10:45:30Z"
}

get_server_health

Get server health status with issue detection.

Parameter Type Required Description
(none)

Example response:

{
  "status": "healthy",
  "overall_health": "healthy",
  "pool_health": "healthy",
  "job_health": "healthy",
  "session_health": "healthy",
  "issues": [],
  "warnings": [],
  "timestamp": "2024-01-15T10:45:30Z"
}

Possible status values: healthy, degraded, unhealthy

get_error_log

Get recent server errors and notable events for diagnosing issues.

Parameter Type Required Description
limit integer no Maximum number of log entries to return (default: 20)

Example response:

{
  "errors": [
    {
      "timestamp": "2024-01-15T10:30:15Z",
      "level": "error",
      "message": "Engine timeout during job abc123",
      "job_id": "abc123"
    },
    {
      "timestamp": "2024-01-15T10:15:00Z",
      "level": "warning",
      "message": "Pool utilization high: 8/10 engines busy",
      "component": "pool"
    },
    {
      "timestamp": "2024-01-15T09:45:30Z",
      "level": "info",
      "message": "Session xyz789 closed",
      "session_id": "xyz789"
    }
  ],
  "total_errors": 12,
  "total_warnings": 45
}

Custom Tools

Custom tools can be registered by defining them in your custom_tools.yaml configuration file. Custom tools are dynamically loaded at server startup and integrated into the MCP tools registry alongside the built-in tools. See the server configuration documentation for details on the YAML schema and tool implementation requirements.

Clone this wiki locally