Skip to content

Add MCP CLI layer, security hardening, and documentation overhaul#1

Open
Krapa007 wants to merge 13 commits into
SriramGanne:mainfrom
Krapa007:main
Open

Add MCP CLI layer, security hardening, and documentation overhaul#1
Krapa007 wants to merge 13 commits into
SriramGanne:mainfrom
Krapa007:main

Conversation

@Krapa007
Copy link
Copy Markdown

  • MCP CLI layer — PromptPilot now ships as a standalone MCP server
    (promptpilot-mcp on npm). Every user prompt is intercepted via the
    optimize_prompt tool before Claude responds, with zero configuration
    required for end users.

  • Claude Code plugin — Added .claude-plugin/manifest.json for one-click
    install from the Claude Code plugin marketplace. Users are prompted for their
    API keys; no manual JSON editing needed.

  • Security hardening — Four vulnerabilities patched:

    • Prompt injection markers (### PROMPT START, <thinking>, etc.) stripped
      from rawPrompt before it enters the pipeline
    • Redis cache payloads validated against an allowlist before being returned
      as Claude's operating instruction (prevents cache poisoning)
    • RAG chunks XML-isolated in the system prompt with explicit "inert data"
      instruction and per-chunk length caps (prevents RAG content injection)
    • writeState() key allowlist prevents poisoned state from persisting to disk
  • Secret management — .claude/settings.json, .mcp.json, and .env*
    added to .gitignore. Git history scrubbed with git-filter-repo to remove
    previously committed credentials.

  • Env loading — Config now reads both .env and .env.local with
    deduplication; installer injects keys from both files.

  • Documentation — README rewritten with architecture diagram, security
    section, and three install options. New ARCHITECTURE.md with full pipeline
    diagram, security measures, and secret management reference. CLAUDE.md bug
    fixed (skipClarification retry logic corrected).

Test plan

  • Run node bin/mcp.js and verify stdio MCP server starts without error
  • Run node bin/promptpilot.js install and confirm .claude/settings.json
    is updated with injected keys
  • Confirm git log --all -p | grep tgp_v1_ returns no output
  • Confirm .env, .mcp.json, .claude/settings.json are not tracked
    (git status shows them as untracked or ignored)
  • Send a prompt through Claude Code and verify optimize_prompt is called
    and returns an optimizedPrompt
  • Send a prompt containing ### PROMPT START and verify it is redacted

SriramGanne and others added 13 commits April 20, 2026 11:02
Renamed the project from PromptBuddy to PromptPilot.
Updated the README to enhance clarity and structure, adding sections on product features, technical architecture, installation, and roadmap.
Removed mention of the Quality Gate framework using Claude Sonnet 4.6.
Adds a self-contained CLI (`cli/`) that installs PromptPilot as an MCP
server into Claude Code, intercepting every user prompt before Claude
responds to it — similar to how GitNexus intercepts symbol lookups.

- `promptpilot init` wires the MCP server into .claude/settings.json and
  appends the interception hook to CLAUDE.md; auto-injects keys from .env.local
- `promptpilot remove / status / config` for lifecycle management
- MCP server runs the full pipeline: gap analysis → semantic cache →
  RAG retrieval → Gemma 3n synthesis, all self-contained (no Next.js deps)
- Short-circuits trivial inputs (< 6 words) with zero API calls
- Falls back to raw prompt on pipeline error so Claude is never blocked
- Ignores cli/node_modules and cli/package-lock.json via .gitignore

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Publish package as `promptpilot-mcp` with `promptpilot-mcp` binary entry point
- Add `cli/bin/mcp.js` as the MCP server entrypoint (via stdio transport)
- Add `.claude-plugin/manifest.json` for one-click Claude Code plugin install
- Add `marketplace.json` for plugin marketplace registration
- Extend env config loading to read both `.env` and `.env.local` (with dedup)
- Update installer to inject keys from both env files, skipping already-set keys
- Add `.mcp.json` to .gitignore to prevent committing local credentials
- Update README: MCP architecture, npx install, plugin install, npm package link

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- README: embed high-level pipeline flowchart in the Technical Architecture section
- ARCHITECTURE.md: new dedicated file with full pipeline diagram, component table,
  data flow summary, fallback guarantee, and external services reference
- Diagrams reflect actual code: gap analysis → embed+cache → RAG retrieval → synthesis

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The file held live Together AI, Supabase, and Upstash credentials.
Untrack it and add to .gitignore so local keys are never committed.
All exposed keys must be rotated immediately.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…e pollution

Finding 2 — Redis cache payload poisoning (embedAndCache.js, semanticCache.js):
  Add validateCachedPayload() allowlist before spreading any Redis-sourced data
  into the MCP response. Rejects entries missing optimizedPrompt, caps length
  at 8000 chars, and strips all non-whitelisted keys in both CLI and web paths.

Finding 3 — RAG content injected verbatim into LLM system prompt (synthesis.js):
  Wrap each RAG chunk in <research_chunk> XML tags with an explicit instruction
  to treat content as inert data. Escape </research_chunk> sequences that could
  break out of the wrapper. Cap chunk content at 800 chars and titles at 200.

Finding 4 — State file written with unvalidated merged data (mcp-server.js):
  writeState() now uses ALLOWED_STATE_KEYS allowlist when reading existing state
  and when writing new data — prevents poisoned state keys from persisting.

Finding 5 — Prompt injection markers not stripped in CLI pipeline (mcp-server.js):
  sanitizeRawPrompt() strips ### PROMPT START/END and internal XML tags from
  rawPrompt before it enters the pipeline, matching the web API's existing defence.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
CLAUDE.md:
  - Fix skipClarification: false → true on clarification retry (was causing
    gap analysis to re-run instead of forcing synthesis after user answers)
  - Add explicit handling for skipped: true / fallback: true cases
  - Align wording with .claude-plugin/manifest.json claudeMd field

ARCHITECTURE.md:
  - Add sanitizeRawPrompt() step to pipeline diagram
  - Add validateCachedPayload() step to Embed & Cache subgraph
  - Add escapeChunkContent() step to Synthesis subgraph
  - New Security Measures section documenting all four defences:
    prompt injection sanitization, Redis cache payload validation,
    RAG content XML isolation, state file key allowlist
  - Add Secret Management table (which files are gitignored and why)
  - Update Component Responsibilities table to include lib/ files

README.md:
  - Add Security section with defence summary table and link to ARCHITECTURE.md
  - Update Evaluator-Optimizer Loop: sanitize step added as step 1,
    cache now described as "validated", RAG described as "XML-isolated"

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- cli/package.json: update author name/email and repository/homepage URLs
- .claude-plugin/manifest.json: update author field

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 27, 2026

@Krapa007 is attempting to deploy a commit to the SriramGanne's projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants