Source profileQuality 93/100

brucesongs/kali-claw/skills/mcp-server-patterns/SKILL.md

mcp-server-patterns

Building and security-testing MCP (Model Context Protocol) servers for Kali Linux security tools.

Source repository stars
67
Declared platforms
2
Static risk flags
1
Last source update
2026-08-19
Source checked
2026-08-28

Decision brief

What it does: where it fits

Supplementary Files: - payloads.md — Complete Python code templates, tool wrapping scaffolds, input validation snippets, auth middleware, rate limiting patterns, and MCP security testing commands - test-cases.md — Structured test cases covering tool wrapping verification, input…

Best for

  • Wrap nmap as an MCP tool: Expose nmap's network scanning capability via a typed tool call with validated inputs, structured JSON output, and per-client rate limiting — enabling the agent to scan targets without construc…
  • Wrap sqlmap as an MCP tool: Create a controlled sqlmap interface with target allowlisting, flag whitelisting, and output parsing, so the agent can invoke SQL injection testing through a safe, audited interface
  • Build a reusable security tool library for agents: Assemble a suite of MCP tools (nmap, nikto, gobuster, sqlmap, whatweb) into a single MCP server that any agent session can connect to, establishing a persistent, authen…

Not for

  • Tasks that require unconfirmed production actions or broad system permissions.
  • Environments where the pinned source and install steps cannot be inspected.

Compatibility matrix

Platform support, with evidence labels

PlatformStatusEvidenceWhat to check
CodexNot declaredNo explicit evidencePortability before use
Claude CodeDeclaredSource recordInstall path and trigger
CursorDeclaredSource recordInstall path and trigger
Gemini CLINot declaredNo explicit evidencePortability before use
Open the compatibility checker

Installation

Inspect first. Install second.

The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.

Source-detected install commandSource
npx skills add https://github.com/brucesongs/kali-claw --skill "skills/mcp-server-patterns"
Safe inspection promptEditorial

Inspect the Agent Skill "mcp-server-patterns" from https://github.com/brucesongs/kali-claw/blob/a3205f5484ca8fec9fd809f3c16fe41fbc6ac87e/skills/mcp-server-patterns/SKILL.md at commit a3205f5484ca8fec9fd809f3c16fe41fbc6ac87e. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.

Workflow

What the source asks the agent to do

  1. 01

    Summary

    Mcp Server Patterns skill domain covering infrastructure operations.

    Mcp Server Patterns skill domain covering infrastructure operations.Tools: Tools, Resources, Prompts, stdio, HTTP/SSE
  2. 02

    Description

    Building and security-testing MCP (Model Context Protocol) servers for Kali Linux security tools. Covers wrapping tools as structured APIs with input validation, subprocess safety, authentication, and rate limiting, plus auditing MCP server implementations for authentication wea…

    Building and security-testing MCP (Model Context Protocol) servers for Kali Linux security tools. Covers wrapping tools as structured APIs with input validation, subprocess safety, authentication, and rate limiting, plu…
  3. 03

    Use Cases

    Wrap nmap as an MCP tool: Expose nmap's network scanning capability via a typed tool call with validated inputs, structured JSON output, and per-client rate limiting — enabling the agent to scan targets without construc…

    Wrap nmap as an MCP tool: Expose nmap's network scanning capability via a typed tool call with validated inputs, structured JSON output, and per-client rate limiting — enabling the agent to scan targets without construc…Wrap sqlmap as an MCP tool: Create a controlled sqlmap interface with target allowlisting, flag whitelisting, and output parsing, so the agent can invoke SQL injection testing through a safe, audited interfaceBuild a reusable security tool library for agents: Assemble a suite of MCP tools (nmap, nikto, gobuster, sqlmap, whatweb) into a single MCP server that any agent session can connect to, establishing a persistent, authen…
  4. 04

    MCP Server Architecture

    An MCP server exposes three primitive types:

    An MCP server exposes three primitive types:For security tool wrapping, tools are the primary primitive. A tool definition has four fields:The AI (Claude) reads the tool list, decides which tool to call, constructs a JSON argument object matching the inputSchema, and sends it to the server. The server validates the arguments, executes the handler, and retu…
  5. 05

    Core Components

    An MCP server exposes three primitive types:

    An MCP server exposes three primitive types:For security tool wrapping, tools are the primary primitive. A tool definition has four fields:The AI (Claude) reads the tool list, decides which tool to call, constructs a JSON argument object matching the inputSchema, and sends it to the server. The server validates the arguments, executes the handler, and retu…

Permission review

Static risk signals and limitations

Network access

medium · line 119

The documentation includes network, browsing, or remote request actions.

Track request timestamps per client identifier (API key or IP)

Evidence record

Why each signal appears

EvidenceSourceComputedTestedEditorial
SignalValueEvidence typeMeaning
Quality score93/100ComputedDocumentation, specificity, maintenance, and trust rules
Repository stars67SourceRepository attention, not individual Skill quality
Compatibility2 platformsSourceDeclared in the catalog source record
Usage guideautomated source guideEditorialGenerated or reviewed according to the visible evidence level

Pinned source

Provenance and original SKILL.md

Repository
brucesongs/kali-claw
Skill path
skills/mcp-server-patterns/SKILL.md
Commit
a3205f5484ca8fec9fd809f3c16fe41fbc6ac87e
License
MIT
Collected
2026-08-28
Default branch
main
View the original SKILL.md

Skill: MCP Server Patterns

Supplementary Files:

  • payloads.md — Complete Python code templates, tool wrapping scaffolds, input validation snippets, auth middleware, rate limiting patterns, and MCP security testing commands
  • test-cases.md — Structured test cases covering tool wrapping verification, input validation enforcement, authentication testing, rate limiting, and full MCP security audit
  • guides/security-mcp-server-design.md — Deep-dive guide on tool selection, protocol fundamentals, secure wrapping principles, implementation walkthrough, testing, and deployment

Summary

Mcp Server Patterns skill domain covering infrastructure operations.

Tools: Tools, Resources, Prompts, stdio, HTTP/SSE

Domain: infrastructure

Description

Building and security-testing MCP (Model Context Protocol) servers for Kali Linux security tools. Covers wrapping tools as structured APIs with input validation, subprocess safety, authentication, and rate limiting, plus auditing MCP server implementations for authentication weakness, command injection, schema abuse, and information disclosure.

Use Cases

  • Wrap nmap as an MCP tool: Expose nmap's network scanning capability via a typed tool call with validated inputs, structured JSON output, and per-client rate limiting — enabling the agent to scan targets without constructing raw shell commands each time
  • Wrap sqlmap as an MCP tool: Create a controlled sqlmap interface with target allowlisting, flag whitelisting, and output parsing, so the agent can invoke SQL injection testing through a safe, audited interface
  • Build a reusable security tool library for agents: Assemble a suite of MCP tools (nmap, nikto, gobuster, sqlmap, whatweb) into a single MCP server that any agent session can connect to, establishing a persistent, authenticated API for the full toolset
  • Build a custom security tool API: Expose project-specific scripts (custom exploit PoCs, recon aggregators, reporting generators) as MCP tools with schema-enforced inputs and structured outputs
  • Test MCP server authentication: Audit an MCP server's API key validation, token expiration, and missing-auth behavior — verifying that unauthenticated callers are rejected with appropriate error codes rather than partial responses
  • Audit MCP tool input validation: Fuzz tool input schemas with malformed types, injection strings, out-of-scope targets, and boundary values — confirming that all inputs are rejected before reaching subprocess execution

MCP Server Architecture

Core Components

An MCP server exposes three primitive types:

PrimitivePurposeExample
ToolsFunctions the AI calls to take actionsrun_nmap, check_url, parse_output
ResourcesData the AI reads (like files or DB records)scan_results, target_list
PromptsTemplated instructions the AI can requestpentest_report_template

For security tool wrapping, tools are the primary primitive. A tool definition has four fields:

name        — unique identifier the AI uses to invoke the tool
description — natural language explanation of what the tool does and when to use it
inputSchema — JSON Schema describing required/optional parameters and their types
handler     — the Python function that executes when the AI calls the tool

The AI (Claude) reads the tool list, decides which tool to call, constructs a JSON argument object matching the inputSchema, and sends it to the server. The server validates the arguments, executes the handler, and returns a structured result.

Security Tool Wrapping Pattern

The canonical wrapping pattern follows this sequence:

AI tool call (JSON args)
       ↓
Input validation (schema + allowlist checks)
       ↓
Subprocess construction (shlex.split, no shell=True)
       ↓
Subprocess execution (timeout enforced)
       ↓
Output parsing (structured JSON from raw stdout)
       ↓
Error sanitization (no stack traces, no internal paths)
       ↓
Structured response returned to AI

Each step is a mandatory gate. Skipping input validation before subprocess construction is the primary attack surface in MCP servers that wrap shell tools.

Transport Modes

ModeHow It WorksSecurity Implications
stdioServer communicates over stdin/stdout; launched as child processDefault for Claude Desktop; no network exposure; authentication handled by OS-level process isolation
HTTP/SSEServer runs as HTTP service; AI sends POST requests; Server-Sent Events for streamingExposed to network; requires explicit authentication (API key, OAuth); TLS mandatory for remote deployment

For penetration testing use cases, HTTP/SSE transport introduces a real attack surface — the server becomes a network service accepting arbitrary JSON from callers.

Building Secure MCP Servers

Tool Design Principles

  1. Minimal permissions: Each tool should run under the minimum OS permissions needed for its function. Do not run the MCP server as root.
  2. Explicit input schema: Every parameter must appear in inputSchema with type, description, and constraints (enum for allowed values, pattern for format, minimum/maximum for ranges).
  3. Allowlist validation: Validate inputs against an explicit allowlist (approved targets, approved flags), not a denylist (blocked strings). Denylists always have gaps.
  4. No shell=True: Construct subprocess arguments as a list (["nmap", "-sV", target]), never as a shell string. shell=True with any user-controlled input is command injection.
  5. Explicit timeouts: Every subprocess call must have a timeout parameter. Unbounded execution enables denial of service.
  6. Structured output only: Parse tool output into a JSON-serializable dict before returning. Never return raw stdout as an unstructured string blob.
  7. Scope enforcement: Maintain an allowlist of authorized target IPs/CIDRs. Reject any target not in scope before executing.

Input Validation Patterns

IP/CIDR validation   — regex match + ipaddress module parse
URL validation       — urllib.parse.urlparse + scheme allowlist
Port range           — integer cast + 1-65535 bounds check
File path            — os.path.realpath + prefix allowlist
Target scope         — ip_network.supernet_of check against authorized_ranges
Tool flags           — set intersection against ALLOWED_FLAGS constant

Authentication

For HTTP/SSE transport, implement token-based authentication on every request:

  • Load the expected API key from an environment variable at startup; fail immediately if missing
  • Validate the X-API-Key header on every incoming request before processing
  • Return HTTP 401 with a generic {"error": "unauthorized"} body — no detail about why the key was rejected
  • Never log the received key value; log only "auth success" or "auth failure" with the client address

Rate Limiting

Per-client limits prevent abuse and limit blast radius if credentials are compromised:

  • Track request timestamps per client identifier (API key or IP)
  • Enforce a sliding window (e.g., 10 requests per 60 seconds per client)
  • Enforce a global limit (e.g., 100 requests per 60 seconds across all clients)
  • Return HTTP 429 with {"error": "rate_limit_exceeded", "retry_after": N} — never silently drop
  • Apply exponential backoff signals in the retry_after field for repeated violations

Error Handling

MCP server errors are a significant information disclosure vector:

  • Catch all exceptions at the tool handler boundary; never let a raw exception propagate to the caller
  • Log the full exception with stack trace server-side (to a file or syslog)
  • Return a sanitized message to the caller: {"error": "tool_execution_failed", "detail": "nmap returned non-zero exit code"}
  • Never include: internal file paths, stack traces, OS usernames, subprocess command strings, environment variable values

Security Testing MCP Servers

Attack Surface

SurfaceAttack VectorGoal
Tool input parametersInjection strings (;, &&, `, $()`)
Input schemaSend wrong types, missing required fieldsSchema bypass, unexpected code path
AuthenticationMissing header, wrong key, replayed tokenUnauthorized tool access
Rate limitingRapid sequential requestsExhaust tool execution, DoS
Error messagesTrigger tool failures deliberatelyInformation disclosure (paths, versions)
Scope validationSubmit out-of-scope targetsExecute tools against unauthorized hosts

Testing Methodology

Step 1 — Schema Fuzzing: Send tool calls with wrong parameter types (string where int expected), missing required fields, extra undeclared fields, and boundary values (empty string, very long string, null).

Step 2 — Injection Testing: For every string input, test: semicolons (; id), shell metacharacters ($(whoami), `id`), path traversal (../../etc/passwd), newlines (\n), and null bytes (\x00).

Step 3 — Auth Bypass: Test: missing X-API-Key header, empty key, key with extra whitespace, key from a different server, expired/rotated key. Verify all return 401 with no partial data.

Step 4 — Rate Limit Bypass: Send requests faster than the limit. Try: different client IPs (X-Forwarded-For spoofing), different API keys per request, large batch requests vs many small ones.

Step 5 — Error Analysis: Trigger failures by passing valid-format-but-broken inputs (unreachable IPs, nonexistent files, malformed URLs). Examine every error response for internal path leakage, version strings, or exception class names.

Step 6 — Scope Bypass: Submit targets just outside the authorized CIDR (adjacent IPs, neighboring subnets). Verify rejection. Test CIDR notation edge cases (host bits set, /0, /32).

Tools

Tool / SDKPurpose
mcp Python SDKOfficial MCP server implementation library (pip install mcp)
fastmcpFastAPI-style high-level MCP server framework for rapid development
httpx / requestsHTTP client for testing HTTP/SSE transport MCP servers
ipaddress (stdlib)IP and CIDR validation in tool handlers
shlex (stdlib)Safe subprocess argument construction
subprocess (stdlib)Tool execution with timeout and output capture
Custom Python scriptsSecurity testing automation (schema fuzzer, injection tester)

Detection Methods

MCP Server Audit

  • Tool description diff: Diff tool descriptions across versions; alert on new exfil capabilities.
  • Server registration: New MCP server registered; alert if not in allowlist.
  • Tool call anomalies: Calls with unexpected parameters; path traversal in read_file.
  • Outbound connections: MCP client connecting to non-default MCP ports (27042, etc.).

SIEM Detection Rules

  • Splunk SPL: index=mcp server.tool="read_file" | where match(params.path, "\.\./\.\./")
  • MCP Inspector / Claude Code audit logs: Per-tool invocation logging.

Defense Evasion Techniques

Tool Poisoning Stealth

  • Legitimate-looking updates: Push tool updates via official channels; descriptions look benign.
  • Gradual capability addition: Add small exfil features across multiple updates; below diff threshold.
  • Poison chained tools: Modify tool A to call tool B (legitimate) with attacker-controlled args.
  • Tool result poisoning: Modify tool results to inject context for next call.

MCP Server Compromise

  • Mimic legitimate MCP: Use known MCP server name (e.g., filesystem, git); inherit trust.
  • Use stdio transport: Local stdio MCP servers; no network footprint.
  • Cross-platform abuse: MCP server runs in multiple Claude Code installs; persistent across projects.

Orchestration

ECC Loop Pattern: Sequential Pipeline

Rationale: MCP server development follows a strict build-test-secure-deploy sequence. Each phase gates the next: schema design must precede implementation, implementation must precede security testing, security testing must pass before deployment. Skipping phases or running them in parallel introduces unvetted code into production.

Integration:

  • Feeds into: terminal-ops (MCP server enables structured tool execution replacing ad-hoc shell commands), autonomous-loops (MCP tools called within agent autonomy loops), multi-agent-collaboration (shared MCP server exposes tools across multiple agent sessions)
  • Consumes from: security-review (audit the MCP server implementation itself before deployment), verification-loop (confirm tool outputs are correct and reproducible)

Cross-Skill Pipeline:

[Identify security tools to wrap]
         ↓
mcp-server-patterns → [Design tool schemas + input validation rules]
         ↓
mcp-server-patterns → [Implement server: handlers, auth, rate limiting]
         ↓
security-review     → [Audit the MCP server implementation itself]
         ↓
verification-loop   → [Confirm tool outputs are correct and consistent]
         ↓
[Deploy + integrate with agent workflows]

Quality Gate: Before deploying any MCP server:

  1. All tool inputs validated against JSON Schema before reaching handler code
  2. No shell=True in any subprocess call — verified by grep
  3. Authentication implemented and tested with missing/invalid key scenarios
  4. Rate limiting configured with both per-client and global limits
  5. Error messages sanitized — no stack traces, no internal paths in responses
  6. All tool outputs structured as JSON-serializable dicts
  7. Authorized target scope defined and enforced before any tool execution

Frequently asked questions

What to verify before installation and use

What does the mcp-server-patterns source document cover?

Supplementary Files: - payloads.md — Complete Python code templates, tool wrapping scaffolds, input validation snippets, auth middleware, rate limiting patterns, and MCP security testing commands - test-cases.md — Structured test cases covering tool wrapping verification, input…

How do I install mcp-server-patterns?

The source record exposes this install command: npx skills add https://github.com/brucesongs/kali-claw --skill "skills/mcp-server-patterns". Inspect the command and pinned source before running it.

Which Agent platforms does the source record declare?

The pinned source record declares support for: claude code, cursor.

Which permission-related actions were detected?

Static rules flagged network in the source; the page lists the matching lines and excerpts.

Alternatives

Compare before choosing

Computed 97211

PramodDutta/qaskills

Pairwise Test Generator

Generate optimized test combinations using pairwise (all-pairs) testing algorithms to achieve maximum coverage with minimum test cases across multiple input parameters

Computed 97211

PramodDutta/qaskills

Test Case Generator from User Stories

Automatically generate comprehensive test cases from user stories and acceptance criteria using BDD patterns, equivalence partitioning, and risk-based prioritization

Computed 9421

upex-galaxy/agentic-qa-boilerplate

test-automation

Plan, write, and review automated tests following KATA (Komponent Action Test Architecture) on Playwright + TypeScript, or explain existing automated tests in a sealed read-only mode. Use when writing E2E or API/integration tests, creating Page or Api components, designing ATCs, parameterizing test data, registering fixtures, reviewing test code for KATA compliance, or requesting break-down-tests / a plain-English test breakdown. The explain mode reads source and reports assertions without enter

Computed 9421

upex-galaxy/agentic-qa-boilerplate

test-documentation

Analyze, prioritize, and document test cases in TMS (Jira/Xray), or repair an existing Story-ATS-ATP-ATR-TC cascade through a sealed explicit mode. Use for Test/ATP/ATR artifacts, ROI and automation verdicts, maintaining traceability, fix-traceability, or broken TMS links. The repair-traceability mode audits, plans, waits for explicit approval, applies, and verifies without launching the general documentation workflow. Do NOT use for writing test code (test-automation) or running suites (regress