🤖 Robotics Tool of the Week: MATLAB Agentic Toolkit

What if your AI coding agent could actually work with MATLAB—not just write MATLAB code for you?

This week’s tool is the MATLAB Agentic Toolkit, an open-source toolkit from MathWorks that connects AI coding agents to MATLAB through the Model Context Protocol (MCP).

Instead of asking an AI assistant to generate MATLAB code and then manually copying and pasting it into MATLAB, the agent can interact with a live MATLAB environment.

What can it do?

The MATLAB Agentic Toolkit combines two important capabilities:

1. Connect AI agents to MATLAB

Through the MATLAB MCP Server, an AI agent can:

  • Run MATLAB code

  • Execute MATLAB files

  • Run MATLAB tests

  • Check MATLAB code using Code Analyzer

  • Detect installed MATLAB toolboxes

This means an agent can follow an iterative workflow:

Write → Run → Inspect → Debug → Test → Improve

rather than simply generating code and leaving the execution to you.

2. Give the agent MATLAB-specific expertise

The toolkit also provides curated agent skills containing MATLAB workflows, conventions, and engineering practices.

These skills cover areas such as data analysis, app development, testing, debugging, code modernization, and many specialized engineering domains. MathWorks currently lists 100+ specialized skills.

Why is this interesting for robotics?

Robotics development often requires moving between:

MATLAB → simulation → analysis → controller design → testing → visualization

An AI agent that can interact directly with MATLAB can potentially help automate much of this loop.

For example, you could ask an agent:

❝

“Create a trajectory for a 6-DOF robotic manipulator, plot the joint positions and velocities, check the results, and modify the trajectory if the velocity limits are exceeded.”

Instead of merely generating MATLAB code, the agent can execute the code and inspect the results through the MATLAB connection. This makes the idea particularly interesting for robotics research, control systems, computer vision, optimization, and data analysis.

How it works?

The basic architecture is:

AI Coding Agent → MCP → MATLAB MCP Server → MATLAB

The toolkit supports AI coding agents including OpenAI Codex, Claude Code, GitHub Copilot, Gemini CLI, and Amp.

The MATLAB MCP Server provides the bridge between the agent and MATLAB.

🚀 Getting started

The MATLAB Agentic Toolkit requires MATLAB R2021a or later and an AI coding agent that supports MCP and skills.

Install Command Line Interface (CLI)

Before installing Agentic Tookit, install command line interface (CLI) for the agent of your choice. For this task, I installed Codex CLI for Windows. Make sure to have an account for Open AI as it requires you to login first at the first use.

Install Agentic Toolkit in MATLAB

  1. First download the Agentic Toolkit Installer.

  2. Open the downloaded mltbx file from MATALAB to install the add-on

  3. On MATLAB terminal, start basic installation using

setupAgenticToolkit("install")
  1. During the installation, MATLAB requires your permission to setup MCP server. Please follow the steps to install Codex MCP server. If unintentionally you cancel it, you can configure using

setupAgenticToolkit("configure")
  1. During the configuration, it also asks to install support for MATLAB or Simulink or both. You can also mention to install support for some selected toolboxes or for all.

  2. After configuring, next step is to form a connection between MATLAB and Codex through MCP. If you want the agent to connect to an already-running MATLAB session, you can directly run this command:

shareMATLABSession()
  1. It is advisable to create a new directory where you wish to build a new project. Open the same directory in MATLAB and Windows Power Shell or Command Prompt by changing the directory using cd command. Once you are inside the directory, initialize Codex by typing codex in Power Shell or Command Prompt. On the successful initialization, you should receive such output

  1. To verify that configuration is done properly and a connection has been established between MATLAB and Codex, you can ask

    ❝

    What version of MATLAB is running? List the installed toolboxes.

  2. In case, it is unable to retrieve the required information, it means that the connection is not properly established. In MATLAB, you can run this on terminal to check the status of the connection as established (1) or not established (0).

matlab.engine.isEngineShared
  1. You can forcefully share the engine in case it is not shared using

matlab.engine.shareEngine
  1. Share MATLAB session again and restart the CLI and ask the same question as in 8. If everything is in order, the MATLAB version and list of toolboxes will be retrieved.

This concludes the setup and configuration.

💡 A robotics experiment to try

Ask the AI agent to

❝

“Create a MATLAB simulation of a 2-DOF planar robotic arm. Derive its forward kinematics, generate a circular end-effector trajectory, calculate the required joint angles, plot the resulting motion, and test the code.”

It will generate a MATLAB .m file in the working directory and also show the output.

%% 2-DOF Planar Manipulator Simulation
% Two revolute joints move in the XY plane. Run this script to animate the arm.
% Requires Robotics System Toolbox for rigidBodyTree and show.

clear; clc; close all;

% Link lengths (m)
L1 = 0.50;
L2 = 0.40;

% Build a 2R serial manipulator using standard DH parameters
robot = rigidBodyTree("DataFormat", "row", "MaxNumBodies", 2);
body1 = rigidBody("link1");
joint1 = rigidBodyJoint("joint1", "revolute");
setFixedTransform(joint1, [L1 0 0 0], "dh");
joint1.PositionLimits = deg2rad([-150 150]);
body1.Joint = joint1;
addBody(robot, body1, robot.BaseName);

body2 = rigidBody("link2");
joint2 = rigidBodyJoint("joint2", "revolute");
setFixedTransform(joint2, [L2 0 0 0], "dh");
joint2.PositionLimits = deg2rad([-160 160]);
body2.Joint = joint2;
addBody(robot, body2, "link1");

% Define two reachable joint-space waypoints and a smooth round trip.
qA = deg2rad([20 45]);
qB = deg2rad([75 -55]);
numSteps = 160;
s = linspace(0, 1, numSteps)';
blend = 3*s.^2 - 2*s.^3;             % zero velocity at both ends
qForward = qA + blend .* (qB - qA);
qTrajectory = [qForward; flipud(qForward(1:end-1,:))];

% Animate and draw the end-effector trace.
fig = figure("Color", "w", "Name", "2-DOF Planar Manipulator");
ax = axes(fig);
hold(ax, "on");
axis(ax, "equal");
reach = L1 + L2;
axis(ax, 1.1*[-reach reach -reach reach]);
grid(ax, "on");
xlabel(ax, "X (m)"); ylabel(ax, "Y (m)");
title(ax, "2-DOF Planar Manipulator");

% Draw arm links directly so the end-effector trace remains visible.
hArm = plot(ax, [0 L1 L1+L2], [0 0 0], "o-", ...
    "LineWidth", 4, "MarkerSize", 8, "Color", [0.1 0.35 0.75], ...
    "MarkerFaceColor", [0.95 0.55 0.15]);
path = animatedline(ax, "Color", [0.85 0.2 0.15], "LineWidth", 1.5);

for k = 1:size(qTrajectory, 1)
    q = qTrajectory(k,:);
    x1 = L1*cos(q(1));
    y1 = L1*sin(q(1));
    x2 = x1 + L2*cos(q(1) + q(2));
    y2 = y1 + L2*sin(q(1) + q(2));
    set(hArm, "XData", [0 x1 x2], "YData", [0 y1 y2]);
    addpoints(path, x2, y2);
    title(ax, sprintf("2-DOF Planar Manipulator   q = [%5.1f°, %5.1f°]", ...
        rad2deg(q(1)), rad2deg(q(2))));
    drawnow limitrate;
end

% Report the final end-effector position.
Tfinal = getTransform(robot, qTrajectory(end,:), "link2");
fprintf("Final end-effector position: x = %.3f m, y = %.3f m\n", ...
    Tfinal(1,4), Tfinal(2,4));

The output trajectory formed by the robot’s tool is obtained as

You can also update the skills.md file to store your preferences for the next task.

⚠️ One important point

This is an agent, not simply an AI autocomplete tool.

That also means you should review and validate the actions it takes. MathWorks specifically recommends keeping a human in the loop and reviewing tool calls before allowing important operations to proceed.

🔗 Explore the tool

My take: The interesting development here isn't simply “AI can write MATLAB.” We've had that for a while.

The more important shift is that AI agents can now execute, test, analyze, and iterate on engineering code inside established tools such as MATLAB.

For robotics researchers and engineers, that could make the AI assistant part of the simulation and development loop—not just a code generator.