🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

dotnet-zap-mcp

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dotnet-zap-mcp

MCP server for OWASP ZAP. Enables AI agents (Claude, Copilot, etc.) to drive ZAP vulnerability scanning via the Model Context Protocol.

Source
nugetNuGet
Version
1.1.0
Version published
Total downloads
567
Maintainers
1
Created
Source

dotnet-zap-mcp

NuGet NuGet Downloads Release

MCP (Model Context Protocol) server for OWASP ZAP. Enables AI agents (Claude, GitHub Copilot, etc.) to drive ZAP vulnerability scanning via MCP.

Features

  • 45 MCP tools for controlling OWASP ZAP (scanning, alerts, spider, ajax spider, context, authentication, reports, etc.)
  • Built-in Docker Compose management (start/stop ZAP with a single tool call)
  • Zero-config setup: auto-generates API keys and extracts Docker assets
  • Works with any MCP-compatible client (Claude Desktop, VS Code, etc.)

Installation

dotnet tool install -g dotnet-zap-mcp

Prerequisites

  • .NET 10 SDK
  • Docker (Docker Engine or Docker Desktop) with docker compose support (for built-in ZAP container management)

Configuration

No configuration needed. The agent calls DockerComposeUp which automatically:

  • Extracts Docker assets to ~/.zap-mcp/docker/
  • Generates a random API key
  • Starts the ZAP container on localhost:8090
  • Waits for ZAP to become healthy

Data persistence

The ZAP container uses two Docker named volumes:

VolumeContainer PathPurpose
zap-home/home/zap/.ZAPZAP settings, contexts, sessions, scan policies (persisted across restarts)
zap-data/zap/wrk/dataShared directory for reports, session files, and context import/export

On the first launch, the template config.xml is copied into zap-home. On subsequent launches, only the API key is updated — any changes made through ZAP (contexts, authentication settings, scan policies, etc.) are preserved.

The zap-data volume contains:

  • reports/ — generated scan reports
  • sessions/ — saved ZAP sessions
  • contexts/ — exported context files

Claude Desktop / Claude Code

Add to your MCP configuration:

{
  "mcpServers": {
    "zap": {
      "command": "zap-mcp"
    }
  }
}

VS Code (Copilot)

Add to .vscode/mcp.json:

{
  "servers": {
    "zap": {
      "command": "zap-mcp"
    }
  }
}

With existing ZAP instance

If you already have a ZAP instance running, pass connection details via environment variables:

{
  "mcpServers": {
    "zap": {
      "command": "zap-mcp",
      "env": {
        "ZAP_BASE_URL": "http://localhost:8090",
        "ZAP_API_KEY": "your-api-key"
      }
    }
  }
}

Available Tools

Docker Management

ToolParametersDescription
DockerComposeUpStart the ZAP container and wait for healthy
DockerComposeDownStop and remove the ZAP container
DockerComposeStatusCheck container status
DockerComposeLogstailGet recent container logs

ZAP Core

ToolParametersDescription
GetVersionVerify ZAP connectivity
GetHostsList recorded hosts
GetSitesList recorded sites
GetUrlsbaseUrlList recorded URLs for a base URL

Spider

ToolParametersDescription
StartSpiderurl, maxChildren, recurse, subtreeOnly, contextNameStart a spider scan to crawl and discover pages
GetSpiderStatusscanIdCheck spider progress (0-100%)
GetSpiderResultsscanIdGet URLs discovered by spider
StopSpiderscanIdStop a running spider scan

Active Scan

ToolParametersDescription
StartActiveScanurl, recurse, inScopeOnly, scanPolicyName, contextIdStart an active vulnerability scan
GetActiveScanStatusscanIdCheck active scan progress (0-100%)
StopActiveScanscanIdStop a running active scan

Passive Scan

ToolParametersDescription
GetPassiveScanStatusCheck passive scan progress (records remaining)

Alerts

ToolParametersDescription
GetAlertsSummarybaseUrlAlert counts by risk level
GetAlertsbaseUrl, start, count, riskIdDetailed alert list with pagination and risk filter

Reports

ToolParametersDescription
GetHtmlReportGenerate HTML scan report
GetJsonReportGenerate JSON scan report
GetXmlReportGenerate XML scan report

Context Management

ToolParametersDescription
GetContextListList all contexts defined in ZAP
GetContextcontextNameGet context details (scope patterns, etc.)
CreateContextcontextNameCreate a new context
RemoveContextcontextNameDelete a context
IncludeInContextcontextName, regexAdd URL include pattern to context scope
ExcludeFromContextcontextName, regexAdd URL exclude pattern to context scope
ImportContextcontextFilePathImport a context file into ZAP
ExportContextcontextName, contextFilePathExport a context to file

Authentication

ToolParametersDescription
GetAuthenticationMethodcontextIdGet the authentication method configured for a context
SetAuthenticationMethodcontextId, authMethodName, authMethodConfigParamsSet authentication method (form-based, JSON-based, script-based, HTTP)
SetLoggedInIndicatorcontextId, loggedInIndicatorRegexSet regex pattern indicating logged-in state
SetLoggedOutIndicatorcontextId, loggedOutIndicatorRegexSet regex pattern indicating logged-out state

Users

ToolParametersDescription
GetUsersListcontextIdList all users for a context
CreateUsercontextId, nameCreate a new user
RemoveUsercontextId, userIdRemove a user
SetAuthenticationCredentialscontextId, userId, authCredentialsConfigParamsSet user credentials (username/password)
SetUserEnabledcontextId, userId, enabledEnable or disable a user

Forced User

ToolParametersDescription
SetForcedUsercontextId, userIdSet the forced user for a context
SetForcedUserModeEnabledenabledEnable or disable forced user mode globally
GetForcedUserStatuscontextIdGet forced user mode status and current forced user

Ajax Spider

ToolParametersDescription
StartAjaxSpiderurl, inScope, contextName, subtreeOnlyStart the Ajax Spider for JavaScript-heavy apps
StartAjaxSpiderAsUsercontextName, userId, url, subtreeOnlyStart the Ajax Spider as a specific user
GetAjaxSpiderStatusGet Ajax Spider status (running/stopped)
GetAjaxSpiderResultsGet Ajax Spider results summary
StopAjaxSpiderStop the Ajax Spider

Typical Workflow

  • Agent calls DockerComposeUp to start ZAP
  • Configure browser/Playwright to use ZAP as proxy (http://127.0.0.1:8090)
  • Browse the target application through the proxy
  • Agent calls StartSpider to crawl the application, then GetSpiderStatus to monitor progress
  • Agent calls GetPassiveScanStatus to wait for passive scan completion
  • Agent calls StartActiveScan on key pages, then GetActiveScanStatus to monitor progress
  • Agent calls GetAlertsSummary and GetAlerts to retrieve vulnerability findings
  • Agent calls GetHtmlReport or GetJsonReport to generate a scan report
  • Agent calls DockerComposeDown when done

Note: ZAP settings (contexts, authentication, scan policies) are persisted in the zap-home Docker volume. You can stop and restart the container without losing configuration.

Try It Out (with the included vulnerable app)

This repository includes an intentionally vulnerable web application for trying out ZAP scanning. The app contains common vulnerabilities (XSS, SQL Injection, CSRF, Open Redirect) so ZAP can detect real findings.

Setup

# Start ZAP and the vulnerable target app
docker compose -f tests/docker/docker-compose.test.yml up -d --build

# Wait until both containers are healthy
docker compose -f tests/docker/docker-compose.test.yml ps

Then configure your MCP client to connect to this ZAP instance:

{
  "mcpServers": {
    "zap": {
      "command": "zap-mcp",
      "env": {
        "ZAP_BASE_URL": "http://localhost:8090",
        "ZAP_API_KEY": "test-api-key-for-ci"
      }
    }
  }
}

The vulnerable app is accessible at http://target from within the Docker network (used by ZAP), and at http://localhost:8080 from your host machine.

Example 1: Quick Scan

Prompt to agent:

Scan http://target for vulnerabilities. Run a spider crawl, wait for the passive scan to finish, then show me the alert summary and generate an HTML report.

Expected tool flow:

GetVersion          → Verify ZAP connectivity
StartSpider         → url: "http://target"
GetSpiderStatus     → Poll until 100%
GetPassiveScanStatus → Poll until 0 records remaining
GetAlertsSummary    → baseUrl: "http://target"
GetAlerts           → baseUrl: "http://target"
GetHtmlReport       → Generate report

ZAP will discover pages like /search, /login, /users, /about, /contact, and the passive scan will report issues such as missing security headers and CSRF vulnerabilities.

Example 2: Authenticated Scan

The /admin page requires login (username: admin, password: password). An authenticated scan lets ZAP access protected pages.

Prompt to agent:

Set up an authenticated scan for http://target. The login form is at /login with fields "username" and "password" (credentials: admin / password). The logged-in indicator is "Welcome, admin". After configuring authentication, spider the site as the authenticated user and run an active scan.

Expected tool flow:

CreateContext                   → contextName: "target-auth"
IncludeInContext                → regex: "http://target.*"
SetAuthenticationMethod         → contextId, authMethodName: "formBasedAuthentication",
                                  authMethodConfigParams: "loginUrl=http://target/login&loginRequestData=username%3D%7B%25username%25%7D%26password%3D%7B%25password%25%7D"
SetLoggedInIndicator            → loggedInIndicatorRegex: "Welcome, admin"
CreateUser                      → contextId, name: "admin"
SetAuthenticationCredentials    → contextId, userId, authCredentialsConfigParams: "username=admin&password=password"
SetUserEnabled                  → contextId, userId, enabled: true
SetForcedUser                   → contextId, userId
SetForcedUserModeEnabled        → enabled: true
StartSpider                     → url: "http://target", contextName: "target-auth"
GetSpiderStatus                 → Poll until 100%
GetPassiveScanStatus            → Poll until 0 records remaining
StartActiveScan                 → url: "http://target"
GetActiveScanStatus             → Poll until 100%
GetAlertsSummary                → baseUrl: "http://target"
GetAlerts                       → baseUrl: "http://target"
SetForcedUserModeEnabled        → enabled: false

With authentication configured, ZAP can access /admin and test for vulnerabilities behind the login.

Example 3: Full Vulnerability Assessment

Prompt to agent:

Perform a full vulnerability assessment of http://target. Crawl the site, run an active scan, then give me a detailed breakdown of all discovered vulnerabilities grouped by risk level.

Expected tool flow:

StartSpider          → url: "http://target", recurse: true
GetSpiderStatus      → Poll until 100%
GetSpiderResults     → Review discovered URLs
GetPassiveScanStatus → Poll until 0 records remaining
StartActiveScan      → url: "http://target", recurse: true
GetActiveScanStatus  → Poll until 100%
GetAlertsSummary     → baseUrl: "http://target"
GetAlerts            → baseUrl: "http://target", riskId: "3" (High)
GetAlerts            → baseUrl: "http://target", riskId: "2" (Medium)
GetAlerts            → baseUrl: "http://target", riskId: "1" (Low)
GetHtmlReport        → Generate final report

The active scan will detect vulnerabilities including:

  • High: SQL Injection (/users?id=), Cross Site Scripting (/search?q=)
  • Medium: CSRF (missing tokens on /login), Open Redirect (/redirect?url=)
  • Low/Informational: Missing security headers, cookie issues, etc.

Cleanup

docker compose -f tests/docker/docker-compose.test.yml down -v

License

MIT

Keywords

mcp

FAQs

Package last updated on 31 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts