Skip to main content
Glama

The first MCP (Model Context Protocol) server for NetLogo — enabling AI assistants to create, run, and analyze agent-based models through natural conversation.

Works with: Claude Code, Claude Desktop, Cursor, Windsurf, VS Code (Copilot), Cline, Continue, Roo Code, Zed, OpenCode, Codex — any tool that supports MCP.

Why NetLogo MCP?

As an AI student taking an Agent-Based Modeling course, I searched for an MCP server to control NetLogo — nothing existed. So I built one.

Instead of manually writing NetLogo code, clicking buttons, and tweaking sliders, you tell your AI assistant what you want in plain English:

"Create a predator-prey model with 100 sheep and 20 wolves. Run it for 500 ticks and show me the population dynamics."

The AI writes the code, runs the simulation, and shows you the results — all through conversation.

By default a real NetLogo window opens (on first use) so you can watch your simulations run live. Headless mode is available for CI or servers.

Related MCP server: mcp-tap

Features

  • Create models from code — with real interface widgets: sliders, switches, buttons, monitors

  • Run simulations and collect tick-by-tick data as markdown tables

  • Run BehaviorSpace experiments — parallel parameter sweeps via the headless launcher

  • Export the view as PNG — visible inline in chat

  • Inspect everything — world state, agent samples, patch grids for heatmaps

  • CoMSES Net integration — search and safely run models from the largest peer-reviewed ABM library

  • Built-in references — NetLogo primitives, programming guide, and 6→7 transition guide as MCP resources

  • Lazy startup — the NetLogo window only opens when you actually use a tool, not when your AI client connects

See docs/TOOLS.md for the full reference of all 25 tools, widget schema, and prompts.

Prerequisites

Requirement

Install via terminal?

How

Python 3.10+

Yes

Windows: winget install Python.Python.3.12 · macOS: brew install python@3.12 · Linux: sudo apt install python3.12

Java JDK 11+

Yes

Windows: winget install EclipseAdoptium.Temurin.21.JDK · macOS: brew install --cask temurin · Linux: sudo apt install openjdk-21-jdk

NetLogo 7.0+

No — manual

Download from ccl.northwestern.edu/netlogo

Only NetLogo requires manual download. Everything else can be installed via terminal, and the Zero-Config Setup prompt below handles those automatically.

If you're using an AI coding tool, copy the prompt below into your chat. The AI will detect your OS, find your NetLogo and Java installations, clone the repo, install dependencies, configure your MCP client, and tell you how to use it.

Please set up the NetLogo MCP server for me end-to-end. Follow these steps carefully:

1. **Detect my environment**
   - Identify my OS (Windows / macOS / Linux).
   - Check Python version (need 3.10+). If missing, tell me to install it first and stop.
   - Check for Java JDK 11+ (not JRE). Look in common locations (JAVA_HOME env var, standard install dirs). If missing, tell me to install Adoptium Temurin JDK 11+ and stop.
   - Check for NetLogo 7.0+. Look in common locations:
     - Windows: `C:/Program Files/NetLogo*`
     - macOS: `/Applications/NetLogo*`
     - Linux: `/opt/netlogo*`, `~/netlogo*`
     If NetLogo isn't installed, tell me to download it from https://ccl.northwestern.edu/netlogo/download.shtml and stop.

2. **Install**
   - Run: `pip install netlogo-mcp`
   - Verify the `netlogo-mcp` command is now available on my PATH.

3. **Identify my MCP client**
   - Figure out which AI tool I'm using (Claude Code, Cursor, Windsurf, Cline, Continue, Roo Code, Zed, OpenCode, VS Code Copilot, Codex, or Claude Desktop).
   - If you're not sure, ask me.

4. **Configure the MCP client**
   - Locate (or create) the correct config file for my client (see
     https://github.com/Razee4315/NetLogo-MCP/blob/main/docs/CLIENTS.md
     for exact paths and schemas per client).
   - Add a `netlogo` server entry with:
     - `command`: `netlogo-mcp`
     - `env.NETLOGO_HOME`: the NetLogo path you detected
     - `env.JAVA_HOME`: the JDK path you detected
   - Use the exact JSON schema for my specific client (e.g. `"type": "stdio"` for Cursor, `"servers"` key for VS Code).
   - Preserve any existing config entries — merge, don't overwrite.
   - IMPORTANT: configure it for THIS project only (project-scope config file), not globally, unless I say otherwise — a global entry loads the server in every session.

5. **Tell me what to do next**
   - Tell me to fully restart my AI tool for the new MCP server to load.
   - Tell me the NetLogo window opens on the FIRST model tool call, and that call takes 30–60 seconds while the Java Virtual Machine starts. Tell me NOT to click stop during this wait.
   - Give me this exact test prompt to try after restart:

     > "Create a simple predator-prey model with wolves and sheep on a green landscape. Run setup, then run 100 ticks while tracking wolf and sheep counts. Export the view before and after so I can see how the world evolved."

   - Tell me where models and exports are saved (by default, the current working directory's `models/` and `exports/` folders) and that I can browse them with the `list_models` tool.

Do not skip any verification step. If something fails, stop and tell me exactly what failed and how to fix it.

Manual Installation

pip install netlogo-mcp

Then add the server to your MCP client. For Claude Code, add to your project's .mcp.json:

{
  "mcpServers": {
    "netlogo": {
      "command": "netlogo-mcp",
      "args": [],
      "env": {
        "NETLOGO_HOME": "C:/Program Files/NetLogo 7.0.3",
        "JAVA_HOME": "C:/Program Files/Eclipse Adoptium/jdk-25.0.2.10-hotspot"
      }
    }
  }
}

Restart Claude Code and verify with /mcp.

Tip: prefer project-scope config (.mcp.json in one project) over global config — a global entry loads the server in every session of every project.

Using Cursor, Windsurf, VS Code, Cline, Continue, Roo Code, Zed, OpenCode, Codex, or Claude Desktop? See docs/CLIENTS.md for exact config for all 11 clients. All configuration options (GUI/headless mode, directories, limits) are in docs/CONFIGURATION.md.

Developing or contributing? Clone the repo and install editable instead:

git clone https://github.com/Razee4315/NetLogo-MCP.git
cd NetLogo-MCP
pip install -e ".[dev]"

Docker

The image bakes in NetLogo (headless) with its bundled JRE — no host install needed:

docker build -t netlogo-mcp .
docker run -i --rm netlogo-mcp

MCP client config:

{
  "mcpServers": {
    "netlogo": {
      "command": "docker",
      "args": ["run", "-i", "--rm", "netlogo-mcp"]
    }
  }
}

Docker runs headless only (no GUI mode). Add -v ./exports:/data/exports to keep exported views and worlds on the host.

Quick Start

Once connected, try these prompts in any MCP client:

> Create a simple NetLogo model with 50 turtles doing a random walk.
  Run setup, simulate 100 ticks, and export the view.

> Open the Wolf Sheep Predation model and run a parameter sweep
  on initial-number-wolves from 10 to 100.

> Build a disease spread model with sliders for population size and
  infection chance.

The first model tool call takes 30-60 seconds while the JVM starts — the NetLogo window appears when it's ready. Don't click stop. Every call after that is instant.

Troubleshooting

Problem

Solution

NETLOGO_HOME is not set

Set the environment variable to your NetLogo install directory

JAVA_HOME is not set

Set it to your JDK directory (not JRE)

JVM crashes on startup

Make sure JAVA_HOME points to JDK 11+, not an older version

No model is loaded

Call open_model or create_model before using other tools

First model call hangs for 30-60s

Normal — JVM is warming up. Don't click stop.

NetLogo window opens when my AI client starts

You have NETLOGO_EAGER_START=true set, or an old version — by default the window only opens on first tool use

Server won't connect

Run netlogo-mcp manually in terminal to see error output

Documentation

Listed on

MCP Badge

Citing

If you use NetLogo MCP in research or teaching, please cite it — click "Cite this repository" in the GitHub sidebar, or see CITATION.cff.

Author

Saqlain Abbas Email: saqlainrazee@gmail.com GitHub: @Razee4315 LinkedIn: @saqlainrazee

License

This project is licensed under the MIT License — free to use, modify, and distribute for any purpose.

Available Tools

36 tools
calibrateA

Calibrate simulated funnel rates to real-world levels.

Two modes:

  • With csv_path: fit against a REAL past campaign's stats. The CSV needs columns sent, opened, clicked, converted (one or more rows). Requires campaign_name for the simulated side of the fit.

  • Without csv_path: anchor the campaign's simulated rates to industry benchmark base rates (a sane default until you have real data).

After calibrating, get_campaign_report shows a calibrated column.

Inputs: channel, csv_path, campaign_name. Returns: result

close_modelA

Unload the currently loaded model and reset the workspace.

Useful when you want to discard pending state (mid-run agents, set parameters, pending plots) and start fresh, or before opening a new model file from disk to make sure cached compilation state isn't carried forward.

Note: this does NOT shut down the JVM or NetLogo workspace — only the model. The next open_model / create_model call will reuse the same JVM (no 30-60s warmup).

Inputs: no named parameters. Returns: result

commandB

Execute a NetLogo command (e.g. 'setup', 'go', 'create-turtles 10').

Inputs: netlogo_command (required). Returns: result

compare_campaign_variantsA

Paired A/B comparison of a campaign's variants (winner, lift, significance). Subset of get_campaign_report for quick checks.

Inputs: campaign_name (required). Returns: result

create_campaignA

Create and save a campaign (one audience x one or more ad/email variants).

Inputs: campaign_yaml (required). Returns: result

create_modelA

Create a new NetLogo model from code and load it.

Inputs: code (required), widgets. Returns: result

download_comses_modelA

Download and safely extract a COMSES model archive.

Standalone "fetch but don't open" tool. Most AI flows should use open_comses_model instead — it subsumes this tool and also loads NetLogo models into the workspace.

Safety guarantees:

  • version="latest" is resolved to a concrete version BEFORE any cache path is computed. Cache dirs are named by the resolved version.

  • HEAD request screens oversize archives before streaming.

  • Stream enforces the byte cap mid-download; overruns abort and delete the partial file.

  • Zip members are validated against path traversal before extraction.

  • Uncompressed total is checked against 2 × cap to reject zip bombs.

  • Extract happens in a temp directory; only a successful extract is moved atomically into the cache. A .comses_complete marker is written on success; future calls only trust cached dirs with the marker.

Inputs: identifier (required), max_mb, version. Returns: result

export_viewA

Export the current NetLogo view as a PNG image.

Returns the image so Claude can see the model visualization.

Inputs: no named parameters.

export_worldA

Export the full world state to a CSV file.

Saves all turtle, patch, and link data. Useful for checkpointing a simulation or analyzing the complete state offline.

Returns the path to the exported CSV file.

Inputs: no named parameters. Returns: result

generate_audienceA

Generate and save a synthetic audience from a YAML spec.

The audience is a frozen, seeded population of personas plus a social network — the same spec always produces the same people, so campaign variants can be tested against an identical audience.

Inputs: spec_yaml (required). Returns: result

get_agent_sampleA

Return a sample of agents with selected variables as a markdown table.

Filling the gap between get_world_state (aggregates only) and hand-crafted report calls. Picks N random agents from the named breed (or all turtles when breed is None) and reports the requested per-agent attributes.

Inputs: n, breed, attributes. Returns: result

get_audienceA

Show a saved audience: spec summary, archetypes, and sample persona cards.

Inputs: name (required), sample. Returns: result

get_campaign_reportA

Generate the pre-flight report for a campaign that has been run.

Includes: funnel with confidence intervals (simulated / calibrated / industry benchmark), segment breakdown, top objections with verbatim quotes, word-of-mouth stats, weak-point diagnosis, and the A/B verdict. Also writes an HTML version with interactive charts.

Inputs: campaign_name (required). Returns: result

get_comses_modelC

Get detailed metadata for a specific CoMSES model.

Inputs: identifier (required). Returns: result

get_patch_dataA

Get patch data as a 2D grid (useful for heatmaps / spatial analysis).

Inputs: attribute (required), max_cells, summary_only. Returns: result

get_world_stateA

Get the current world state: tick count, agent counts, world dimensions.

Returns JSON with ticks, turtle/patch/link counts, and world bounds.

Inputs: no named parameters. Returns: result

interview_personaB

Ask a follow-up question to persona(s) — an on-demand focus group.

Inputs: question (required), audience_name (required), n, persona_id. Returns: result

list_audiencesB

List saved synthetic audiences.

Inputs: no named parameters. Returns: result

list_campaignsA

List saved campaigns.

Inputs: no named parameters. Returns: result

list_experimentsA

List BehaviorSpace experiments saved inside a NetLogo model file.

Reads the <experiments> section of a .nlogox (or .nlogo) without starting a JVM, so it's instant. By default it inspects the model the AI most recently loaded; pass model_path to inspect a specific file.

Returns JSON: {"model_path": ..., "experiments": [<spec>...]} where each spec includes name, repetitions, time_limit, setup_commands, go_commands, metrics, variables (with expanded_size per variable), and total_runs. An empty list means the file has no saved experiments — you can still pass an inline spec to run_experiment.

Inputs: model_path. Returns: result

list_modelsA

List all .nlogo model files in the configured models directory.

Returns a JSON array of {name, path, size_kb} objects.

Inputs: no named parameters. Returns: result

market_infoA

Status of the market-simulation module: LLM config, saved audiences, campaigns, and where artifacts live.

Inputs: no named parameters. Returns: result

open_comses_modelA

Download (or reuse cache), then open a COMSES model ready to use.

This is the single entry point most AI flows should call.

Behavior:

  • Resolves "latest" to a concrete version BEFORE any cache path is computed. The returned resolved_version is what every follow-up read_comses_files call MUST pass — never re-pass "latest" in the same flow, or you risk inspecting a different cache slot than the model you just loaded.

  • If the cache for (identifier, resolved_version) is already complete (has .comses_complete), skips download.

  • Otherwise, downloads + extracts safely (same logic as download_comses_model).

  • If the model is NetLogo, picks one .nlogo / .nlogox per Section 4.4 rules (exactly one → use it; else prefer code/; else prefer .nlogox; else lex-largest relative path — a deterministic tie-breaker, NOT semver-aware).

  • If NetLogo, loads it into the workspace.

  • If not NetLogo, returns structured info for manual follow-up.

Returns JSON with:

  • status: "loaded_netlogo", "not_runnable_in_netlogo", or "no_netlogo_file".

  • resolved_version: concrete version string (never "latest").

  • identifier, title, language, license, cached.

  • extracted_path: absolute path to cached model directory.

  • all_netlogo_files: list of every NetLogo file found.

  • loaded_netlogo_file: the one selected (if any).

  • code_files: source files by extension.

  • odd_doc: ODD / README path, if any.

  • message: short text for the AI to show the user.

Inputs: identifier (required), max_mb, version. Returns: result

open_modelB

Open an existing .nlogo model file.

Inputs: path (required). Returns: result

preview_experimentA

Show the run plan for a BehaviorSpace experiment WITHOUT executing it.

Use this before run_experiment to verify the parameter combinations, total runs, and rough time estimate. Two modes:

  • By name: pass experiment_name (must match a saved experiment in the model file). The other args are ignored.

  • Inline: omit experiment_name and pass metrics + (optionally) variables, repetitions, time_limit, setup_commands, go_commands, stop_condition.

Returns JSON with the resolved spec, total_runs, and a coarse estimated_seconds_lower_bound derived from time_limit × total_runs assuming roughly 1k ticks/s per run (real models are usually slower).

Inputs: metrics, variables, model_path, time_limit, +7 more. Returns: result

read_comses_filesA

Return text contents of source and documentation files from a downloaded COMSES model.

The model MUST already be downloaded by open_comses_model or download_comses_model. If the cache is absent, this tool returns an error telling the AI to call one of those first.

The AI should pass the resolved_version it captured from open_comses_model — not the literal string "latest" — or it risks inspecting a different cache slot than the model it just loaded. When version="latest" is passed, this tool calls the COMSES API to resolve it (so it works standalone) and surfaces the concrete version in the resolved_version field of the response.

Behavior:

  • Files are UTF-8 decoded with errors="replace" so binary junk never aborts the call. Every file that matches extensions is returned as a string (may contain replacement characters for non-text bytes).

  • Files are included in priority order: ODD docs → NetLogo source → other code → other .md/.txt → everything else matching extensions.

  • Total body is capped at max_total_bytes (default 50 KB — sized to fit in a single conversational-LLM tool response). When the cap is hit mid-file, that file is truncated at a line boundary; subsequent files are listed in omitted_files with reason byte_cap_reached. For larger pulls, pass a higher value explicitly.

  • Files matching no extensions filter are listed in omitted_files with reason extension_not_in_filter.

Inputs: identifier (required), version, extensions, max_total_bytes. Returns: result

reportA

Evaluate a NetLogo reporter expression and return its value.

Inputs: reporter (required). Returns: result

run_campaignA

Run a saved campaign against its audience and log every reaction.

Runs every variant x replicate with a PAIRED design (identical audience, reach and network randomness per replicate across variants), so A/B differences are attributable to the creative.

Cognition: personas react via the configured backend — a live local LLM when SYNTH_LLM_MODE=live (Ollama etc.), otherwise the deterministic heuristic model.

Inputs: campaign_name (required), watch, engine. Returns: result

run_experimentA

Run a BehaviorSpace experiment headlessly and return summarized results.

Two ways to specify the experiment:

  • By name — pass experiment_name matching a saved experiment in the loaded model (.nlogox <experiments> section). All other experiment-shape args are ignored.

  • Inline — omit experiment_name. Required: metrics. Optional: variables (list of {"name", "values"} or {"name", "first", "step", "last"}), repetitions, time_limit, setup_commands, go_commands, stop_condition.

Variable shapes (Cartesian product of all expanded values is run for each repetition)::

[{"name": "density", "values": [50, 60, 70]},
 {"name": "growth-rate", "first": 0.1, "step": 0.05, "last": 0.3}]

Long-run controls: - max_total_runs — refuse to start if total_runs exceeds this. - timeout_seconds — kill the launcher after this many seconds. Partial results in the table CSV are preserved. - threads — parallel runs (0 = let NetLogo decide; default ~75% of CPUs).

The launcher runs in a SEPARATE JVM, so the GUI workspace this server is hosting is unaffected. Run before calling this only matters insofar as the model file must be saved on disk (it is, after open_model / create_model / open_comses_model).

Returns JSON with: output_csv, runs, metrics_summary, per_combination, duration_seconds, command, timed_out. The full per-tick data is in output_csv for offline analysis.

Inputs: metrics, threads, variables, model_path, +11 more. Returns: result

run_simulationB

Run the simulation for N ticks and collect reporter data each tick.

Inputs: ticks (required), reporters (required), max_rows, go_command, +1 more. Returns: result

save_modelA

Save NetLogo model code to a .nlogox file in the models directory.

This saves the model so you can open it in the NetLogo desktop app for live visualization with GUI, sliders, and real-time animation.

Inputs: code (required), name (required), widgets. Returns: result

search_comsesC

Search the CoMSES Net computational model library.

Inputs: page, query. Returns: result

server_infoA

Return a snapshot of the running NetLogo MCP server's configuration.

Useful as a no-cost health check for the AI / user — returns the server version, configured paths, GUI mode, currently-loaded model, and whether a NetLogo headless launcher is reachable for BehaviorSpace runs.

No JVM round-trip; this is a pure config / filesystem inspection so it works even before the workspace is fully initialized.

Inputs: no named parameters. Returns: result

set_parameterB

Set a NetLogo global variable / slider / switch value.

Inputs: name (required), value (required). Returns: result

update_modelA

Update the currently loaded model's code in place and reload it.

Prefer this over create_model when iterating on an existing model: the same .nlogox file is rewritten and reloaded, so the NetLogo window stays on one model and the models directory doesn't grow a new file per iteration.

Inputs: code (required), widgets. Returns: result

watch_simulationA

Run the simulation SLOWLY so a human can watch it in the GUI window.

Unlike run_simulation (full speed, returns data), this steps go once per tick with a pause between steps — use it for demos and teaching when the user wants to see the dynamics unfold live. In headless mode it works but there's nothing to watch; prefer run_simulation there.

Inputs: ticks (required), delay_ms, go_command. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 36 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose. For instance, simulation tools are differentiated by use case (run_simulation for data collection, watch_simulation for visual demo, run_campaign for campaign testing, run_experiment for BehaviorSpace). Model management tools are also well-separated. No two tools appear to overlap in functionality.

    Naming Consistency4/5

    The vast majority of tool names follow a consistent verb_noun pattern with underscores (e.g., create_campaign, list_audiences, get_world_state). A few exceptions like market_info and server_info (noun_noun) and calibrate (bare verb) break the pattern slightly, but overall the naming is predictable and readable.

    Tool Count3/5

    With 36 tools, the server covers a broad scope (NetLogo model management, simulation, BehaviorSpace, campaign marketing simulation, COMSES integration). While each tool serves a specific function, the high count may be overwhelming for simple tasks. It is borderline appropriate for the server's ambitious scope, but could benefit from consolidation.

    Completeness4/5

    The tool surface covers the full lifecycle of NetLogo models (create, open, update, close, save), simulation control, state inspection, BehaviorSpace experiments, and campaign simulation. Notable gaps include missing delete operations for models, audiences, and campaigns, which agents may need for cleanup. Otherwise, the set is comprehensive.

    Maintenance

    ActivityInactive
    ResponsivenessLimited data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables AI assistants to discover, install, configure, and manage MCP servers through natural language conversation, automating tedious manual setup across multiple clients.
      11
      MIT
    • A
      license
      Not graded
      quality
      F
      maintenance
      Enables AI agents to communicate, coordinate, and collaborate on complex tasks through a local MCP server.
      8
      Business Source 1.1
    • A
      license
      Not graded
      quality
      D
      maintenance
      An MCP server that enables AI agents to dynamically create and reuse executable skills (Python functions) from natural language descriptions, with automatic skill crystallization and real-time MCP spec updates.
      42
      MIT