Skip to content

MCP and Claude skill

MCP (Model Context Protocol) is a protocol that lets an AI client call tools provided by another program. This local stdio server lets Claude ask Phronesis to rank NSE scripts from existing Nmap XML. It returns suggestions and a printed command, without running Nmap or sending scan traffic.

Only tool: suggest_scripts(xml, top_k=5, personal_dir=None); xml is the XML text, not a file path.

Installation and quick test

From the repository root, use a Python environment that already runs Phronesis; see Installation. Install mcp in that same environment, then check the server:

python -m pip install mcp
python -m py_compile integrations/mcp/phronesis_mcp.py
python -m pytest tests/test_mcp_suggest.py

Start the stdio server manually:

python integrations/mcp/phronesis_mcp.py

Waiting for a client on stdin is normal; stop this manual check with Ctrl+C before connecting Claude. The client starts its own server process.

Connect Claude

Claude Code: project .mcp.json

Place this file at the repository root and start Claude Code there. python must resolve to the environment containing mcp. Claude Code expands the environment variable; the empty fallback permits use without personal scripts, and any supplied personal_dir is then refused.

{
  "mcpServers": {
    "phronesis": {
      "command": "python",
      "args": [
        "integrations/mcp/phronesis_mcp.py"
      ],
      "env": {
        "PHRONESIS_PERSONAL_ROOT": "${PHRONESIS_PERSONAL_ROOT:-}",
        "PHRONESIS_DEVICE": "cpu"
      }
    }
  }
}

Claude Code: command line

Alternative to editing .mcp.json, checked against claude mcp add --help in Claude Code 2.1.333. This writes project configuration; run it only when you want to register the connector. PHRONESIS_PERSONAL_ROOT, if set before starting Claude, is inherited by the server.

claude mcp add --transport stdio --scope project phronesis --env PHRONESIS_DEVICE=cpu -- python integrations/mcp/phronesis_mcp.py

Claude Desktop

Open Settings > Developer > Edit Config. On Windows the file is %APPDATA%\Claude\claude_desktop_config.json; on macOS, ~/Library/Application Support/Claude/claude_desktop_config.json. Merge this entry into mcpServers, replace all placeholder paths, then fully restart Desktop. The interpreter must contain mcp; PHRONESIS_PERSONAL_ROOT must be an existing parent directory of the personal script folders.

{
  "mcpServers": {
    "phronesis": {
      "command": "C:\\CHEMIN\\VERS\\python.exe",
      "args": [
        "C:\\CHEMIN\\VERS\\phronesis-nmap-selector\\dev\\integrations\\mcp\\phronesis_mcp.py"
      ],
      "env": {
        "PHRONESIS_PERSONAL_ROOT": "C:\\CHEMIN\\VERS\\nse-personnels",
        "PHRONESIS_DEVICE": "cpu"
      }
    }
  }
}

Install the skill

Copy the whole integrations/claude/phronesis/ folder to ~/.claude/skills/phronesis/ for all your Claude Code projects, or to .claude/skills/phronesis/ at a project's root for that project. The resulting file must be SKILL.md inside that folder. These are Claude Code locations; Desktop skill loading was not tested on this version.

The skill requires explicit agreement for each proposed Nmap command before running it. Installing the connector does not install the skill.

Example

With the two demo scripts from tests/test_mcp_suggest.py installed in my-nse under the configured root, ask:

Read examples/quickstart-scan.xml and send its XML content to suggest_scripts with top_k=6 and personal_dir="my-nse". Show the ranking, sources and exact returned command. Do not execute Nmap.

Expected CPU reference for 443/tcp HTTPS, probabilities rounded to three decimals:

Script Probability Source
http-title 0.331 official
http-server-header 0.271 official
http-methods 0.177 official
http-internal-admin-panel 0.099 personal
http-robots.txt 0.043 official
http-api-version 0.039 personal

Printed proposal, not an instruction to execute:

nmap -Pn -sV -p 443 --script http-title 192.0.2.10

Claude must say that nothing was executed. Probabilities compare candidates; they are not calibrated confidence. GPU values may differ slightly. my-nse is a demo setup, not a folder shipped at the repository root; omit personal_dir when you have no personal scripts.

Scope and configuration

  • XML limit: 2 MiB (2,097,152 UTF-8 bytes); subprocess timeout: 120 s.
  • top_k: integer 1 to 14, default 5; candidate cap: 14 per port.
  • The tool returns results, with host, port, protocol, service, ranking and command; command may be null when the CLI proposes no command.
  • It does not scan, execute NSE, accept an XML file path or read personal scripts outside the configured root.
Variable Purpose / default
PHRONESIS_PERSONAL_ROOT Allowed root for personal_dir; unset means refusal. Relative personal paths resolve under it; resolved paths outside it are refused.
PHRONESIS_CLI CLI executable or .py path; default: repository nmap_select.py.
PHRONESIS_PYTHON For a .py CLI only: repository .venv-grpo/Scripts/python.exe if that Windows path exists, otherwise the server interpreter.
PHRONESIS_DEVICE Forwarded to --device; unset uses the CLI choice. Set cpu to compare with the reference.

Code note: the server's opening comment says the current interpreter is the default; _cli_command() actually prefers the repository venv as described above.

Troubleshooting

  • ModuleNotFoundError: mcp: install mcp with the interpreter used by the connector; a second Phronesis interpreter may be selected with PHRONESIS_PYTHON.
  • personal_dir refused: check the server's root variable, directory existence and resolved containment; do not retry an outside path to bypass the refusal.
  • CPU/GPU differences: set PHRONESIS_DEVICE=cpu, and check PHRONESIS_PYTHON before comparing scores.
  • Server does not start: check Python and script paths, JSON syntax and client logs; launch it manually with the same interpreter. Silent stdin waiting is not a startup failure.

Verification and sources

Locally checked: Python 3.11.9, mcp 2.3.0, stdio initialization and discovery of the single tool, compilation and 7 passing tests. Claude Code registration syntax was checked with --help; no connector was registered. The install command was checked with --help, with mcp already installed.

Claude Desktop connection and skill loading, MCP 1.x, a fresh dependency installation and GPU output: not tested on this version.

Sources: integrations/mcp/phronesis_mcp.py, integrations/claude/phronesis/SKILL.md, tests/test_mcp_suggest.py; official client instructions: