pentest-kb
pentest-kb is an MCP server that stores, searches, and curates penetration-testing experience records in a PostgreSQL (Supabase) database, using BM25 relevance ranking with Chinese tokenization and a draft/approval workflow with automatic sanitization.
Search experiences —
search_experience(keyword, tags_filter)returns the top 10 approved records ranked by BM25 relevance, optionally filtered to records containing all given scenario tags.Add experiences —
add_experience(title, detail, scenario_tags, tool_code, tool_type, status)creates a record; defaults todraftfor review, orapprovedfor direct entry. Inputs are sanitized before writing, rejecting real IPs, domains, emails, credentials, cloud AccessKeys, JWTs, private keys, and phone numbers.Browse the library —
list_all_experiences(limit, offset)paginates through the titles of all approved records (default 50, max 200).Read individual records —
get_experience(experience_id)returns the full content of one entry (title, details, tags, tool code, status).Edit records —
update_experience(...)patches only the supplied fields, with sanitization applied before the change.Detect duplicates —
find_similar(title, detail)finds already-stored entries resembling the given content.Review drafts —
list_pending_experiences()shows pending drafts and flags possibly duplicated approved records.Approve or reject drafts —
approve_experience(experience_id, merge_with_id)publishes a draft (optionally merging it into an existing record, appending detail, combining tags, and filling in tool info);reject_experience(experience_id)soft-deletes a draft asrejected.Soft-delete and restore —
delete_experience(experience_id)marks an approved entrydeletedso it leaves search but can be recovered;restore_experience(experience_id)returns rejected drafts todraftand deleted entries toapproved.Manage the recycle bin —
list_deleted_experiences()lists all soft-deleted records;purge_experiences(days)permanently removes records soft-deleted longer than the given retention period (default 30 days).
Stores penetration testing experience records in a PostgreSQL database, with the MCP server providing tools to search, add, list, update, approve, reject, delete, and restore experiences. Supports Supabase-hosted PostgreSQL as the backing store.
Uses Supabase (hosted PostgreSQL) as the backend database for the penetration testing knowledge base, storing structured experience records that the MCP server queries and manages via BM25 relevance ranking.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@pentest-kb search my pentest knowledge base for WAF bypass techniques"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
pentest-kb MCP Server
Penetration testing experience base MCP server. Based on MCP (Model Context Protocol), it provides tools such as retrieval, addition, and listing for accumulating and reusing hands-on penetration testing experience.
What problem does this project solve
Background pain points:
Penetration testing experience is scattered across notes, chat logs, and personal memory, making it hard to retrieve and reuse; when encountering similar problems (such as WAF bypass, 403 bypass), you often have to search again from scratch
Agents have no access to a personal experience base by default; when answering penetration testing questions, they can only rely on general knowledge, lacking hands-on experience support and tending to give vague, generic advice
Experience cannot be accumulated or reused across scenarios, making it hard for individuals or teams to build a systematic body of knowledge
What this project solves:
Unifies penetration testing experience into a PostgreSQL (Supabase) database with structured storage
Connects the experience base to agents via the MCP protocol, letting agents directly search (
search_experience), add (add_experience), and list (list_all_experiences) experienceRetrieval is based on BM25 relevance ranking (jieba Chinese word segmentation), more accurate than simple fuzzy matching
Lets agents answer in real-world scenarios based on their personal experience base rather than general knowledge alone
Related MCP server: mcp-rag-bridge
Features
search_experience(keyword, tags_filter): searches the experience base with BM25 relevance ranking (approved records only), supports Chinese word segmentation, returns Top 10;tags_filterallows precise filtering by scenario tags (e.g.,["WAF bypass"])add_experience(title, detail, scenario_tags, tool_code, tool_type, status): adds experience.status='draft'stores it as a pending-approval draft (default);status='approved'puts it directly into the base; before writing, an automatic desensitization check is performed (detects real IPs, domains, credentials, cloud provider AccessKeys, JWTs, private keys, phone numbers; rejects on match)list_all_experiences(limit, offset): paginated list of titles of all approved records in the experience base (default 50 per page, max 200)find_similar(title, detail): duplicate check, finds stored records similar to the given contentget_experience(experience_id): gets the full content of one experience by id (title, detail, tags, tool code, status, etc.)update_experience(experience_id, title, detail, scenario_tags, tool_code, tool_type, status): updates fields of an experience (only updates passed-in fields; omitted fields remain unchanged; desensitization check is performed before modifying)list_pending_experiences(): lists pending-approval drafts and hints at stored records each draft may duplicateapprove_experience(experience_id, merge_with_id): approves a draft; whenmerge_with_idis provided, merges it into the specified record (detail appended, tags merged, tool info completed) and then deletes the draftreject_experience(experience_id): rejects a draft (soft delete, the record is kept asrejectedand can be restored)delete_experience(experience_id): soft-deletes an approved experience (status set todeleted, excluded from search, restorable)restore_experience(experience_id): restores a soft-deleted record (rejected draft →draft, deleted experience →approved)list_deleted_experiences(): lists all soft-deleted records (recycle bin), making it easy to restore or permanently clean uppurge_experiences(days): physically deletes records soft-deleted for more than the specified number of days (default 30 days, irreversible, use with caution)
Experience accumulation and approval
To avoid verbose content and sensitive information leakage from automatic accumulation, a "semi-automatic accumulation + mandatory desensitization + manual approval" flow is used:
实战结束 → Agent 生成经验草稿(status='draft',结构化 + 限长 + 脱敏)
→ 草稿进入待审批状态(不直接入库,不参与检索)
→ 用户审批(list_pending 查看 → approve / reject / merge)
→ 通过后才正式入库(status='approved')Desensitization line of defense: before writing, add_experience automatically detects real IP addresses, domains, emails, credentials (including Chinese "password/passphrase/secret/account" etc.), cloud provider AccessKeys (AWS/Aliyun/Tencent), JWTs, private key blocks, and phone numbers; on a match, the write is rejected and placeholders are required instead (e.g., <target URL>, <target domain>). Special IPs such as private/loopback/link-local addresses and whitelisted domains (example.com etc.) are allowed into the base.
Duplicate-check line of defense: during approval, list_pending_experiences automatically hints at stored records each draft may duplicate, and the user can choose to skip, merge, or still add.
Direct insertion vs. draft approval:
add_experiencesupportsstatus='approved'for direct insertion, used only for manual user-confirmed entry scenarios; AI workflows (see SKILL.md) must always generatedraftdrafts and go through approval, never direct insertion.
Dependencies
Python 3.10+
mcp(MCP Python SDK)psycopg2(PostgreSQL driver)jieba(Chinese word segmentation, automatically loads the domain dictionarypentest_dict.txtin the root directory at startup)rank_bm25(BM25 retrieval algorithm)A PostgreSQL database (e.g., Supabase)
Install dependencies:
pip install -r requirements.txtThe dependency list is in requirements.txt (version ranges are pinned; note that mcp must be 2.x).
Database initialization
Run schema.sql in the repository root directory against PostgreSQL (e.g., Supabase) (idempotent, can be run repeatedly):
# 方式一:Supabase 控制台 → SQL Editor → 粘贴 schema.sql 内容执行
# 方式二:命令行(需已配置 psql)
psql "$PENTEST_KB_DB_CONNECTION_STRING" -f schema.sqlThe table structure is as follows (schema.sql is the single source of maintenance; the README does not repeat the SQL):
Field | Type | Description |
| uuid PK | Primary key, defaults to |
| timestamptz | Creation time |
| text | Experience title |
| jsonb | Scenario tag array, e.g., |
| text | Experience details |
| text | Exploit/tool code |
| text | Tool type, e.g., sqlmap, burp |
| text |
|
| timestamptz | Soft-delete time (recorded when |
Optional: semantic search column (not used by the current code, reserved) To integrate vector semantic search, uncomment the trailing comment in
schema.sqland run it (requires enabling the pgvector extension first).
Configuration
Database connection information is injected via environment variables; do not hardcode credentials in code:
Environment variable | Description |
| Database host address |
| Port (default 5432) |
| Database name (default postgres) |
| Database username |
| Database password |
| Connection pool max connections (optional, default 10) |
MCP client configuration
Register the server in your MCP client, see mcp.example.json:
{
"mcpServers": {
"pentest-kb": {
"command": "python",
"args": ["/absolute/path/to/pentest_kb_mcp.py"],
"env": {
"PENTEST_KB_DB_HOST": "your-supabase-host.pooler.supabase.com",
"PENTEST_KB_DB_PORT": "5432",
"PENTEST_KB_DB_NAME": "postgres",
"PENTEST_KB_DB_USER": "postgres.your-project-ref",
"PENTEST_KB_DB_PASSWORD": "your-database-password"
}
}
}
}Usage
Call the tools in your MCP client, for example:
搜索:search_experience(keyword="WAF绕过") # BM25 相关性排序
搜索+标签过滤:search_experience(keyword="绕过", tags_filter=["WAF绕过"]) # 只看 WAF 相关
新增(直接入库,仅手动操作):add_experience(title="Nginx 403 绕过", detail="...", scenario_tags=["WAF绕过"], tool_type="burp", status="approved")
新增草稿:add_experience(title="...", detail="...") # 默认 status='draft',待审批
查重:find_similar(title="...", detail="...")
查看单条:get_experience(experience_id="...")
修改:update_experience(experience_id="...", detail="...") # 只更新传入字段
查看草稿:list_pending_experiences()
审批:approve_experience(experience_id="...") # 或 merge_with_id 合并
拒绝:reject_experience(experience_id="...") # 软删除,可恢复
删除:delete_experience(experience_id="...") # 软删除已审批经验
恢复:restore_experience(experience_id="...")
回收站:list_deleted_experiences()
清理:purge_experiences(days=30) # 物理删除超期软删记录
列出:list_all_experiences(limit=50, offset=0) # 分页Skill encapsulation
Already wrapped as a custom Skill, located in SKILL.md in the project root directory, organized into six phases by execution flow:
Phase 1: Intent determination
Phase 2: Information gathering first
Phase 3: Database lookup trigger
Phase 4: Result citation and answering
Phase 5: Execution and exemption rules
Phase 6: Experience accumulation
Put SKILL.md into the custom Skill directory to load it.
Security notes
Database credentials are injected only via environment variables; the repository contains no real connection information
Rotate the database password regularly and avoid using weak passwords
Available Tools
13 toolsadd_experienceB
往经验库中新增一条渗透测试经验。 参数: title: 经验标题,如 'Nginx 403 绕过' detail: 详细描述,包括漏洞类型、利用过程、关键payload等 scenario_tags: 场景标签列表(可选),如 ['WAF绕过', 'SQL注入'] tool_code: 利用/工具代码(可选) tool_type: 工具类型(可选),如 'sqlmap'、'burp' status: 'draft'(存为待审批草稿,默认)或 'approved'(直接入库)
Inputs: title (required), detail (required), status, tool_code, +2 more. Returns: result
approve_experienceB
审批通过一条待审批草稿。 参数: experience_id: 草稿的 id merge_with_id: 可选。提供时,将草稿内容合并进指定记录(详情追加、标签合并、工具信息补全),然后删除草稿
Inputs: experience_id (required), merge_with_id. Returns: result
delete_experienceA
软删除一条已审批经验(状态置为 deleted,不参与检索,可恢复)。 参数: experience_id: 经验的 id
Inputs: experience_id (required). Returns: result
find_similarA
查重:查找与给定标题/详情相似的已入库经验,用于避免重复录入。 参数: title: 待查重的标题 detail: 待查重的详情(可选)
Inputs: title (required), detail. Returns: result
get_experienceC
按 id 获取一条经验的完整内容(标题、详情、标签、工具代码、状态等)。 参数: experience_id: 经验的 id
Inputs: experience_id (required). Returns: result
list_all_experiencesA
分页列出经验库中所有已审批记录的标题。 参数: limit: 每页条数(默认 50,最大 200) offset: 偏移量(默认 0)
Inputs: limit, offset. Returns: result
list_deleted_experiencesA
列出所有软删除的记录(被拒绝的草稿 + 被删除的经验),便于恢复或彻底清理。
Inputs: no named parameters. Returns: result
list_pending_experiencesA
列出待审批的经验草稿,并提示每条草稿可能重复的已入库记录。
Inputs: no named parameters. Returns: result
purge_experiencesA
彻底删除软删除超过指定天数的记录(物理删除,不可恢复,请谨慎)。 参数: days: 保留天数,软删除超过该天数的记录将被物理删除(默认 30)
Inputs: days. Returns: result
reject_experienceA
拒绝一条待审批草稿(软删除:记录保留,状态置为 rejected,可恢复)。 参数: experience_id: 草稿的 id
Inputs: experience_id (required). Returns: result
restore_experienceB
恢复一条软删除的记录:被拒绝的草稿恢复为 draft,被删除的经验恢复为 approved。 参数: experience_id: 记录的 id
Inputs: experience_id (required). Returns: result
search_experienceA
搜索渗透测试经验库(仅已审批记录)。基于 BM25 相关性排序,支持中文分词。 参数: keyword: 搜索关键词,如 'WAF绕过'、'SQL注入'、'403' tags_filter: 场景标签过滤(可选),如 ['WAF绕过'],仅返回包含全部指定标签的记录
Inputs: keyword (required), tags_filter. Returns: result
update_experienceB
更新一条经验的字段(只更新传入的字段,未传字段保持不变)。修改前自动做脱敏校验。 参数: experience_id: 经验的 id title: 新标题(可选) detail: 新详情(可选) scenario_tags: 新标签列表(可选) tool_code: 新工具代码(可选) tool_type: 新工具类型(可选) status: 新状态(可选,approved/draft/rejected/deleted)
Inputs: experience_id (required), title, detail, status, +3 more. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 13 tools
Most tools have clearly distinct purposes: the three list_* tools are scoped by status (all/pending/deleted), and search vs. list vs. find_similar are distinguishable. However, update_experience can also set status to approved/rejected, overlapping with the dedicated approve_experience and reject_experience tools, and the delete/reject/purge triad requires careful reading to tell apart.
All 13 tools follow a consistent snake_case verb_noun pattern (list_*, get_*, add_*, update_*, delete_*, restore_*, approve_*, reject_*, search_experience, find_similar, purge_experiences). No convention mixing.
13 tools is well-scoped for a knowledge base with CRUD, search, moderation workflow, dedup, and soft-delete lifecycle. Each tool earns its place with a distinct role.
Full lifecycle is covered: create/add, get, update, search, paginated listing, approval/rejection moderation, dedup checking, soft-delete, restore, and physical purge. No obvious dead ends for the stated domain.
Maintenance
Related MCP Connectors
Search and manage your team's knowledge from MCP clients.
Personal knowledge base MCP server with semantic search, auto-categorization, metadata extraction
Cloud or self-hosted knowledge for AI agents: hybrid search, reranking, GraphRAG, scoped MCP tools.
A shared team wiki your coding agents read and write — across every repo and every MCP client.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides AI agents with persistent knowledge storage, enabling them to store, search, and retrieve text, documents, and files using semantic and keyword search via MCP tools.35Apache 2.0
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to query and manage a document knowledge base via MCP, with RAG-powered search and grounded answers with citations.MIT
- AlicenseAqualityDmaintenanceA knowledge base MCP server that aggregates team knowledge from multiple sources into Postgres. It provides hybrid search (full-text + vector + RRF) via MCP tools, and enables direct recording of decisions, learnings, and pitfalls.151MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents and MCP clients to search, retrieve, and read documents across unified knowledge sources including ShowDoc, GitHub, Gitee, ZenTao, Evernote, and Tencent Docs. It also supports connecting external MCP servers as additional knowledge sources.MIT