home / mcp / prompt cleaner mcp server

Prompt Cleaner MCP Server

TypeScript MCP server that cleans prompts, redacts secrets, and normalizes output

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "dacebt-prompt-cleaner-mcp": {
      "command": "node",
      "args": [
        "/absolute/path/to/prompt-cleaner/dist/server.js"
      ],
      "env": {
        "LLM_MODEL": "open/ai-gpt-oss-20b",
        "LOG_LEVEL": "info",
        "LLM_API_KEY": "YOUR_API_KEY",
        "LLM_API_BASE": "http://localhost:1234/v1",
        "LLM_BACKOFF_MS": "250",
        "LLM_TIMEOUT_MS": "60000",
        "LLM_MAX_RETRIES": "1",
        "ENFORCE_LOCAL_API": "false",
        "LLM_BACKOFF_JITTER": "0.2",
        "RETOUCH_CONTENT_MAX_RETRIES": "1"
      }
    }
  }
}

You have a TypeScript MCP server that exposes a prompt cleaning tool and health checks. It routes prompts through a cleaner, redacts secrets, returns a structured output, and can be run locally for deterministic behavior. This guide shows you how to install, run, and configure it, plus how to integrate it with an MCP client for practical prompt sanitization and safety checks.

How to use

You interact with the server through an MCP client by invoking tools provided by the Prompt Cleaner MCP server. The two primary tools are health-ping and cleaner. Use health-ping to verify the server is responsive. Use cleaner to process a raw prompt, producing a retouched string and structured metadata such as notes, open questions, risks, and redactions. You can also access aliases like sanitize-text and normalize-prompt, which expose the same behavior under different tool names for compatibility with various agents.

How to install

# Prerequisites
node --version
# Node.js must be >= 20
# If you don’t have dependencies installed yet
npm install

# Build the project
npm run build

# Start the dev (stdio) server
npm run dev
```} ,{

Configuration and running locally

Configure the server with environment variables to control the LLM backend, model policy, timeouts, and logging. You can place these in a .env file or export them in your shell. The key options include the base URL for the LLM API, your API key, the model identifier, and timing/backoff settings.

Example environment configuration to start from a local development setup is shown below. Adapt values to your environment.

LLM_API_BASE=http://localhost:1234/v1
LLM_MODEL=open/ai-gpt-oss-20b
LLM_API_KEY=sk-xxxxx
LLM_TIMEOUT_MS=60000
LOG_LEVEL=info
ENFORCE_LOCAL_API=false
LLM_MAX_RETRIES=1
RETOUCH_CONTENT_MAX_RETRIES=1
LLM_BACKOFF_MS=250
LLM_BACKOFF_JITTER=0.2
```}]} ,{

Troubleshooting

If you encounter timeouts, increase LLM_TIMEOUT_MS and verify network reachability to LLM_API_BASE. If the cleaner occasionally returns non-JSON content, retry up to RETOUCH_CONTENT_MAX_RETRIES and consider adjusting temperature or the model to align with the output contract. For HTTP 5xx responses from the LLM, the client will retry up to LLm_MAX_RETRIES with exponential backoff (LLM_BACKOFF_MS and LLM_BACKOFF_JITTER). If ENFORCE_LOCAL_API=true, ensure LLM_API_BASE points to localhost. Redaction helps prevent secrets from leaking in logs and outputs; update redaction patterns if you detect leaks.

Notes on usage and security

All secrets are scrubbed from logs and cleaner outputs by the redaction utilities. This server operates under a single-model policy controlled by LLM_MODEL to maintain determinism. Output normalization ensures clients that reject JSON content types receive plain text when necessary.

Appendix: Example integration

{
  "mcpServers": {
    "prompt_cleaner": {
      "command": "node",
      "args": ["/absolute/path/to/prompt-cleaner/dist/server.js"]
    }
  }
}

Available tools

health-ping

Liveness probe returning { ok: true } to verify the MCP server is responsive.

cleaner

Process a raw prompt through the cleaner, returning a structured JSON with retouched text, notes, openQuestions, risks, and redactions.

sanitize-text

Alias of cleaner for agents that seek keyword matches on redaction or PII handling.

normalize-prompt

Alias of cleaner for agents that seek formatting or preprocessing workflows.