NetLogo-MCP

mcp
Security Audit
Pass
Health Pass
  • License — License: NOASSERTION
  • Description — Repository has a description
  • Active repo — Last push 0 days ago
  • Community trust — 10 GitHub stars
Code Pass
  • Code scan — Scanned 12 files during light audit, no dangerous patterns found
Permissions Pass
  • Permissions — No dangerous permissions requested
Purpose
This MCP server acts as a bridge between AI assistants and NetLogo, allowing users to create, run, and analyze agent-based models using natural language commands. It operates NetLogo in a background headless mode to execute simulations and return data or visual snapshots.

Security Assessment
The tool relies on a background Java process to run headless simulations. While the automated code scan passed and found no dangerous patterns, hardcoded secrets, or dangerous permissions, the tool does inherently execute code and external processes. The overarching risk of running dynamically generated or provided simulation scripts is present, but given the contained nature of its intended use, the overall risk is rated as Low.

Quality Assessment
The project appears to be a recently created, active endeavor by a university student, with the last push occurring just today. It features a solid setup, including continuous integration (CI), type checking (mypy), and linting (Ruff). However, the repository lacks a formally recognized open-source license (currently marked as NOASSERTION), which means strict legal usage and distribution rights are undefined. It has garnered 10 stars, showing a small but present level of community interest.

Verdict
Safe to use, but keep in mind the project's academic origins and lack of a formal license if planning for commercial or widespread distribution.
SUMMARY

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

README.md

NetLogo MCP

CI Python 3.10+ Ruff mypy License

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 — any tool that supports MCP.

Why NetLogo MCP?

As an AI student in my 6th semester, I was taking an Agent-Based Modeling course that heavily uses NetLogo. When I discovered MCP (Model Context Protocol) and how it lets AI assistants interact with external tools, I immediately searched for a NetLogo MCP server. Nothing existed — not for NetLogo, not for any agent-based modeling platform.

So I built one.

The idea is simple: instead of manually writing NetLogo code, clicking buttons, and tweaking sliders, you just 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." "What happens if we double the wolf reproduction rate?" The AI handles the code, runs the simulation, and shows you the results — all through conversation.

This bridges the gap between AI-powered assistance and agent-based modeling, making NetLogo accessible to anyone who can describe what they want to simulate.

How It Works

You (in any MCP client) → AI Assistant → MCP Protocol → NetLogo MCP Server → NetLogo (headless JVM)

The server runs NetLogo in headless mode (no GUI) as a background Java process. Your AI sends commands through the MCP protocol, NetLogo executes them, and results come back — including simulation data, agent counts, and exported view snapshots you can see right in the chat.

Features

  • Create Models from Code — Write NetLogo procedures, the AI wraps them in the proper format and loads them
  • Run Simulations — Execute setup, go, or any custom command with full control
  • Collect Data — Run N ticks and collect reporter data as markdown tables
  • Visual Snapshots — Export the current world view as PNG images, visible inline in chat
  • Parameter Control — Set globals, sliders, and switches programmatically
  • World Inspection — Get tick counts, agent counts, world dimensions, and patch data grids
  • Model Library — Browse and load .nlogo/.nlogox files from a models directory
  • Built-in References — NetLogo primitives and programming guide as MCP resources
  • Prompt Templates — Pre-built workflows for model analysis, ABM creation, and parameter sweeps
  • Live GUI Mode — Optional: open a real NetLogo window to watch simulations run in real-time

Tools

Tool Description
create_model(code) Create a new model from NetLogo code
open_model(path) Load an existing .nlogo/.nlogox model
command(netlogo_command) Execute a NetLogo command (setup, go, etc.)
report(reporter) Evaluate a reporter expression
run_simulation(ticks, reporters) Run N ticks, collect data as a table
set_parameter(name, value) Set a global variable / slider / switch
get_world_state() Get tick count, agent counts, world dimensions
get_patch_data(attribute) Get patch data as a 2D grid (for heatmaps)
export_view() Export current view as PNG image
save_model(name, code) Save model to file — open in NetLogo app for live viewing
export_world() Export full world state to CSV for offline analysis
list_models() List model files in models directory

Resources

URI Description
netlogo://docs/primitives NetLogo primitives quick reference
netlogo://docs/programming NetLogo programming guide
netlogo://models/{name} Read model source code

Prompts

Prompt Description
analyze_model(model_name) Step-by-step guide to understand an existing model
create_abm(description, agents, behaviors) Build a new ABM from scratch
parameter_sweep(parameter, min, max, steps, metric) Systematic parameter exploration

Prerequisites

Installation

# Clone the repository
git clone https://github.com/Razee4315/NetLogo_MCP.git
cd NetLogo_MCP

# Install the package
pip install -e .

Configuration

Copy .env.example to .env and set your paths:

NETLOGO_HOME=C:/Program Files/NetLogo 7.0.3
JAVA_HOME=C:/Program Files/Eclipse Adoptium/jdk-25.0.2.10-hotspot

Environment Variables

Variable Required Description
NETLOGO_HOME Yes Path to your NetLogo installation directory
JAVA_HOME No Path to your JDK directory (auto-detected if not set)
NETLOGO_MODELS_DIR No Directory for model files (defaults to ./models)
NETLOGO_GUI No "true" for live GUI window, "false" for headless (default)
NETLOGO_EXPORTS_DIR No Directory for exported views/worlds (defaults to ./exports)

Client Setup

This server uses the MCP stdio transport, which is supported by all major AI coding tools. Pick your tool below.

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",
        "NETLOGO_MODELS_DIR": "C:/path/to/NetLogo_MCP/models"
      }
    }
  }
}

Restart Claude Code and verify with /mcp.

Claude Desktop

Add to claude_desktop_config.json:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.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"
      }
    }
  }
}
Cursor

Add to .cursor/mcp.json (project) or ~/.cursor/mcp.json (global):

{
  "mcpServers": {
    "netlogo": {
      "type": "stdio",
      "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"
      }
    }
  }
}
VS Code (Copilot)

Add to .vscode/mcp.json:

{
  "servers": {
    "netlogo": {
      "type": "stdio",
      "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"
      }
    }
  }
}

Note: VS Code uses "servers" instead of "mcpServers".

Windsurf

Add to ~/.codeium/windsurf/mcp_config.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"
      }
    }
  }
}
Cline

Add via Cline settings UI, or edit cline_mcp_settings.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"
      },
      "disabled": false
    }
  }
}
Roo Code

Add to .roo/mcp.json (project) or via VS Code settings:

{
  "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"
      },
      "disabled": false
    }
  }
}
Continue

Create .continue/mcpServers/netlogo.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"
      }
    }
  }
}

Note: MCP tools only work in Continue's Agent mode.

Zed

Add to Zed settings.json:

{
  "context_servers": {
    "netlogo": {
      "command": {
        "path": "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"
        }
      }
    }
  }
}

Note: Zed uses "context_servers" with a nested "command" object.

OpenCode

Add to opencode.json (project root) or ~/.config/opencode/opencode.json:

{
  "mcp": {
    "netlogo": {
      "type": "local",
      "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"
      }
    }
  }
}

Note: OpenCode uses "mcp" as the root key and "type": "local" for stdio.

Headless vs GUI Mode

Mode NETLOGO_GUI What Happens
Headless (default) "false" No window. Fast. See snapshots via export_view in chat.
Live GUI "true" Opens a NetLogo window. Watch simulations run in real-time.

Note: GUI mode runs NetLogo on a separate thread so the MCP server stays responsive. The mode is set at startup — to switch, change the env var and restart your client.

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 susceptible, infected, and
  recovered agents on a grid.

Tech Stack

  • Server: FastMCP (Python)
  • NetLogo Bridge: pynetlogo + JPype
  • Runtime: NetLogo headless JVM
  • Transport: MCP stdio protocol

Project Structure

NetLogo_MCP/
├── pyproject.toml              # Package config, linting & type check settings
├── smithery.yaml               # Smithery registry configuration
├── .mcp.json                   # Claude Code MCP configuration
├── .pre-commit-config.yaml     # Pre-commit hooks (ruff, mypy)
├── .github/workflows/ci.yml    # CI pipeline (lint, type check, test)
├── CHANGELOG.md                # Version history
├── src/
│   └── netlogo_mcp/
│       ├── server.py           # FastMCP app, stdout protection, lifespan
│       ├── tools.py            # All 12 tools
│       ├── resources.py        # 3 resources (docs + model source)
│       ├── prompts.py          # 3 prompts (analyze, create, sweep)
│       ├── config.py           # Environment variable loading
│       ├── py.typed            # PEP 561 type marker
│       └── data/
│           ├── primitives.md   # NetLogo primitives reference
│           └── programming_guide.md
├── models/                     # Drop .nlogo/.nlogox files here
└── tests/
    ├── conftest.py             # Mock fixtures (no JVM needed)
    ├── test_tools.py
    └── test_resources.py

Running Tests

# Run tests
pytest tests/ -v

# Run tests with coverage
pytest tests/ -v --cov=netlogo_mcp --cov-report=term-missing

Tests use mock fixtures — no Java/NetLogo installation needed to run them.

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
NetLogo syntax errors Consult the netlogo://docs/primitives resource
Server won't connect Run netlogo-mcp manually in terminal to see error output

Contributing

Contributions are welcome! This is an open project — feel free to open issues, suggest features, or submit pull requests. See CONTRIBUTING.md for details.

Listed on

MCP Badge

Author

Saqlain Abbas
Email: [email protected]
GitHub: @Razee4315
LinkedIn: @saqlainrazee

License

This project is source available with restricted commercial use:

  • Personal use — Free to use, copy, and modify
  • Commercial use — Requires written permission from the author

See the LICENSE file for full details.

Reviews (0)

No results found