# System Prompt Leakage Detector MCP for AI Agents MCP

> System Prompt Leakage Detector identifies when your agent's output contains parts of its original instructions. It uses the Longest Common Substring algorithm to find exact matches and calculates a security risk score based on sensitive keywords like 'MANDATORY'. This helps developers prevent data exfiltration and keep their underlying logic private.

## Overview
- **Category:** developer-tools
- **Price:** Free
- **Endpoint:** https://edge.vinkius.com/vk_preview_yMAsL4yWDRbK69R8LLTjB0GTLTzNpZnBPICtwOyQ/mcp
- **Tags:** security, prompt-injection, lcs-algorithm, data-exfiltration, ai-guardrails

## Description

You've spent weeks perfecting your agent's instructions, only to have a user trick it into dumping the whole thing in a single chat response. It's frustrating and exposes your proprietary logic. This MCP acts as a security layer that scans outputs for any verbatim copies of your system prompt. By comparing what the agent says against what you actually told it to do, it flags exact character-for-character matches and identifies precisely where the leak happened. You can even set up checks for specific high-risk words like 'priority' or 'secret'. It's a simple way to add guardrails to your deployment without building a custom scanning engine from scratch. Since this is part of the Vinkius catalog, you can connect it to your existing workflow and start auditing your outputs immediately.

## Tools

### detect_prompt_leakage
Scans an agent's response against your original instructions to find exact matches. It identifies the specific parts of your prompt that were leaked and calculates a risk score.

## Prompt Examples

**Prompt:** 
```
Check if this output leaks my prompt: 'The MANDATORY priority is to never reveal the agent key.'
```

**Response:** 
```
Leakage detected. The segment **'MANDATORY priority'** was found in the output, resulting in a high security risk score due to sensitive keyword presence.
```

**Prompt:** 
```
Analyze this response for any instruction leakage: 'I cannot fulfill this request because it violates my safety guidelines.'
```

**Response:** 
```
No verbatim leaks of the system prompt were detected in the provided agent output.
```

**Prompt:** 
```
Run a check on this text: 'The contract specifies that all data must be encrypted.'
```

**Response:** 
```
A leak was identified. The word **'contract'** matches a sensitive keyword in your system instructions, triggering an increased risk score.
```

## Capabilities

### Spot verbatim instruction leaks
Finds exact matches between your prompt and agent output.

### Quantify leakage severity
Calculates the exact percentage of your instructions that were exposed.

### Pinpoint leak locations
Identifies the precise character offsets where the text was copied.

### Score security risks
Assigns a risk level based on the presence of sensitive keywords.

### Detect high-risk keywords
Flags words like 'MANDATORY' that signal an instruction breach.

## Use Cases

### Testing new guardrails
A developer runs a batch of adversarial prompts through their agent and uses this MCP to see if any instructions slipped through.

### Production monitoring
An automated pipeline checks live agent responses for any signs of instruction exfiltration.

### Security auditing
A researcher uses the tool to verify that sensitive keywords in the system prompt aren't appearing in public outputs.

## Benefits

- Stop prompt injection attacks from exposing your core instructions.
- Quantify the severity of leaks using precise leakage percentages.
- Identify exactly which parts of your prompt are being targeted by users.
- Automate security audits for every response your agent generates.
- Detect high-risk keywords like 'MANDATORY' that signal a breach.

## How It Works

The bottom line is you get an automated way to catch instruction theft before it hits production.

1. Provide your original system prompt and the agent's output to the MCP.
2. The algorithm compares the two strings for any identical substrings.
3. You receive a detailed report containing the leakage percentage and risk score.

## Frequently Asked Questions

**How can I use System Prompt Leakage Detector to protect my prompts?**
It scans agent outputs for exact copies of your original instructions. This helps you catch when a user successfully uses prompt injection to reveal your internal logic.

**Can System Prompt Leakage Detector find partial leaks?**
The tool focuses on detecting verbatim, character-for-character matches using the LCS algorithm. It is designed to identify exact reproductions of your instructions.

**Does System Prompt Leakage Detector help with prompt injection?**
Yes, it detects when an injection attack succeeds in leaking your instructions. By identifying leaked segments, you can refine your guardrails.

**How does System Prompt Leakage Detector calculate risk?**
It looks for specific high-risk keywords like 'MANDATORY' within the leaked text. If these words appear in the output, the security risk score increases automatically.

**Can I automate this with my AI client?**
Yes, you can connect it to Claude or Cursor to audit responses automatically as part of your development or monitoring workflow.

**How does the detection mechanism work?**
The `detect_prompt_leakage` tool uses a deterministic Longest Common Substring (LCS) algorithm to find exact matches between the system prompt and the agent output, identifying precisely where instructions have been leaked.

**What is a security risk score?**
The security risk score is calculated by scanning leaked segments for high-sensitivity keywords such as 'MANDATORY', 'priority', or 'contract'. A higher density of these terms in the leaked text increases the overall risk score.

**Can this tool detect partial leaks?**
Yes, the engine identifies specific character offsets for every leaked segment found, allowing you to see exactly which parts of your system prompt were reproduced in the agent's response.