MCP for AI Agents (Claude Code, Cursor, etc.)
What is MCP?
MCP (Model Context Protocol) is an open standard protocol that lets AI agents—such as Claude Code, Cursor, and other AI coding assistants—operate your CoModel instance directly: search the component library, write and validate model code, create components, run simulations, and read results.
After connecting, you drive the platform with natural language. Examples:
Build a spring-mass-damper model with m = 1.5 kg, k = 100 N/m, d = 2 N·s/m, initial displacement 0.2 m, and run a 10 s simulation.
Read model
SpringMassDamper, change the spring stiffness to 150 N/m, validate, and resubmit the simulation.Sweep the damping coefficient from 1 to 10 and plot how the overshoot changes.
The intelligence comes from the agent you already use. CoModel exposes its full modeling-and-simulation tool surface over MCP; the agent's own LLM plans the steps. Every tool call runs under your account's permissions—the agent can do exactly what you could do in the web UI, nothing more.
Prerequisites
- A running CoModel instance (cloud or locally installed) with your user account on it, and the model/component permissions you want the agent to have.
- CoModel 1.17.0 or later (the MCP service ships since Phase 14-03).
- An MCP client that supports the Streamable HTTP transport: Claude Code, Cursor, and other agents with MCP support.
Step 1: Create a personal access token (PAT)
MCP access is authenticated by a personal access token (PAT) bound to your user account. The token carries your full account permissions; there are no separate MCP scopes.
- Sign in to the CoModel web UI.
- Open the user menu at the bottom of the left sidebar and choose Profile; find the Personal access tokens (MCP) card.
- Click Create token and give it a recognizable name, e.g.
Claude Code on my laptop. - The new token is shown only once. Copy it immediately and store it safely—after closing the dialog you can only see a masked preview like
cmk_xxxx****xxxx.


Token rules worth knowing:
- Tokens never expire; control their lifecycle by revoking. A revoked token stops working immediately.
- Each user may keep at most 20 active tokens; revoke unused ones first if you hit the limit.
- Treat the token like a password: never commit it to a repository or share it in chat.
Step 2: Configure your MCP client
Two facts are all a client needs:
| Item | Value |
|---|---|
| Service URL (Streamable HTTP) | See the table below — pick by deployment type |
| Authentication header | Authorization: Bearer <your-token> |
Replace <your-token> with the PAT from Step 1 (it starts with cmk_).
Service URL: pick by deployment type
| Deployment | Service URL |
|---|---|
| Cloud (comodelsim.com and other online instances) | https://www.comodelsim.com/mcp |
| Locally installed (Windows / Linux installer, on this machine or an intranet server) | http://<host>:8101/mcp |
- Cloud instances are fronted by a gateway that forwards
/mcpto the internal MCP service. - Locally installed instances listen directly on port 8101, and the endpoint path is plain
/mcp— no/comodelprefix, and no HTTPS.<host>is the machine where CoModel is installed: use127.0.0.1for this machine, or the IP/hostname of the intranet server.
The examples below use the cloud URL; if you installed CoModel locally, replace the URL in each example wholesale with http://127.0.0.1:8101/mcp (or swap the host part for another machine).
Claude Code (CLI)
Register the MCP server with one command (replace <your-token>):
claude mcp add --transport http comodel https://www.comodelsim.com/mcp \
--header "Authorization: Bearer <your-token>"
Locally installed example:
claude mcp add --transport http comodel http://127.0.0.1:8101/mcp \
--header "Authorization: Bearer <your-token>"
By default the registration is local—private to you, in the current project only. Add --scope user to make it available in all your projects, or --scope project to write it into the project's shared .mcp.json (avoid putting the plaintext token in a checked-in file; use an environment variable reference instead). Verify with claude mcp get comodel, then start Claude Code and try a prompt.
Cursor
Cursor reads MCP servers from ~/.cursor/mcp.json (or the project-local .cursor/mcp.json). Add:
Cloud instance:
{
"mcpServers": {
"comodel": {
"url": "https://www.comodelsim.com/mcp",
"headers": {
"Authorization": "Bearer ${env:COMODEL_MCP_TOKEN}"
}
}
}
}
Locally installed (only url differs):
{
"mcpServers": {
"comodel": {
"url": "http://127.0.0.1:8101/mcp",
"headers": {
"Authorization": "Bearer ${env:COMODEL_MCP_TOKEN}"
}
}
}
}
Tip: Cursor expands
${env:VAR}references, so the plaintext token never has to sit in the config file—exportCOMODEL_MCP_TOKENin your shell instead.
Save the file and reload the MCP panel in Cursor; the comodel server should show as connected.
Generic configuration
Any MCP client that supports Streamable HTTP needs the same three values: transport type http, the service URL (per the table above), and the Authorization: Bearer header. Consult your client's documentation for where these go.
Step 3: What the agent can do — the tool surface
The MCP server exposes 20 tools covering the full modeling-and-simulation workflow. In your first conversation, the agent will usually start from get_platform_knowledge—CoModel's built-in MTK dialect differs from older tutorials an LLM may remember, and the knowledge domains give the agent the correct, current facts.
| Category | Tools | Purpose |
|---|---|---|
| Knowledge | get_platform_knowledge |
Fetch one of five platform-knowledge domains: mtk_modern, component_anatomy, model_anatomy, custom_syntax, graph_manifest |
| Discovery | search_components, get_component, list_categories, create_category |
Find components and their ports/parameters; organize with categories |
| Models | list_models, get_model, create_model, update_model |
Read history as reference; create/update models (every save creates a rollback-able version) |
| Compilation | parse_model_code, validate_graph |
Parse MTK code into a graph and run static validation before anything is saved |
| Simulation | run_simulation, get_simulation, get_result_series, get_sim_error, cancel_simulation |
Submit (async), poll, read time series, read verbatim error logs, cancel |
| Parameter studies | run_parameter_study, get_parameter_study |
Submit sweeps and fetch results |
| Components | create_component, update_component |
Author user component libraries (hard compiler gate applies) |
- Simulation results are data, not pictures.
get_simulation/get_result_seriesreturn statistical summaries and time series; the agent charts them with its own plotting ability.
Usage examples
Example 1: Build and simulate from scratch
Input:
Build a spring-mass-damper model: mass 1.5 kg, spring 100 N/m, damper 2 N·s/m, spring attached to a fixed end, initial displacement 0.2 m. Then run a 10 s simulation.
A typical agent workflow: get_platform_knowledge (model anatomy + MTK dialect) → search_components (find the standard-library parts) → parse_model_code / validate_graph (fix issues in-place) → create_model → run_simulation → get_simulation → get_result_series.
Result: the agent reports the outcome in one sentence—e.g. "steady state ≈ 0 m, ~6 % overshoot, oscillation decays within about 4 s"—and can plot the position/velocity curves itself.
Example 2: Modify an existing model
Input:
Open my
SpringMassDampermodel, change the spring stiffness to 150 N/m, validate, and save as a new version.
The agent calls get_model (reads current code), edits the stiffness, runs validate_graph, then update_model. If someone else edited the model meanwhile and you pass expected_version, the conflicting save is rejected rather than silently overwritten; every accepted save creates a new version you can roll back to in the web UI.
Example 3: Diagnose a failed simulation
Input:
The simulation of my
SpringMassDampervariant failed. Find out why and fix it.
The agent calls get_simulation (status + structured error), then get_sim_error for the verbatim solver log—including initialization-failure diagnostics—identifies the cause (e.g. an inconsistent initial condition), fixes the code, validates, and resubmits.
Example 4: Parameter sweep
Input:
Sweep the damping coefficient d from 1 to 10 N·s/m in 10 steps, simulate each, and summarize how peak overshoot changes with d.
The agent calls run_parameter_study (returns a study_id and the total run count), polls get_parameter_study until finished, fetches the result, and summarizes or plots the trend.
Error codes
Tool failures return a structured error the agent can act on:
| Code | Meaning | What the agent should do |
|---|---|---|
INVALID_ARGUMENT |
Malformed parameters or a name conflict | Fix the arguments |
VALIDATION_FAILED |
Code failed parse/validate (includes line numbers and the offending port/parameter names) | Fix the code |
NOT_FOUND |
Model/simulation does not exist or is not visible to your account | Stop; check the ID and permissions |
FORBIDDEN |
The action needs administrator rights or is not permitted | Stop |
LICENSE_REQUIRED |
Model-count limit of the license reached | Free up models or upgrade the license |
QUOTA_EXCEEDED |
Component-library storage quota full | Free space and retry |
CONFLICT |
update_model version conflict (stale expected_version) |
Re-read the model and retry |
BUSY |
The simulation engine is at capacity | Retry with backoff |
INTERNAL |
Server-side failure | Retry a limited number of times, then report |
Errors carry a retryable flag—the agent uses it to decide whether retrying makes sense.
Notes and limitations
- Token security — the PAT carries your full account permissions. Revoke immediately from the Profile → Personal access tokens (MCP) card if it leaks; revocation takes effect at once and usage remains auditable.
- Permissions mirror the web UI — the agent sees exactly the models and components your account can access; nothing extra is exposed.
- Images are drawn by the agent — CoModel returns data and statistical summaries, not rendered plots. Agents with plotting ability (Claude Code, Cursor) chart results themselves.
- Timeouts — synchronous tool calls time out at the server between 30 s and 200 s depending on the operation (component parsing up to 120 s). Long simulations are always asynchronous—submit, then poll.
- No delete operations — models and components cannot be deleted over MCP (v1). Manage deletions in the web UI.