kmcp 0.1.5.dev0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kmcp-0.1.5.dev0/.env.example +29 -0
- kmcp-0.1.5.dev0/.github/workflows/release.yml +82 -0
- kmcp-0.1.5.dev0/.gitignore +13 -0
- kmcp-0.1.5.dev0/Justfile +108 -0
- kmcp-0.1.5.dev0/PKG-INFO +251 -0
- kmcp-0.1.5.dev0/README.md +236 -0
- kmcp-0.1.5.dev0/docs/FEATURE_ROADMAP.md +73 -0
- kmcp-0.1.5.dev0/docs/IMPLEMENTATION_PLAN.md +186 -0
- kmcp-0.1.5.dev0/docs/credential-evidence-vault-plan.md +143 -0
- kmcp-0.1.5.dev0/docs/interactive-monitor-plan.md +308 -0
- kmcp-0.1.5.dev0/docs/orchestration-playbooks-plan.md +131 -0
- kmcp-0.1.5.dev0/docs/parallel-execution-plan.md +97 -0
- kmcp-0.1.5.dev0/docs/result-normalization-plan.md +184 -0
- kmcp-0.1.5.dev0/docs/superpowers/specs/2026-10-31-foundation-design.md +43 -0
- kmcp-0.1.5.dev0/docs/target-scope-management-plan.md +136 -0
- kmcp-0.1.5.dev0/docs/tool-wrappers-plan.md +134 -0
- kmcp-0.1.5.dev0/pyproject.toml +45 -0
- kmcp-0.1.5.dev0/requirements.txt +4 -0
- kmcp-0.1.5.dev0/setup.cfg +4 -0
- kmcp-0.1.5.dev0/src/kali_mcp/__init__.py +3 -0
- kmcp-0.1.5.dev0/src/kali_mcp/__main__.py +28 -0
- kmcp-0.1.5.dev0/src/kali_mcp/_version.py +24 -0
- kmcp-0.1.5.dev0/src/kali_mcp/cli.py +169 -0
- kmcp-0.1.5.dev0/src/kali_mcp/config.py +95 -0
- kmcp-0.1.5.dev0/src/kali_mcp/db/__init__.py +1 -0
- kmcp-0.1.5.dev0/src/kali_mcp/db/manager.py +248 -0
- kmcp-0.1.5.dev0/src/kali_mcp/execution.py +439 -0
- kmcp-0.1.5.dev0/src/kali_mcp/logging_utils.py +74 -0
- kmcp-0.1.5.dev0/src/kali_mcp/models.py +51 -0
- kmcp-0.1.5.dev0/src/kali_mcp/monitor/__init__.py +105 -0
- kmcp-0.1.5.dev0/src/kali_mcp/monitor/sessions.py +70 -0
- kmcp-0.1.5.dev0/src/kali_mcp/monitor/sse_client.py +87 -0
- kmcp-0.1.5.dev0/src/kali_mcp/monitor/tui.py +364 -0
- kmcp-0.1.5.dev0/src/kali_mcp/notifications.py +130 -0
- kmcp-0.1.5.dev0/src/kali_mcp/prompts.py +184 -0
- kmcp-0.1.5.dev0/src/kali_mcp/registry.py +33 -0
- kmcp-0.1.5.dev0/src/kali_mcp/resources.py +263 -0
- kmcp-0.1.5.dev0/src/kali_mcp/responses.py +39 -0
- kmcp-0.1.5.dev0/src/kali_mcp/security.py +15 -0
- kmcp-0.1.5.dev0/src/kali_mcp/server.py +535 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/__init__.py +125 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/amass.py +83 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/arjun.py +86 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/base.py +100 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/bettercap.py +99 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/bloodhound.py +68 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/commix.py +73 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/crackmapexec.py +100 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/dirb.py +75 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/dursgo.py +156 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/enum4linux.py +59 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/farsight.py +127 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/ffuf.py +85 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/file_download.py +119 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/file_read.py +144 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/file_write.py +141 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/flowlyt.py +88 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/generic_command.py +95 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/gobuster.py +84 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/hashcat.py +101 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/httpx.py +85 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/hydra.py +99 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/john.py +100 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/katana.py +81 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/masscan.py +85 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/medusa.py +102 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/msfconsole.py +59 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/naabu.py +100 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/netexec.py +86 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/nmap.py +94 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/normalization.py +18 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/nuclei.py +87 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/parallel_execute.py +246 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/persist.py +436 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/playbook_ad.py +99 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/playbook_engine.py +142 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/playbook_engine_tool.py +72 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/playbook_recon.py +115 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/playbook_tools.py +125 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/playbook_webapp.py +105 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/python_command.py +100 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/responder.py +85 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/searchsploit.py +123 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/spiderfoot.py +75 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/sqlmap.py +73 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/subfinder.py +69 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/theharvester.py +80 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/vault_tool.py +489 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/wfuzz.py +87 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/whatweb.py +82 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/wpscan.py +76 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/zap.py +79 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/zighound.py +139 -0
- kmcp-0.1.5.dev0/src/kali_mcp/tools/zizmor.py +98 -0
- kmcp-0.1.5.dev0/src/kali_mcp/utils/__init__.py +0 -0
- kmcp-0.1.5.dev0/src/kali_mcp/utils/process.py +36 -0
- kmcp-0.1.5.dev0/src/kali_mcp/utils/vault.py +471 -0
- kmcp-0.1.5.dev0/src/kali_mcp/validation.py +82 -0
- kmcp-0.1.5.dev0/src/kmcp.egg-info/PKG-INFO +251 -0
- kmcp-0.1.5.dev0/src/kmcp.egg-info/SOURCES.txt +158 -0
- kmcp-0.1.5.dev0/src/kmcp.egg-info/dependency_links.txt +1 -0
- kmcp-0.1.5.dev0/src/kmcp.egg-info/entry_points.txt +4 -0
- kmcp-0.1.5.dev0/src/kmcp.egg-info/requires.txt +6 -0
- kmcp-0.1.5.dev0/src/kmcp.egg-info/scm_file_list.json +154 -0
- kmcp-0.1.5.dev0/src/kmcp.egg-info/scm_version.json +8 -0
- kmcp-0.1.5.dev0/src/kmcp.egg-info/top_level.txt +1 -0
- kmcp-0.1.5.dev0/tests/conftest.py +23 -0
- kmcp-0.1.5.dev0/tests/e2e/mcp_smoke.sh +276 -0
- kmcp-0.1.5.dev0/tests/e2e/test_mcp_prompts_resources.py +139 -0
- kmcp-0.1.5.dev0/tests/e2e/test_mcp_protocol.py +123 -0
- kmcp-0.1.5.dev0/tests/integration/test_execution_advanced.py +140 -0
- kmcp-0.1.5.dev0/tests/integration/test_execution_engine.py +61 -0
- kmcp-0.1.5.dev0/tests/integration/test_file_tools.py +60 -0
- kmcp-0.1.5.dev0/tests/integration/test_generic_command.py +71 -0
- kmcp-0.1.5.dev0/tests/integration/test_monitor_endpoints.py +146 -0
- kmcp-0.1.5.dev0/tests/integration/test_parallel_execute.py +67 -0
- kmcp-0.1.5.dev0/tests/integration/test_playbook_engine.py +64 -0
- kmcp-0.1.5.dev0/tests/integration/test_playbook_tools.py +123 -0
- kmcp-0.1.5.dev0/tests/integration/test_process_and_download.py +87 -0
- kmcp-0.1.5.dev0/tests/integration/test_python_command.py +62 -0
- kmcp-0.1.5.dev0/tests/integration/test_resources.py +60 -0
- kmcp-0.1.5.dev0/tests/integration/test_resources_more.py +160 -0
- kmcp-0.1.5.dev0/tests/integration/test_safe_execute.py +36 -0
- kmcp-0.1.5.dev0/tests/integration/test_vault_tools.py +224 -0
- kmcp-0.1.5.dev0/tests/unit/test_cli.py +119 -0
- kmcp-0.1.5.dev0/tests/unit/test_config.py +20 -0
- kmcp-0.1.5.dev0/tests/unit/test_config_extended.py +157 -0
- kmcp-0.1.5.dev0/tests/unit/test_db_edge.py +143 -0
- kmcp-0.1.5.dev0/tests/unit/test_db_manager.py +88 -0
- kmcp-0.1.5.dev0/tests/unit/test_db_manager_extended.py +102 -0
- kmcp-0.1.5.dev0/tests/unit/test_execution_edge.py +124 -0
- kmcp-0.1.5.dev0/tests/unit/test_execution_engine_unit.py +46 -0
- kmcp-0.1.5.dev0/tests/unit/test_logging_utils.py +109 -0
- kmcp-0.1.5.dev0/tests/unit/test_main_entry.py +32 -0
- kmcp-0.1.5.dev0/tests/unit/test_models.py +49 -0
- kmcp-0.1.5.dev0/tests/unit/test_monitor_actions.py +59 -0
- kmcp-0.1.5.dev0/tests/unit/test_monitor_sessions.py +95 -0
- kmcp-0.1.5.dev0/tests/unit/test_monitor_snapshot.py +125 -0
- kmcp-0.1.5.dev0/tests/unit/test_monitor_tui.py +88 -0
- kmcp-0.1.5.dev0/tests/unit/test_notifications.py +106 -0
- kmcp-0.1.5.dev0/tests/unit/test_persist.py +215 -0
- kmcp-0.1.5.dev0/tests/unit/test_process_extended.py +65 -0
- kmcp-0.1.5.dev0/tests/unit/test_prompts_extended.py +72 -0
- kmcp-0.1.5.dev0/tests/unit/test_registry.py +55 -0
- kmcp-0.1.5.dev0/tests/unit/test_resources_extended.py +171 -0
- kmcp-0.1.5.dev0/tests/unit/test_responses.py +44 -0
- kmcp-0.1.5.dev0/tests/unit/test_security.py +21 -0
- kmcp-0.1.5.dev0/tests/unit/test_security_edge.py +56 -0
- kmcp-0.1.5.dev0/tests/unit/test_security_helpers.py +13 -0
- kmcp-0.1.5.dev0/tests/unit/test_server.py +267 -0
- kmcp-0.1.5.dev0/tests/unit/test_support_modules.py +241 -0
- kmcp-0.1.5.dev0/tests/unit/test_tool_commands_matrix.py +231 -0
- kmcp-0.1.5.dev0/tests/unit/test_tool_schemas.py +327 -0
- kmcp-0.1.5.dev0/tests/unit/test_validation.py +103 -0
- kmcp-0.1.5.dev0/tests/unit/test_validation_edge.py +135 -0
- kmcp-0.1.5.dev0/tests/unit/test_vault.py +40 -0
- kmcp-0.1.5.dev0/tests/unit/test_vault_edge.py +83 -0
- kmcp-0.1.5.dev0/tests/unit/test_vault_extended.py +159 -0
- kmcp-0.1.5.dev0/tests/unit/test_vault_sqlite.py +231 -0
- kmcp-0.1.5.dev0/tests/unit/test_wrapper_normalize.py +201 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Kali MCP Server Configuration
|
|
2
|
+
MCP_HOST=0.0.0.0
|
|
3
|
+
MCP_PORT=8399
|
|
4
|
+
MCP_SERVER_NAME=kali-mcp
|
|
5
|
+
MCP_SERVER_VERSION=1.0.0
|
|
6
|
+
MCP_DEFAULT_TIMEOUT=300
|
|
7
|
+
MCP_MAX_TIMEOUT=3600
|
|
8
|
+
MCP_MAX_CONCURRENT=10
|
|
9
|
+
MCP_LOG_DIR=logs
|
|
10
|
+
MCP_ARTIFACT_DIR=artifacts
|
|
11
|
+
MCP_ENCODING=utf-8
|
|
12
|
+
MCP_DEBUG=false
|
|
13
|
+
MCP_TRANSPORT=sse
|
|
14
|
+
|
|
15
|
+
# Authentication (set in production)
|
|
16
|
+
MCP_API_TOKEN=
|
|
17
|
+
|
|
18
|
+
# CORS (comma-separated origins, default: * = all origins)
|
|
19
|
+
MCP_ALLOWED_ORIGINS=*
|
|
20
|
+
|
|
21
|
+
# Rate limiting (requests per minute per IP, 0 = unlimited)
|
|
22
|
+
MCP_RATE_LIMIT=0
|
|
23
|
+
|
|
24
|
+
# Path containment (comma-separated allowed directories, empty = unrestricted)
|
|
25
|
+
MCP_ALLOWED_WRITE_DIRS=
|
|
26
|
+
MCP_ALLOWED_READ_DIRS=
|
|
27
|
+
|
|
28
|
+
# GitHub token for zizmor (GitHub Actions scanner)
|
|
29
|
+
GH_TOKEN=
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
name: Release to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
# Fire the release on both conventions: `v0.5.0` and `0.5.0`.
|
|
7
|
+
- "v*"
|
|
8
|
+
- "[0-9]*"
|
|
9
|
+
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read
|
|
12
|
+
id-token: write # trusted publishing (OIDC) — no PyPI token secret required
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
test:
|
|
16
|
+
name: Test (unit + integration)
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- uses: actions/setup-python@v5
|
|
22
|
+
with:
|
|
23
|
+
python-version: "3.10"
|
|
24
|
+
|
|
25
|
+
- name: Install dependencies
|
|
26
|
+
run: |
|
|
27
|
+
python -m pip install --upgrade pip
|
|
28
|
+
pip install -e .
|
|
29
|
+
pip install pytest pytest-asyncio ruff
|
|
30
|
+
|
|
31
|
+
- name: Run unit tests
|
|
32
|
+
run: python -m pytest tests/unit
|
|
33
|
+
|
|
34
|
+
- name: Run integration tests
|
|
35
|
+
run: python -m pytest tests/integration
|
|
36
|
+
|
|
37
|
+
- name: Lint with ruff
|
|
38
|
+
run: ruff check src/ tests/
|
|
39
|
+
|
|
40
|
+
build-and-publish:
|
|
41
|
+
name: Build and publish to PyPI
|
|
42
|
+
needs: test
|
|
43
|
+
runs-on: ubuntu-latest
|
|
44
|
+
steps:
|
|
45
|
+
# Full history so setuptools-scm (if enabled later) can resolve versions.
|
|
46
|
+
- uses: actions/checkout@v4
|
|
47
|
+
with:
|
|
48
|
+
fetch-depth: 0
|
|
49
|
+
|
|
50
|
+
- uses: actions/setup-python@v5
|
|
51
|
+
with:
|
|
52
|
+
python-version: "3.10"
|
|
53
|
+
|
|
54
|
+
- name: Build wheel + sdist
|
|
55
|
+
run: |
|
|
56
|
+
python -m pip install --upgrade build
|
|
57
|
+
python -m build
|
|
58
|
+
|
|
59
|
+
# Trusted Publishing: authenticates via OIDC against the Trusted
|
|
60
|
+
# Publisher configured on pypi.org for this repository
|
|
61
|
+
# (owner magichrist, repo kali-mcp, workflow release.yml).
|
|
62
|
+
# Do NOT add a username/password here — the action would fall back
|
|
63
|
+
# to token auth and fail.
|
|
64
|
+
- name: Publish to PyPI
|
|
65
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
66
|
+
|
|
67
|
+
publish-github-release:
|
|
68
|
+
name: Create GitHub release
|
|
69
|
+
needs: test
|
|
70
|
+
runs-on: ubuntu-latest
|
|
71
|
+
permissions:
|
|
72
|
+
contents: write # create the GitHub release
|
|
73
|
+
steps:
|
|
74
|
+
- uses: actions/checkout@v4
|
|
75
|
+
with:
|
|
76
|
+
fetch-depth: 0
|
|
77
|
+
|
|
78
|
+
- name: Create GitHub release
|
|
79
|
+
uses: softprops/action-gh-release@v2
|
|
80
|
+
with:
|
|
81
|
+
name: ${{ github.ref_name }}
|
|
82
|
+
generate_release_notes: true
|
kmcp-0.1.5.dev0/Justfile
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Kali MCP Server — Just Commands
|
|
2
|
+
set dotenv-load
|
|
3
|
+
|
|
4
|
+
# Show available commands
|
|
5
|
+
default:
|
|
6
|
+
@just --list
|
|
7
|
+
|
|
8
|
+
# Install dependencies (editable install of the kali_mcp package + deps)
|
|
9
|
+
install:
|
|
10
|
+
pip install -e .
|
|
11
|
+
|
|
12
|
+
# Start the server (foreground)
|
|
13
|
+
start:
|
|
14
|
+
python -m kali_mcp
|
|
15
|
+
|
|
16
|
+
# Start in debug mode
|
|
17
|
+
debug:
|
|
18
|
+
MCP_DEBUG=true python -m kali_mcp
|
|
19
|
+
|
|
20
|
+
# Run the full pytest suite (unit + integration)
|
|
21
|
+
test:
|
|
22
|
+
.venv/bin/python -m pytest
|
|
23
|
+
|
|
24
|
+
# Run only fast unit tests
|
|
25
|
+
test-unit:
|
|
26
|
+
.venv/bin/python -m pytest tests/unit
|
|
27
|
+
|
|
28
|
+
# Run integration tests (uses local subprocesses; no external binaries needed except coreutils)
|
|
29
|
+
test-integration:
|
|
30
|
+
.venv/bin/python -m pytest tests/integration
|
|
31
|
+
|
|
32
|
+
# Run end-to-end protocol tests (spawns a real server)
|
|
33
|
+
test-e2e:
|
|
34
|
+
.venv/bin/python -m pytest tests/e2e -m e2e
|
|
35
|
+
|
|
36
|
+
# Show server health (requires running server)
|
|
37
|
+
health:
|
|
38
|
+
@curl -sf http://127.0.0.1:8399/sse -o /dev/null && echo "Server running" || echo "Server not running"
|
|
39
|
+
|
|
40
|
+
# View logs
|
|
41
|
+
logs:
|
|
42
|
+
tail -f logs/server.log
|
|
43
|
+
|
|
44
|
+
# View execution logs
|
|
45
|
+
exec-logs:
|
|
46
|
+
tail -f logs/executions.jsonl
|
|
47
|
+
|
|
48
|
+
# Clean build artifacts
|
|
49
|
+
clean:
|
|
50
|
+
rm -rf logs/*.log logs/*.jsonl
|
|
51
|
+
rm -rf artifacts/*
|
|
52
|
+
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
|
|
53
|
+
|
|
54
|
+
# Purge stored data: just purge db | just purge vault | just purge all
|
|
55
|
+
purge scope="all":
|
|
56
|
+
#!/usr/bin/env bash
|
|
57
|
+
set -euo pipefail
|
|
58
|
+
if [ -z "${CONFIRM:-}" ]; then
|
|
59
|
+
read -r -p "Purge '{{scope}}' data — this cannot be undone. Continue? [y/N] " c
|
|
60
|
+
[[ "$c" =~ ^[Yy]$ ]] || { echo "aborted"; exit 1; }
|
|
61
|
+
fi
|
|
62
|
+
case "{{scope}}" in
|
|
63
|
+
db)
|
|
64
|
+
rm -fv data/kali-mcp.sqlite data/kali-mcp.sqlite-wal data/kali-mcp.sqlite-shm
|
|
65
|
+
;;
|
|
66
|
+
vault)
|
|
67
|
+
rm -rf artifacts/vault
|
|
68
|
+
;;
|
|
69
|
+
all)
|
|
70
|
+
rm -fv data/kali-mcp.sqlite data/kali-mcp.sqlite-wal data/kali-mcp.sqlite-shm
|
|
71
|
+
rm -rf artifacts/vault
|
|
72
|
+
;;
|
|
73
|
+
*)
|
|
74
|
+
echo "unknown scope '{{scope}}' — use: db | vault | all" >&2
|
|
75
|
+
exit 1
|
|
76
|
+
;;
|
|
77
|
+
esac
|
|
78
|
+
echo "purged: {{scope}}"
|
|
79
|
+
echo "note: if the server is running, restart it (or just deploy) so it reconnects cleanly."
|
|
80
|
+
|
|
81
|
+
# Show all registered tools
|
|
82
|
+
tools:
|
|
83
|
+
python -c "from kali_mcp.tools import ALL_TOOLS; [print(f' {t.name:20s} {t.description[:60]}') for t in ALL_TOOLS]"
|
|
84
|
+
|
|
85
|
+
# Deploy to the Kali VM and restart the server (requires ssh key auth)
|
|
86
|
+
deploy host="kali-linux.shared" dest="~/kali-mcp":
|
|
87
|
+
rsync -av --exclude '.venv' --exclude '__pycache__' --exclude '.git' \
|
|
88
|
+
--exclude 'logs' --exclude 'artifacts' --exclude 'data' \
|
|
89
|
+
./ {{host}}:{{dest}}/
|
|
90
|
+
ssh {{host}} "pkill -f '[k]ali_mcp' || true; cd {{dest}} && \
|
|
91
|
+
nohup python -m kali_mcp > logs/stdout.log 2>&1 & sleep 2; \
|
|
92
|
+
curl -sf --max-time 5 http://127.0.0.1:8399/sse -o /dev/null \
|
|
93
|
+
&& echo 'server restarted OK' || echo 'server did not come up — check logs/stdout.log'"
|
|
94
|
+
|
|
95
|
+
# Commit all changes, tag with version, and push — triggers PyPI release
|
|
96
|
+
release version="0.0.0":
|
|
97
|
+
#!/usr/bin/env bash
|
|
98
|
+
set -euo pipefail
|
|
99
|
+
if [ "{{version}}" = "0.0.0" ]; then
|
|
100
|
+
echo "Usage: just release version=0.1.3" >&2
|
|
101
|
+
exit 1
|
|
102
|
+
fi
|
|
103
|
+
git add -A
|
|
104
|
+
git commit -m "chore: release v{{version}}" || echo "nothing to commit"
|
|
105
|
+
git tag -f "v{{version}}"
|
|
106
|
+
git push origin master
|
|
107
|
+
git push origin "v{{version}}" --force
|
|
108
|
+
echo "Released v{{version}} — GitHub Actions will build and publish to PyPI"
|
kmcp-0.1.5.dev0/PKG-INFO
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: kmcp
|
|
3
|
+
Version: 0.1.5.dev0
|
|
4
|
+
Summary: MCP server exposing Kali Linux penetration-testing tools to AI agents
|
|
5
|
+
Author: kali-mcp
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
Requires-Dist: mcp<2,>=1.26.0
|
|
10
|
+
Requires-Dist: uvicorn>=0.30.0
|
|
11
|
+
Requires-Dist: fastmcp
|
|
12
|
+
Requires-Dist: python-dotenv
|
|
13
|
+
Requires-Dist: rich
|
|
14
|
+
Requires-Dist: httpx
|
|
15
|
+
|
|
16
|
+
# ✦ kali-mcp
|
|
17
|
+
|
|
18
|
+
*A warm, expressive MCP server that puts 56 Kali Linux pentesting tools at your AI agent's fingertips — soft voltage around sharp security tooling.*
|
|
19
|
+
|
|
20
|
+
The Kali MCP Server is a production-grade Model Context Protocol (MCP) server that exposes Kali Linux penetration-testing tools (nmap, sqlmap, nuclei, hydra, metasploit, and 50 more) to AI agents. Every tool call is validated, every execution is sandboxed with timeouts, and every result can be shared between agents through a built-in inter-agent vault.
|
|
21
|
+
|
|
22
|
+
## ✧ At a glance
|
|
23
|
+
|
|
24
|
+
| | |
|
|
25
|
+
|---|---|
|
|
26
|
+
| **Transport** | HTTP/SSE or streamable-http on `:8399/mcp` |
|
|
27
|
+
| **Tools** | 56 native Kali wrappers + `generic_command` escape hatch |
|
|
28
|
+
| **Persistence** | SQLite (targets, scans, findings, credentials) + inter-agent vault |
|
|
29
|
+
| **Orchestration** | Playbooks (recon / webapp / AD / custom engine) with `{{target}}` substitution and resume |
|
|
30
|
+
| **Parallelism** | `parallel_execute` with deduplicated aggregate results |
|
|
31
|
+
| **Monitoring** | Live CLI/TUI with SSE push, job kill, force cleanup |
|
|
32
|
+
| **Safety** | 3-layer timeout defense, process-tree cleanup, semaphore limits, output truncation |
|
|
33
|
+
|
|
34
|
+
## ♡ Get started
|
|
35
|
+
|
|
36
|
+
### Requirements
|
|
37
|
+
|
|
38
|
+
- Python 3.10+
|
|
39
|
+
- A host with the Kali tools you want to run installed (the server wraps binaries; it doesn't install them)
|
|
40
|
+
- `pip`
|
|
41
|
+
|
|
42
|
+
### Install
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install kmcp
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Start the server
|
|
49
|
+
|
|
50
|
+
Use the `kmcp` CLI:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
kmcp start
|
|
54
|
+
|
|
55
|
+
# With custom host/port
|
|
56
|
+
kmcp start --host 127.0.0.1 --port 9000
|
|
57
|
+
|
|
58
|
+
# Aliases: s, monitor (m), purge (p)
|
|
59
|
+
kmcp s
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The server listens on `http://0.0.0.0:8399/mcp` by default. Point your MCP client at that URL.
|
|
63
|
+
|
|
64
|
+
### Debug mode
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
MCP_DEBUG=true kmcp start
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Configuration
|
|
71
|
+
|
|
72
|
+
Copy `.env.example` to `.env` and adjust:
|
|
73
|
+
|
|
74
|
+
| Variable | Default | What it does |
|
|
75
|
+
|---|---|---|
|
|
76
|
+
| `MCP_HOST` | `0.0.0.0` | Listen address |
|
|
77
|
+
| `MCP_PORT` | `8399` | Listen port |
|
|
78
|
+
| `MCP_TRANSPORT` | `sse` | `sse` or `streamable-http` |
|
|
79
|
+
| `MCP_API_TOKEN` | *(empty)* | Bearer token for HTTP auth |
|
|
80
|
+
| `MCP_DEFAULT_TIMEOUT` | `300` | Default command timeout (seconds) |
|
|
81
|
+
| `MCP_MAX_TIMEOUT` | `3600` | Maximum allowed timeout |
|
|
82
|
+
| `MCP_MAX_CONCURRENT` | `10` | Max concurrent tool executions |
|
|
83
|
+
| `MCP_DB_ENABLED` | `true` | Write executions to SQLite |
|
|
84
|
+
| `MCP_DEBUG` | `false` | Verbose structured logging |
|
|
85
|
+
|
|
86
|
+
## ✦ Features
|
|
87
|
+
|
|
88
|
+
**56 Kali tools, natively wrapped.** Nmap, sqlmap, nuclei, ffuf, katana, subfinder, amass, hydra, metasploit, bettercap, responder, zap, wpscan, and more. Each tool validates its arguments against a JSON schema, builds a safe subprocess argument list (no shell injection for native tools), and returns structured JSON with stdout, stderr, exit code, and timing.
|
|
89
|
+
|
|
90
|
+
**`generic_command`** — the escape hatch. Run any shell command or pipeline not covered by a native wrapper. Full bash scripting supported (pipes, redirects, here-docs).
|
|
91
|
+
|
|
92
|
+
**`python_command`** — execute Python scripts directly on the host. Full access to installed libraries (scapy, impacket, requests, etc.).
|
|
93
|
+
|
|
94
|
+
**Playbooks** — multi-step pipelines with `{{target}}` substitution and resume support:
|
|
95
|
+
- `playbook_recon` — subfinder → httpx → masscan → whatweb+nmap → nuclei
|
|
96
|
+
- `playbook_webapp` — katana → arjun+ffuf → nuclei → sqlmap+commix
|
|
97
|
+
- `playbook_ad` — enum4linux → bloodhound → netexec+crackmapexec
|
|
98
|
+
- `playbook_engine` — run a custom playbook definition
|
|
99
|
+
|
|
100
|
+
**`parallel_execute`** — fan out to multiple tools concurrently, then aggregate and deduplicate open ports, vulnerabilities, and credentials.
|
|
101
|
+
|
|
102
|
+
**Inter-agent vault** — SQLite-backed knowledge store (`artifacts/vault/vault.sqlite` + JSON mirrors). Any agent can write findings, credentials, or notes; any other agent can query them back by category, target, tool, or free-text search. Every tool run is automatically deposited.
|
|
103
|
+
|
|
104
|
+
**Live monitor TUI** — `kmcp monitor` launches a pastel cyber dashboard showing connected users, running jobs, and server health with SSE push updates. Kill stuck jobs or force cleanup from the dashboard. Press `q` to quit; the screen clears on exit.
|
|
105
|
+
|
|
106
|
+
**MCP resources & prompts** — `kali://config`, `kali://tools`, `kali://health`, `kali://vault/index`, plus guided workflow prompts (recon, webapp, AD, OSINT, quick scan, report).
|
|
107
|
+
|
|
108
|
+
## ⟡ How it works
|
|
109
|
+
|
|
110
|
+
Every tool call follows the same path:
|
|
111
|
+
|
|
112
|
+
1. **Validate** — arguments checked against the tool's JSON schema (required fields, IP/CIDR/domain/URL/timeout formats, enums).
|
|
113
|
+
2. **Build command** — arguments converted to a safe subprocess argument list. No shell interpolation for native tools; `generic_command` is the only shell path.
|
|
114
|
+
3. **Execute** — subprocess runs in its own process group with a 3-layer timeout defense:
|
|
115
|
+
- `asyncio.wait_for` enforced timeout
|
|
116
|
+
- Watchdog thread kills stuck executions
|
|
117
|
+
- Semaphore limits concurrent executions (`MCP_MAX_CONCURRENT`, default 10)
|
|
118
|
+
4. **Persist** — run recorded to SQLite (`targets`, `scans`, `findings`, `credentials`) and deposited to the vault.
|
|
119
|
+
5. **Respond** — structured JSON with stdout, stderr, exit_code, timing, and success flag.
|
|
120
|
+
|
|
121
|
+
**Session tracking** — the monitor tracks connected MCP client sessions (connect time, last activity, client info) so you can see who's using the server.
|
|
122
|
+
|
|
123
|
+
## ☾ Configuration
|
|
124
|
+
|
|
125
|
+
Configuration is loaded from environment variables via `.env`. All values have safe defaults.
|
|
126
|
+
|
|
127
|
+
| Variable | Default | Description |
|
|
128
|
+
|---|---|---|
|
|
129
|
+
| `MCP_HOST` | `0.0.0.0` | Listen address |
|
|
130
|
+
| `MCP_PORT` | `8399` | Listen port |
|
|
131
|
+
| `MCP_SERVER_NAME` | `kali-mcp` | Server name advertised to MCP clients |
|
|
132
|
+
| `MCP_SERVER_VERSION` | `1.0.0` | Server version |
|
|
133
|
+
| `MCP_TRANSPORT` | `sse` | `sse` or `streamable-http` |
|
|
134
|
+
| `MCP_API_TOKEN` | *(empty)* | Bearer token; when set, all HTTP routes require `Authorization: Bearer <token>` |
|
|
135
|
+
| `MCP_DEFAULT_TIMEOUT` | `300` | Default command timeout (seconds) |
|
|
136
|
+
| `MCP_MAX_TIMEOUT` | `3600` | Hard cap on tool timeout |
|
|
137
|
+
| `MCP_MAX_CONCURRENT` | `10` | Semaphore limit for concurrent executions |
|
|
138
|
+
| `MCP_LOG_DIR` | `logs` | Structured log directory |
|
|
139
|
+
| `MCP_ARTIFACT_DIR` | `artifacts` | Artifact and vault directory |
|
|
140
|
+
| `MCP_DEBUG` | `false` | Verbose debug logging |
|
|
141
|
+
| `MCP_ENCODING` | `utf-8` | Default text encoding |
|
|
142
|
+
| `MCP_RATE_LIMIT` | `0` | Rate limit per minute (0 = unlimited) |
|
|
143
|
+
| `MCP_VAULT_MAX_ROW_BYTES` | `26214400` | Max vault row size (25 MB; 0 = unlimited) |
|
|
144
|
+
| `MCP_DB_PATH` | `data/kali-mcp.sqlite` | SQLite database path |
|
|
145
|
+
| `MCP_DB_ENABLED` | `true` | Write executions to SQLite |
|
|
146
|
+
|
|
147
|
+
## ◈ Architecture
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
MCP Client (AI agent)
|
|
151
|
+
│ HTTP/SSE
|
|
152
|
+
▼
|
|
153
|
+
┌─────────────────────────────────────────┐
|
|
154
|
+
│ Kali MCP Server (:8399) │
|
|
155
|
+
│ │
|
|
156
|
+
│ ┌─────────────┐ ┌─────────────────┐ │
|
|
157
|
+
│ │ Token Auth │ │ CORS Middleware │ │
|
|
158
|
+
│ │ (optional) │ │ │ │
|
|
159
|
+
│ └─────────────┘ └─────────────────┘ │
|
|
160
|
+
│ │ │ │
|
|
161
|
+
│ ▼ ▼ │
|
|
162
|
+
│ FastMCP tool dispatch layer │
|
|
163
|
+
│ │ │ │
|
|
164
|
+
│ ┌─────────────────────────────┐ │
|
|
165
|
+
│ │ Tool registry (56 tools) │ │
|
|
166
|
+
│ └─────────────────────────────┘ │
|
|
167
|
+
│ │ │ │
|
|
168
|
+
│ ┌─────────────────────────────┐ │
|
|
169
|
+
│ │ Execution engine │ │
|
|
170
|
+
│ │ (3-layer timeout, semaphore, │ │
|
|
171
|
+
│ │ process-tree cleanup) │ │
|
|
172
|
+
│ └─────────────────────────────┘ │
|
|
173
|
+
│ │ │ │
|
|
174
|
+
│ ┌─────────────────────────────┐ │
|
|
175
|
+
│ │ SQLite DB + Vault store │ │
|
|
176
|
+
│ └─────────────────────────────┘ │
|
|
177
|
+
│ │ │ │
|
|
178
|
+
│ ┌─────────────────────────────┐ │
|
|
179
|
+
│ │ Monitor SSE stream │ │
|
|
180
|
+
│ └─────────────────────────────┘ │
|
|
181
|
+
└─────────────────────────────────────────┘
|
|
182
|
+
│ │
|
|
183
|
+
▼ ▼
|
|
184
|
+
Kali Linux Monitor TUI
|
|
185
|
+
subprocesses (kmcp monitor)
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
**Package layout (`src/kali_mcp/`):**
|
|
189
|
+
|
|
190
|
+
- `server.py` — MCP server, tool dispatch, health monitor, REST routes
|
|
191
|
+
- `execution.py` — hardened execution engine (timeout, watchdog, semaphore)
|
|
192
|
+
- `security.py` — allowlist, input validation, shell-injection prevention
|
|
193
|
+
- `config.py` — env-based configuration
|
|
194
|
+
- `models.py` — `ExecutionResult`, `ToolError` dataclasses
|
|
195
|
+
- `responses.py` — standardized MCP response builders
|
|
196
|
+
- `registry.py` — tool registration and lookup
|
|
197
|
+
- `logging_utils.py` — structured JSON logging
|
|
198
|
+
- `notifications.py` — MCP server→client notification helpers
|
|
199
|
+
- `prompts.py` — MCP prompt templates
|
|
200
|
+
- `resources.py` — MCP resources (`kali://*`)
|
|
201
|
+
- `db/manager.py` — SQLite persistence
|
|
202
|
+
- `utils/process.py` — process tree cleanup
|
|
203
|
+
- `utils/vault.py` — SQLite-backed inter-agent vault
|
|
204
|
+
- `tools/` — 56 tool wrappers + base class + parsers + playbooks
|
|
205
|
+
|
|
206
|
+
## 🧪 Tests & checks
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
# Full suite (unit + integration + e2e)
|
|
210
|
+
just test
|
|
211
|
+
|
|
212
|
+
# Fast unit tests only
|
|
213
|
+
just test-unit
|
|
214
|
+
|
|
215
|
+
# Integration tests (async engine + tool execution)
|
|
216
|
+
just test-integration
|
|
217
|
+
|
|
218
|
+
# End-to-end (spawns a real server, speaks MCP over HTTP)
|
|
219
|
+
just test-e2e
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
The suite runs on `pytest` with `pytest-asyncio`. 803 tests pass, 11 skipped (conditional/environment-dependent). Coverage is approximately 84% across the package.
|
|
223
|
+
|
|
224
|
+
Quality checks:
|
|
225
|
+
- `ruff` — linting (line-length 100)
|
|
226
|
+
|
|
227
|
+
## ⚠ Known limitations
|
|
228
|
+
|
|
229
|
+
- **Kali tools must be installed on the host.** The server wraps binaries like `nmap`, `sqlmap`, `hydra`; it does not install them. If a binary isn't in `PATH`, the tool returns a structured "Binary not found" error with an install hint.
|
|
230
|
+
- **`generic_command` runs arbitrary shell.** It's the escape hatch — use it deliberately. It is subject to the same timeout and semaphore limits as native tools.
|
|
231
|
+
- **In-memory monitor state.** The live monitor (sessions, active jobs) lives in memory and resets on server restart. Persisted data (SQLite, vault) survives restarts.
|
|
232
|
+
- **No alerting yet.** The monitor displays status but does not send alerts for stuck executions or high error rates.
|
|
233
|
+
- **Output truncation.** stdout/stderr are capped at 100 KB per stream to prevent memory exhaustion.
|
|
234
|
+
|
|
235
|
+
## ◈ Troubleshooting
|
|
236
|
+
|
|
237
|
+
| Symptom | Likely cause | Next step |
|
|
238
|
+
|---|---|---|
|
|
239
|
+
| Server won't start | Port 8399 in use | Set `MCP_PORT` to a free port |
|
|
240
|
+
| Tool returns "Binary not found" | Kali tool not installed or not in `PATH` | Install the tool or add it to `PATH` |
|
|
241
|
+
| `401 Unauthorized` | `MCP_API_TOKEN` set but no/invalid token | Provide `Authorization: Bearer <token>` or `?token=` query param |
|
|
242
|
+
| Monitor TUI shows no jobs | No executions currently running | Run a tool first; jobs appear while active |
|
|
243
|
+
| `q` doesn't quit TUI | Terminal rendering glitch | Press `q` again; if stuck, `Ctrl+C` |
|
|
244
|
+
|
|
245
|
+
## License
|
|
246
|
+
|
|
247
|
+
MIT
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
*Built with soft voltage — sharp security tooling wrapped in a warm, expressive MCP server.*
|