{"id":19125,"date":"2026-01-21T10:26:20","date_gmt":"2026-01-21T15:26:20","guid":{"rendered":"https:\/\/blogs.mathworks.com\/deep-learning\/?p=19125"},"modified":"2026-01-21T10:28:29","modified_gmt":"2026-01-21T15:28:29","slug":"giving-local-ai-agents-the-ability-to-use-matlab-with-mcp","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/deep-learning\/2026\/01\/21\/giving-local-ai-agents-the-ability-to-use-matlab-with-mcp\/","title":{"rendered":"Giving Local AI Agents the ability to use MATLAB with MCP"},"content":{"rendered":"<div class=\"rtcContent\">\r\n<div>\r\n<div class=\"rtcContent\">\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">\r\n<h6><\/h6>\r\n<table style=\"background-color: #e2f0ff;\">\r\n<tbody>\r\n<tr>\r\n<td style=\"width: 120px; padding: 3px; vertical-align: middle;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-19126\" src=\"https:\/\/blogs.mathworks.com\/deep-learning\/files\/2026\/01\/abhijit_small.jpg\" alt=\"\" width=\"100\" height=\"100\" \/><\/td>\r\n<td style=\"vertical-align: middle; padding: 3px;\"><strong>Guest writer: <\/strong><a href=\"https:\/\/www.linkedin.com\/in\/bhattacharjeeabhijit\">Abhijit Bhattacharjee<\/a>\r\n\r\nAbhijit is an application engineer at MathWorks and an expert in AI. He supports customers with the latest and greatest technologies in the space, specifically Agentic AI in the past couple of months.<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/div>\r\n<\/div>\r\n<h6><\/h6>\r\n<div class=\"rtcContent\">\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><\/div>\r\n<\/div>\r\n<\/div>\r\n<div><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Building on my colleague <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/20789457?s_tid=blg_to_profile\">Mike's<\/a> fabulous article on <a href=\"https:\/\/blogs.mathworks.com\/matlab\/2026\/01\/05\/running-large-language-models-on-the-nvidia-dgx-spark-and-connecting-to-them-in-matlab\/\">running LLMs on the NVIDIA DGX Spark and connecting to them in MATLAB<\/a>, I wanted to see if I could flip the workflow; instead of MATLAB calling an LLM (Large Language Model), what if I could have a <span style=\"font-weight: bold;\">local LLM agent call MATLAB?<\/span> That way, the entire MATLAB itself becomes a tool at the agent's disposal, ready to perform, execute, and verify code that the LLM writes.<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">And the best part? Nothing leaves my network and it's all handled locally.<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Fortunately for me, I was also able to get my hands on a beautiful NVIDIA DGX Spark unit to play around with.<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 754px; height: 425px;\" src=\"https:\/\/blogs.mathworks.com\/deep-learning\/files\/2026\/01\/article_1.png\" alt=\"\" width=\"754\" height=\"425\" \/><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">You can learn more about the DGX Spark's specs <a href=\"https:\/\/www.nvidia.com\/en-us\/products\/workstations\/dgx-spark\/\">HERE<\/a>, but the key thing here is that it has enough VRAM (128GB) to handle local LLMs of significant enough size that they can do real engineering work. And that's what I'd like to share with you today.<\/div>\r\n<h2 style=\"margin: 20px 10px 5px 4px; padding: 0px; line-height: 25px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;\">Setting up the local LLM<\/h2>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Like Mike, I chose to use the fantastic <a href=\"https:\/\/openai.com\/index\/introducing-gpt-oss\/\">gpt-oss-120b<\/a> model for its reliable tool-calling abilities and its high performance as a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Mixture_of_experts\">mixture-of-experts (MoE)<\/a>, which means it only uses a fraction of 120 billion parameters actively, reducing the computational load. However, I chose a slightly more complex route than he did, and decided to compile <a href=\"https:\/\/github.com\/ggml-org\/llama.cpp\">llama.cpp<\/a> from source to run the model, to try and eke out even more tokens-per-second (tps) than Ollama, which also uses llama.cpp as its backend. While this sounds intimidating, it's actually not so bad, especially with the comprehensive instructions in the repository.<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">To make use of the local model, you need to launch llama-server with the right parameters. Here is my optimized launch command for the DGX Spark to run gpt-oss-120b:<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\">llama-server \\<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> -m models\/gpt-oss-120b\/Q4_K_M\/gpt-oss-120b-Q4_K_M-00001-of-00002.gguf \\<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> --host 0.0.0.0 --port 8080 \\<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> -ngl 999 \\<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> -fa on \\<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> -t 10 \\<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> -c 0 \\<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> -b 2048 -ub 2048 \\<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> -ctk q8_0 -ctv q8_0 \\<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> --no-mmap \\<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> --jinja \\<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> --reasoning-format auto \\<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> --chat-template-kwargs \"{\\\"reasoning_effort\\\": \\\"medium\\\"}\" \\<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> --temp 1.0 \\<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> --top-p 1.0 \\<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> --top-k 0<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Running it in this way allowed me to specify some optimizations, such as <span style=\"font-family: monospace;\">--no-mmap<\/span>, which disables memory-mapped file I\/O (not needed for unified memory architectures such as the DGX Spark) and <span style=\"font-family: monospace;\">-fa on<\/span>, which enables flash attention kernels, speeding up processing of long sequences of tokens.<\/div>\r\n<h3 style=\"margin: 15px 10px 5px 4px; padding: 0px; line-height: 20.4px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 17px; font-weight: bold; text-align: left;\">Agentic AI coding with the local model<\/h3>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Now before we get to using MATLAB as a callable tool, I needed a way to interact with this local model outside of MATLAB. Fortunately, we can use the very popular agentic AI terminal application <a href=\"https:\/\/opencode.ai\/\">OpenCode<\/a> as a harness. OpenCode allows you to configure a local model in a number of ways. One easy way is to use the opencode.json configuration file.<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">The other thing I want to do is point OpenCode at the local <a href=\"https:\/\/github.com\/matlab\/matlab-mcp-core-server\">MATLAB MCP Core Server<\/a> instance on my machine. To catch up on Model Context Protocol (MCP) and how it works, definitely check out one of our recent blog posts on the topic, like <a href=\"https:\/\/blogs.mathworks.com\/deep-learning\/2025\/11\/03\/releasing-the-matlab-mcp-core-server-on-github\/\">THIS ONE<\/a>.<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">A bit more JSON finagling, and our full opencode.json file to configure both the local LLM (with an endpoint address of <span style=\"font-family: monospace;\">192.168.108.170<\/span>) and the local MATLAB MCP connection looks as follows.<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\">{<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> \"$schema\"<\/span><span style=\"font-family: monospace;\">: <\/span><span style=\"font-family: monospace;\">\"https:\/\/opencode.ai\/config.json\"<\/span><span style=\"font-family: monospace;\">,<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> \"provider\"<\/span><span style=\"font-family: monospace;\">: {<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> \"llama.cpp\"<\/span><span style=\"font-family: monospace;\">: {<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> \"npm\"<\/span><span style=\"font-family: monospace;\">: <\/span><span style=\"font-family: monospace;\">\"@ai-sdk\/openai-compatible\"<\/span><span style=\"font-family: monospace;\">,<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> \"name\"<\/span><span style=\"font-family: monospace;\">: <\/span><span style=\"font-family: monospace;\">\"llama.cpp (abhijit-spark)\"<\/span><span style=\"font-family: monospace;\">,<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> \"options\"<\/span><span style=\"font-family: monospace;\">: {<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> \"baseURL\"<\/span><span style=\"font-family: monospace;\">: <\/span><span style=\"font-family: monospace;\">\"http:\/\/192.168.108.170:8080\/v1\"<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> },<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> \"models\"<\/span><span style=\"font-family: monospace;\">: {<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> \"gpt-oss-120b-GGUF\"<\/span><span style=\"font-family: monospace;\">: {<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> \"name\"<\/span><span style=\"font-family: monospace;\">: <\/span><span style=\"font-family: monospace;\">\"gpt-oss-120b\"<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> }<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> }<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> }<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> },<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> \"mcp\"<\/span><span style=\"font-family: monospace;\">: {<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> \"MATLAB MCP\"<\/span><span style=\"font-family: monospace;\">: {<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> \"type\"<\/span><span style=\"font-family: monospace;\">: <\/span><span style=\"font-family: monospace;\">\"local\"<\/span><span style=\"font-family: monospace;\">,<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> \"command\"<\/span><span style=\"font-family: monospace;\">: [<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> \"C:<\/span><span style=\"font-family: monospace;\">\\\\<\/span><span style=\"font-family: monospace;\">Users<\/span><span style=\"font-family: monospace;\">\\\\<\/span><span style=\"font-family: monospace;\">abhijit<\/span><span style=\"font-family: monospace;\">\\\\<\/span><span style=\"font-family: monospace;\">Local Content<\/span><span style=\"font-family: monospace;\">\\\\<\/span><span style=\"font-family: monospace;\">Apps<\/span><span style=\"font-family: monospace;\">\\\\<\/span><span style=\"font-family: monospace;\">matlab-mcp-core-server-win64.exe\"<\/span><span style=\"font-family: monospace;\">, <\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> \"--matlab-root=C:<\/span><span style=\"font-family: monospace;\">\\\\<\/span><span style=\"font-family: monospace;\">Program Files<\/span><span style=\"font-family: monospace;\">\\\\<\/span><span style=\"font-family: monospace;\">MATLAB<\/span><span style=\"font-family: monospace;\">\\\\<\/span><span style=\"font-family: monospace;\">R2025b\"<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> ],<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> \"enabled\"<\/span><span style=\"font-family: monospace;\">: <\/span><span style=\"font-family: monospace;\">true<\/span><span style=\"font-family: monospace;\">,<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> }<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\"> }<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\">}<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">After configuring everything as above, when I launch OpenCode, I'm greeted with a screen showing me that both the local model is selected and available, and that the MATLAB MCP is connected and running:<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 769px; height: 377px;\" src=\"https:\/\/blogs.mathworks.com\/deep-learning\/files\/2026\/01\/article_2.png\" alt=\"\" width=\"769\" height=\"377\" \/><\/div>\r\n<h2 style=\"margin: 20px 10px 5px 4px; padding: 0px; line-height: 25px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;\">Let's start vibe coding!<\/h2>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">To show off how well this works with the MATLAB MCP Core Server enabled, I'm going to enter the following prompt, which will do some data analysis on a built-in dataset that comes installed with MATLAB:<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-style: italic;\">Create a MATLAB script that loads carbig dataset and creates 3 plots showcasing how different car properties affect MPG. Use default positions for any figures you create. <\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-style: italic;\">Train an ensemble regression model using this data to predict MPG from weight, horsepower, displacement, and acceleration. Show me the model statistics and diagnostic plots.<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-style: italic;\">Use the MATLAB MCP to execute and test your code.<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Now normally, with frontier models such as Claude Opus or GPT-5.2, you don't need to specify that the MCP needs to be invoked. Those LLMs will figure it out automatically. But for gpt-oss-120b, I decided it to give that extra bit of guidance, just so it wouldn't spin its wheels for too long. Here's a video demonstration of my coding session.<\/div>\r\n<div class=\"row\"><div class=\"col-xs-12 containing-block\"><div class=\"bc-outer-container add_margin_20\"><videoplayer><div class=\"video-js-container\"><video data-video-id=\"6387829030112\" data-video-category=\"blog\" data-autostart=\"false\" data-account=\"62009828001\" data-omniture-account=\"mathwgbl\" data-player=\"rJ9XCz2Sx\" data-embed=\"default\" id=\"mathworks-brightcove-player\" class=\"video-js\" controls><\/video><script src=\"\/\/players.brightcove.net\/62009828001\/rJ9XCz2Sx_default\/index.min.js\"><\/script><script>if (typeof(playerLoaded) === 'undefined') {var playerLoaded = false;}(function isVideojsDefined() {if (typeof(videojs) !== 'undefined') {videojs(\"mathworks-brightcove-player\").on('loadedmetadata', function() {playerLoaded = true;});} else {setTimeout(isVideojsDefined, 10);}})();<\/script><\/div><\/videoplayer><\/div><\/div><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">So that's the magic: a local LLM agent driving MATLAB like a pro, with everything running on your own hardware and none of your data drifting off into the cloud. The DGX Spark has more than enough muscle to make models like gpt-oss-120b genuinely useful, and once you plug it into the MATLAB MCP Core Server, the whole setup feels surprisingly natural, almost like MATLAB just became another tool in your AI's toolbox.<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Is it perfect? Not yet. But it's already <span style=\"font-style: italic;\">good<\/span>, and with a little prompt tuning (or a beefier model like <a href=\"https:\/\/mistral.ai\/news\/devstral-2-vibe-cli\">Devstral 2<\/a>), it gets even better.<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">This workflow shows what's coming: real engineering work powered by local AI agents, fully private, fully under your control, and honestly...pretty fun to use.<\/div>\r\n<\/div>","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/deep-learning\/files\/2026\/01\/article_2.png\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/div><p>\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nGuest writer: Abhijit Bhattacharjee\r\n\r\nAbhijit is an application engineer at MathWorks and an expert in AI. He supports customers with the latest and greatest technologies in the... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/deep-learning\/2026\/01\/21\/giving-local-ai-agents-the-ability-to-use-matlab-with-mcp\/\">read more >><\/a><\/p>","protected":false},"author":230,"featured_media":19135,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[74,78],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/deep-learning\/wp-json\/wp\/v2\/posts\/19125"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/deep-learning\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/deep-learning\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/deep-learning\/wp-json\/wp\/v2\/users\/230"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/deep-learning\/wp-json\/wp\/v2\/comments?post=19125"}],"version-history":[{"count":9,"href":"https:\/\/blogs.mathworks.com\/deep-learning\/wp-json\/wp\/v2\/posts\/19125\/revisions"}],"predecessor-version":[{"id":19143,"href":"https:\/\/blogs.mathworks.com\/deep-learning\/wp-json\/wp\/v2\/posts\/19125\/revisions\/19143"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/deep-learning\/wp-json\/wp\/v2\/media\/19135"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/deep-learning\/wp-json\/wp\/v2\/media?parent=19125"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/deep-learning\/wp-json\/wp\/v2\/categories?post=19125"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/deep-learning\/wp-json\/wp\/v2\/tags?post=19125"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}