Skip to main content

netexec-mcp

An MCP server that plugs NetExec (nxc) into an AI agent: Claude Code, Cursor, opencode, or your own. The agent calls NetExec as one of its tools, inside the scope and mode you set. For authorized security testing only.

Recon mode: NetExec-MCP recon mode

Full mode: NetExec-MCP gmsa mode

Why

Instead of letting the agent type nxc commands in a shell:

  • Fewer tokens. The agent sees 5 small meta-tools (about 1k tokens) and looks up the tool it needs, instead of parsing the nxc help to work out the right command. Small local models fit, and big ones cost less.
  • Scope enforced. Every target is checked against NXC_SCOPE. Anything outside is refused.
  • Actions under control. NXC_MODE decides what the agent may run, from suggesting commands only to full exploitation.
  • Structured results. Shares, hashes and admin rights come back as JSON fields, not terminal text.
  • Audit log. Every command, whether it ran, was previewed or was refused, is logged.

It covers the 10 nxc protocols and NetExec's -M modules. SMB, LDAP, WinRM, MSSQL, SSH, RDP and WMI are tested against a live Active Directory lab; FTP, NFS and VNC are unit-tested only.

Install

NetExec is not a dependency: install it first (installation guide). Then, with Python 3.10 or later:

pipx install netexec-mcp
# or
uv tool install netexec-mcp

On startup the server runs nxc --version and refuses to start if NetExec is not found. If nxc is not on your PATH, set NXC_COMMAND, e.g. NXC_COMMAND="uv run --no-sync --directory /opt/NetExec netexec".

From source

git clone https://github.com/mpgn/NetExec-mcp && cd NetExec-mcp
uv sync
NXC_SCOPE=10.0.0.0/24 uv run netexec-mcp

In your agent's config, launch it with uv and the arguments run --directory /path/to/NetExec-mcp netexec-mcp (see .mcp.json.example). If NetExec also runs from a source checkout, keep --no-sync in NXC_COMMAND: without it, each nxc call re-syncs NetExec's environment under a lock and parallel calls run one after another. Run uv sync in the NetExec checkout after each update.

Configure

The server is configured with environment variables, passed by your agent (see below).

Variable What it does Default
NXC_SCOPE Required. Allowed targets: IPs, CIDRs, ranges or hostnames, comma-separated. none
NXC_MODE suggest, recon, loot or full (see below). recon
NXC_AUDIT_LOG Path of the audit log file. Strongly recommended. none
NXC_COMMAND How to launch NetExec, if it is not on your PATH. nxc or netexec on PATH
NXC_PROTOCOLS Restrict the tools to some protocols, e.g. smb,ldap. all 10 protocols
NXC_PATH NetExec home directory (config and workspace databases). ~/.nxc

Each mode includes the previous one:

Mode What the agent can run
suggest Nothing. Tools return the nxc command they would run, for you to run.
recon (default) Read-only enumeration: hosts, shares, users, groups, policies...
loot + credential collection: SAM, LSA, NTDS, GPP, Kerberoasting, AS-REP roasting.
full + everything else: command execution, uploads, spraying, coercion, exploits.

Scope and mode are read once at startup. The agent cannot change them; to raise them, edit the config and restart the server. Every setting is listed in the reference below.

Plug it into your agent

Claude Code

claude mcp add netexec \
  -e NXC_SCOPE=10.0.0.0/24 \
  -e NXC_MODE=recon \
  -e NXC_AUDIT_LOG=~/.netexec-mcp/audit.jsonl \
  -- netexec-mcp

Check with claude mcp list, or /mcp inside Claude Code.

Cursor, Claude Desktop

For Cursor, add this to ~/.cursor/mcp.json (all projects) or .cursor/mcp.json (one project). For Claude Desktop, open Settings > Developer > Edit Config, add it to claude_desktop_config.json and restart.

{
  "mcpServers": {
    "netexec": {
      "command": "netexec-mcp",
      "env": {
        "NXC_SCOPE": "10.0.0.0/24",
        "NXC_MODE": "recon",
        "NXC_AUDIT_LOG": "~/.netexec-mcp/audit.jsonl"
      }
    }
  }
}

Desktop apps may not see your shell PATH. If the server does not start, use the absolute path of netexec-mcp (which netexec-mcp) and set NXC_COMMAND to the full path of nxc.

opencode + Ollama (local)

Add to opencode.json, next to your Ollama provider:

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "netexec": {
      "type": "local",
      "command": ["netexec-mcp"],
      "environment": {
        "NXC_SCOPE": "10.0.0.0/24",
        "NXC_MODE": "recon",
        "NXC_AUDIT_LOG": "~/.netexec-mcp/audit.jsonl"
      }
    }
  }
}

Use a model with solid tool calling (Qwen3 14B is a good start) and at least 32k tokens of context.

Your own agent (Python)

Any MCP SDK works. With Pydantic AI (pip install pydantic-ai):

from fastmcp.client.transports import StdioTransport
from pydantic_ai import Agent
from pydantic_ai.mcp import MCPToolset

netexec = MCPToolset(
    StdioTransport(
        command="netexec-mcp",
        args=[],
        env={"NXC_SCOPE": "10.0.0.0/24", "NXC_MODE": "recon"},
    ),
    include_instructions=True,  # give the agent the server's instructions (off by default)
)

# Any Pydantic AI model works. "ollama:" reads OLLAMA_BASE_URL (e.g. http://localhost:11434/v1)
agent = Agent("ollama:qwen3:14b", toolsets=[netexec])

result = agent.run_sync("Which hosts in scope don't require SMB signing?")
print(result.output)

Each action takes about two tool calls (find the tool, then run it). If your agent caps the number of steps per answer, raise it.

Use it

Ask the agent to "run a NetExec health check": it should answer with your NetExec version. Then give it tasks:

  • "Which hosts in 10.0.0.0/24 don't require SMB signing?"
  • "With robin / Summer2026!, which shares can I write to?"
  • "Kerberoast the domain with these credentials." (needs loot)
  • "Dump LSA on 10.0.0.12 and see if anything lets me move further." (needs loot, full to run commands)

Before you start:

  • One NXC_PATH per engagement. The agent can read credentials stored in NetExec's workspace database, including ones from a previous engagement.
  • Cloud models see your results. Usernames, hashes and hostnames are sent to the model provider. Use a local model if the rules of engagement require it.
  • For authorized testing only.

Learn more

Reference

Configuration (env vars)

Variable What it does Default
NXC_SCOPE Allowed targets (IPs, CIDRs, ranges, hostnames), comma-separated. Fail-closed: with no scope, every target is refused. none
NXC_MODE suggest, recon, loot or full. recon
NXC_COMMAND How to launch NetExec, parsed like a shell command, e.g. uv run --no-sync --directory ~/NetExec netexec. nxc or netexec on PATH
NXC_PROTOCOLS Protocols to expose, comma-separated. all 10
NXC_TOOL_MODE dynamic: the agent sees 5 meta-tools and looks up the others. static: every tool is listed up front, which costs tens of thousands of tokens of context; use it only with a large-context model that should skip the lookup. dynamic
NXC_MODULE_CATALOG Where dynamic mode finds the -M modules: static (the list shipped with the server) or live (nxc <proto> -L at startup, for custom modules or an nxc newer than the list). The mode gate always reads the installed nxc. static
NXC_TIMEOUT Timeout of one call, in seconds. 300
NXC_MAX_TARGETS Maximum targets in one call. 256
NXC_AUDIT_LOG Audit log, one JSON line per command: run, previewed or refused. none
NXC_LOG_DIR One nxc log file per executed call, with the full raw output even when the agent's view of it is capped. Holds secrets: files are created 0600. none
NXC_PATH NetExec home (nxc.conf, workspace databases). Passed on to nxc, so the server reads where nxc writes. Use one per engagement. ~/.nxc
NXC_WORKSPACE Workspace the workspace_* readers look in. Read side only: nxc keeps writing to the workspace set in its nxc.conf. nxc.conf's, else default
NXC_DOWNLOADS_DIR Where retrieved files land (e.g. smb_get_file) when the call gives no absolute path. <NXC_PATH>/downloads

Resources

The server also publishes guides and data as MCP resources:

  • netexec://guide/operating-modes, netexec://guide/auth, netexec://guide/workflows (including the cross-protocol gMSA chain), netexec://guide/workspace, netexec://guide/safety
  • netexec://catalog/tools: the tool inventory
  • netexec://workspace/credentials, /admins, /loggedin, /hosts: the NetExec workspace database, like the workspace_* tools

Safety

Every command goes through one checkpoint before it runs: the scope allowlist (fail-closed), the mode gate, the target cap and the timeout. Each command is written to the audit log, whether it ran, was previewed or was refused. nxc is run as an argument list, never through a shell, and NetExec is never imported as a library.

nxc version

The tools and their flags are checked against nxc 1.5.1 "Yippie-Ki-Yay", commit 6965632b (2026-10-31, build 1174). Check yours with nxc --version. NetExec moves fast and sometimes renames or removes flags, so a much newer or older nxc may reject some of them.

Metadata

Release files for netexec-mcp 1.0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for netexec-mcp 1.0.8
File Size Uploaded Provenance Actions
netexec_mcp-1.0.8.tar.gz 230.4 kB With provenance Details for netexec_mcp-1.0.8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for netexec-mcp 1.0.8
File Interpreter ABI Platform Actions
netexec_mcp-1.0.8-py3-none-any.whl Python 3 none any Details for netexec_mcp-1.0.8-py3-none-any.whl

Total release size: 378.9 kB

Release files / netexec_mcp-1.0.8.tar.gz

Download URL netexec_mcp-1.0.8.tar.gz
Size 230.4 kB
Tags Source
SHA-256 checksum
How to use checksums
fa10196abe37d42661a97f56061f205a4a3dfb5f5749b148670973c15e87c940
BLAKE2b-256 checksum
How to use checksums
d08befbb17bd536b66c7bbcaea3ce773ace4edbbc88df4134d85cf3870861d24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Release files / netexec_mcp-1.0.8-py3-none-any.whl

Download URL netexec_mcp-1.0.8-py3-none-any.whl
Size 148.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
91ded93c6e42210b0a857042a3f1874d9c195520c50262cd920c1910076e894d
BLAKE2b-256 checksum
How to use checksums
15add157429ba0e9606ea4ac536df6b39399a208dd55779ff7d131531e856b7b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Security for netexec-mcp 1.0.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for netexec_mcp-1.0.8.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page