# matlab/matlab-ai-agent-sdk architecture

> Architecture diagram of the GitHub repository matlab/matlab-ai-agent-sdk, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/matlab/matlab-ai-agent-sdk
- Repository: https://github.com/matlab/matlab-ai-agent-sdk

## Overview

MATLAB AI Agent SDK lets MATLAB users call language models directly or create stateful agents that can use tools and agent-workspace data. The principal workflow is to create a client, create an agent with a prompt and optional tools, then run it to obtain a response and retain conversation history. The tree also shows distinct skill and MCP capabilities. Only README-described relationships are evidenced; source excerpts were unavailable, so uncertain internal calls are omitted or marked dashed.

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_agent_runtime["Agent Runtime"]
  node_agent["AI Agent"]
  node_messages["Message Types"]
end

subgraph group_model_clients["Model Clients"]
  node_client_api["Client Factory"]
  node_client_base["Client Base"]
  node_openai_client["OpenAI Chat"]
  node_responses_client["OpenAI Responses"]
  node_ollama_client["Ollama Client"]
end

subgraph group_tools_skills["Tools and Skills"]
  node_tool_definition["Tool Definition"]
  node_tool_arguments["Tool Arguments"]
  node_local_tool["Local Tool"]
  node_built_in_tool["Built-in Tools"]
  node_approval["Tool Approval"]
  node_skill_tool["Load Skill Tool"]
  node_skill_registry["Skill Registry"]
end

subgraph group_mcp_integration["MCP Integration"]
  node_mcp_client["MCP Client"]
  node_mcp_tool["MCP Tool"]
end

node_matlab_user(("MATLAB User"))
node_openai_service{{"OpenAI API"}}
node_ollama_service{{"Ollama"}}
node_mcp_server{{"MCP Server"}}

node_matlab_user -->|"creates client"| node_client_api
node_matlab_user -->|"creates and runs"| node_agent
node_client_api -.->|"selects API"| node_openai_client
node_client_api -.->|"selects API"| node_responses_client
node_client_api -.->|"selects API"| node_ollama_client
node_agent -.->|"uses client"| node_client_base
node_openai_client -->|"requests completions"| node_openai_service
node_responses_client -->|"requests responses"| node_openai_service
node_ollama_client -->|"connects to models"| node_ollama_service
node_agent -->|"tracks history"| node_messages
node_matlab_user -->|"defines tool"| node_tool_definition
node_tool_definition -->|"describes arguments"| node_tool_arguments
node_agent -->|"uses tools"| node_tool_definition
node_agent -.->|"runs tool"| node_local_tool
node_agent -.->|"uses tools"| node_built_in_tool
node_agent -.->|"requests approval"| node_approval
node_matlab_user -.->|"loads skill"| node_skill_tool
node_skill_tool -.->|"registers skill"| node_skill_registry
node_matlab_user -.->|"uses MCP client"| node_mcp_client
node_agent -.->|"uses MCP tool"| node_mcp_tool
node_mcp_tool -.->|"delegates to"| node_mcp_client
node_mcp_client -.->|"communicates with"| node_mcp_server

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_agent,node_messages,node_matlab_user toneBlue
class node_client_api,node_client_base,node_openai_client,node_responses_client,node_ollama_client toneAmber
class node_tool_definition,node_tool_arguments,node_local_tool,node_built_in_tool,node_approval,node_skill_tool,node_skill_registry,node_openai_service,node_mcp_server toneMint
class node_mcp_client,node_mcp_tool toneRose
class node_ollama_service toneIndigo
```

## Components

### Agent Runtime

- **AI Agent**
- **Message Types**

### Model Clients

- **Client Factory**
- **Client Base**
- **OpenAI Chat**
- **OpenAI Responses**
- **Ollama Client**

### Tools and Skills

- **Tool Definition**
- **Tool Arguments**
- **Local Tool**
- **Built-in Tools**
- **Tool Approval**
- **Load Skill Tool**
- **Skill Registry**

### MCP Integration

- **MCP Client**
- **MCP Tool**

### Other components

- **MATLAB User**
- **OpenAI API**
- **Ollama**
- **MCP Server**

## Connections

- MATLAB User → Client Factory: creates client (evidence: `README.md`)
- MATLAB User → AI Agent: creates and runs (evidence: `README.md`)
- Client Factory → OpenAI Chat: selects API
- Client Factory → OpenAI Responses: selects API
- Client Factory → Ollama Client: selects API
- AI Agent → Client Base: uses client
- OpenAI Chat → OpenAI API: requests completions (evidence: `README.md`)
- OpenAI Responses → OpenAI API: requests responses (evidence: `README.md`)
- Ollama Client → Ollama: connects to models (evidence: `README.md`)
- AI Agent → Message Types: tracks history (evidence: `README.md`)
- MATLAB User → Tool Definition: defines tool (evidence: `README.md`)
- Tool Definition → Tool Arguments: describes arguments (evidence: `README.md`)
- AI Agent → Tool Definition: uses tools (evidence: `README.md`)
- AI Agent → Local Tool: runs tool
- AI Agent → Built-in Tools: uses tools
- AI Agent → Tool Approval: requests approval
- MATLAB User → Load Skill Tool: loads skill
- Load Skill Tool → Skill Registry: registers skill
- MATLAB User → MCP Client: uses MCP client
- AI Agent → MCP Tool: uses MCP tool
- MCP Tool → MCP Client: delegates to
- MCP Client → MCP Server: communicates with
