MCPcopy Create free account
hub / github.com/DMontgomery40/pentest-mcp

github.com/DMontgomery40/pentest-mcp @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
70 symbols 180 edges 6 files ⚖ AGPL-3.0 0 documented · 0% ● updated 35d ago★ 150

Browse by type

⨍ Functions 59◇ Types & classes 11
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Pentest MCP

smithery badge Verified on MseeP MseeP.ai Security Assessment Badge

Pentest MCP is a TypeScript MCP server for authorized security assessments. It gives a human researcher or a tool-using assessment agent one scoped interface for discovery, validation, capture, credential checks, local audit, evidence retrieval, and report preparation. Each active tool call is tied to an engagement and a durable record. The server checks the declared targets and time window; the researcher verifies findings before publication.

October 2026 workflow

  1. Create an engagement from signed authorization and rules of engagement, then save the assessment plan. The operator chooses a stable engagementId.
  2. A researcher or fresh Codex process in the managed assessment container connects to the Pentest MCP server. It sees the complete catalog, while the plan's exact allowedToolNames list permits only selected calls. Active tools also pass the engagement target and time gate.
  3. Review recordId values and correlated scope decisions with listEngagementRecords and getEngagementRecord. Records persist across restarts. Import external research with recordResearchActivity; the import does not replace MCP tool use.
  4. Draft a report from the complete evidence ledger, inspect candidate findings against source records, and publish only analyst-verified findings. Retrieve Markdown or JSON later with getClientReport.

The declared-target check is an operational guardrail, not a complete network boundary. DNS changes, redirects, Nmap scripts, Nuclei templates, and other third-party tool behavior can create secondary traffic. Review tool configuration and keep network controls aligned with the engagement's rules.

Agentic assessment uses the MCP tools

The assessment stage is a tool-using agent session. runAgentAssessment supports local Codex or Claude in a dedicated account profile, Codex in a pinned container, a loopback OpenAI-compatible server such as llama.cpp or Ollama, and OpenRouter. CLI workers receive a locked, single-engagement Pentest MCP server and discover the full catalog. Guarded API models receive only the exact plan allowlist intersected with the worker catalog. Every requested action still reaches the same worker-side plan, target, parent-status, and time checks before a handler starts. Optional hostileModelProtection adds duplicate-action, token-accounting, and finish-reason circuit breakers and defaults to false. An interrupted run with a durable start receipt and no terminal receipt blocks replay; reconcileAgentAssessment requires an operator to confirm that the prior process stopped, records reviewer and rationale, and revokes the prior worker scope when it is still available. The returned toolCounts, importedRecordIds, and importMapRecordId identify recorded actions and imported evidence. A run with no successful assessment-tool call fails.

draftAssessmentReport is a later, context-quarantined report-writing step; a draft alone does not show that Pentest MCP helped the assessment. OpenAI, Anthropic, OpenRouter, OpenAI-compatible, local Codex, local Claude, container Codex, and configured SSH profiles can draft from a bounded evidence packet without scanner tools. local-agent accepts self-hosted CLI profiles and loopback OpenAI-compatible profiles while rejecting hosted providers before context is sent. The guarded model guide gives llama.cpp and OpenRouter profiles, enforced stop conditions, audit fields, and hostile-model deployment boundaries. The container assessment guide gives CLI profile fields, real acceptance command, and isolation limits. The agentic workflow covers scope, evidence review, Daybreak/Glasswing access, and Faxbot planning.

Release acceptance uses scripts/run-real-acceptance.mjs. It has no default target or authorization and refuses to pass unless installed Nmap and ProjectDiscovery HTTPX create successful evidence records. With --profile, the managed agent must invoke both through Pentest MCP. With --report-profile, a separate report context must produce the saved draft. Test doubles remain in automated tests only and are never shipped as acceptance receipts.

Quick start

Requires Node.js 22.19.0 or newer and the host binaries for the tools you intend to use. The Docker image includes the listed tools; native installations must provide them in PATH.

npm install -g pentest-mcp
pentest-mcp

Stdio is the default for local MCP clients. pentest-mcp inspector starts the bundled MCP Inspector against this server over stdio; Inspector flags can be forwarded, for example pentest-mcp inspector --help.

Set PENTEST_DATA_DIR to choose the local evidence directory. Otherwise the server uses $XDG_DATA_HOME/pentest-mcp when that variable is set, or ~/.pentest-mcp. Evidence and report files are stored with private directory and file permissions. Treat raw outputs, hashes, captured traffic, and reports as client-sensitive data; control access, retention, and backups accordingly.

Register an engagement

Call createEngagement before scanning. Use dates, targets, and references from the actual signed authorization; the values below are illustrative.

{
  "tool": "createEngagement",
  "arguments": {
    "engagementId": "client-2026-10",
    "authorizationReference": "Signed SoW section 4, approved 2026-10-24",
    "notBefore": "2026-10-25T09:00:00-06:00",
    "expiresAt": "2026-10-26T18:00:00-06:00",
    "allowedTargets": ["app.example.com", "192.0.2.0/28"],
    "excludedTargets": ["192.0.2.7"],
    "testingWindows": [
      {
        "start": "2026-10-25T09:00:00-06:00",
        "end": "2026-10-25T17:00:00-06:00"
      }
    ]
  }
}

Allowed targets accept exact hosts, CIDRs, wildcard subdomains, and HTTP(S) URL prefixes. Exclusions take precedence. All timestamps need an explicit timezone. getEngagement and listEngagements inspect stored registrations. closeEngagement revokes later execution, aborts managed assessments running in the same server process, and causes a separate managed runner to stop when it observes the parent registry closure.

Run and review

Use the same engagementId for active tools. The default non-root container supports a TCP connect scan; SYN and OS detection need additional privileges that are not granted by default.

{
  "tool": "nmapScan",
  "arguments": {
    "engagementId": "client-2026-10",
    "target": "app.example.com",
    "scanTechnique": "Connect",
    "serviceVersionDetection": true
  }
}

A successful tool response includes a recordId for its stored evidence. Retrieve only the records you need:

{
  "tool": "listEngagementRecords",
  "arguments": {
    "engagementId": "client-2026-10",
    "limit": 50
  }
}

listEngagementRecords returns summaries and accepts limit and offset for paging through older records. getEngagementRecord takes both engagementId and recordId and returns stored evidence when permitted. Credential tools return counts and output digests. New unauthenticated Gobuster/Nikto records retain private scanner output and findings for owner-scoped reads; older scanner records remain redacted. Nmap XML and bounded ffuf/Nuclei machine output are retained alongside summaries. A record's outcome is succeeded, failed, or cancelled, with a start time and duration when tracked; subprocess failures create an audit record rather than a successful scan result. A preflight scope refusal starts no command. For authenticated HTTP, engagement and evidence access is scoped to the verified token owner; stdio data is local to the server installation.

Give the agent a client-specific plan

saveAssessmentPlan stores objectives, human-readable allowed and prohibited methods, exact allowedToolNames, data handling, stop conditions, report audience, work ownership, and model data policy as a versioned evidence record. getAssessmentPlan reads the latest version. The managed worker receives the full catalog but the server rejects any call omitted from allowedToolNames before its handler runs, leaving a failed audit receipt. When a plan exists, its allowlist also gates direct manual MCP calls to the 14 assessment methods; denials are audited before the handler or command runs. Direct calls on legacy engagements without a plan keep their previous behavior and still pass engagement scope gates. This plan cannot expand createEngagement targets or time. An external-client plan needs a provider client-work approval reference before model drafting, and no-model permits only the deterministic draft. See the plan schema and example.

After a plan with modelDataPolicy: "local-agent" or "approved-provider" and nonempty allowedToolNames is recorded, launch the tool-using run:

{
  "tool": "runAgentAssessment",
  "arguments": {
    "engagementId": "client-2026-10",
    "profileId": "daybreak-cli-assessment",
    "timeoutSeconds": 900
  }
}

The response includes a run ID, status, model, toolCounts, imported evidence IDs, importMapRecordId, and an ID for unreviewed model output. If the model, MCP child, or an assessment tool fails, inspect the retained failure and any imported records before retrying. If only a start receipt exists after a process interruption, verify that the old process stopped and call reconcileAgentAssessment with that run ID, the reviewer identity, and the reason for the decision. The server will not silently replay the run. A process that finishes without a successful assessment-tool call is rejected; its bounded output is retained privately with a failed outcome and linked hash for diagnosis, never as verified finding evidence. A completed agent process does not make its observations confirmed findings. The worker blocks engagement creation, closure, plan changes, recursive assessment launches, reconciliation, and report publication.

Ask for useful wordlist clues

Call generateWordlist with engagementId and omit baseWords when the MCP client supports form elicitation. The server asks the authorized operator for known names and aliases, organization or product terms, dates, location or address terms, and prefix or suffix patterns. They may skip unknown categories or decline. The prompt excludes current passwords and patient data. If the client lacks form elicitation, the tool returns the questions so the assistant can ask and retry with explicit baseWords, dates, locationWords, and customPatterns. The private wordlist record retains input counts and a SHA-256 digest rather than the supplied words or a sample of the list. Wordlist creation does not authorize password attempts; hydraBruteforce, runJohnTheRipper, and runHashcat must also fit the engagement methods.

Produce an evidence-backed report

createClientReport requires a registered engagement, client, title, assessment type, summary, and explicit recordIds. Use [] only when no tool evidence should be attached. Select the evidence records for each report deliberately; the server never silently chooses a limited subset. Audit, scope-gate, and report-workflow records cannot be attached as vulnerability evidence. Supply analyst-confirmed findings with severity, impact, remediation, verifier, timestamp, and evidence references. Scanner output remains an observation until a researcher verifies it. A report with an empty findings array explicitly says no analyst-verified vulnerability findings were included.

{
  "tool": "createClientReport",
  "arguments": {
    "engagementId": "client-2026-10",
    "client": "Example Client",
    "title": "External Assessment",
    "assessmentType": "External network",
    "summary": "Assessment activity and verified outcomes are summarized below.",
    "recordIds": [],
    "findings": [],
    "recommendations": ["Review the evidence index and validate remediation with a retest."],
    "methodology": "Authorized, scoped enumeration and manual verification.",
    "limitations": ["The example has no attached scan records."]
  }
}

Replace recordIds with IDs from this engagement and add verified findings only after manual review. Each finding can include evidenceRecordIds, externalEvidence, affected assets, reproduction steps, references, CWE, CVSS vector, and retest status. Optional scopeOfWork text adds report context; it does not change executable scope. The report includes scope details from the registered engagement, verified severity counts, a completeness checklist, an evidence index with raw-output SHA-256 hashes, and limitations. Raw scanner output is kept in private evidence records rather than copied into the client-facing Markdown.

listClientReports takes engagementId. getClientReport takes engagementId and reportId, with format set to markdown or json. The Markdown report is also available as the mcp://pentest/clientReport/{reportId} resource.

For an agent-assisted report, call draftAssessmentReport after assessment records exist. Omit profileId for a deterministic evidence inventory or select a configured draft profile for model-written observations. local-agent permits CLI profiles and loopback openai-compatible profiles; approved-provider permits a configured API or CLI profile, including OpenRouter. Both receive bounded scope, plan and evidence summaries and may suggest unverified candidates. Under metadata-only, the model receives structural

Extension points exported contracts — how you extend this code

browse all types & interfaces →

Core symbols most depended-on inside this repo

browse all functions →

Shape

Function 59
Interface 8
Class 2
Enum 1

Languages

TypeScript100%

Modules by API surface

src/index.ts46 symbols
test/mcp-behavior.test.mjs10 symbols
src/node-nmap.d.ts5 symbols
src/logger.ts5 symbols
test-multi-transport.js2 symbols
src/types.ts2 symbols

For agents

$ claude mcp add pentest-mcp \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page