# Promptguard — canonical payload contracts

Host-side prompt injection gate (normalize + structural + intent + soft neural stack: attack, discourse, gated secondary semantic encoder + policy; optional sticky session risk, spotlight/canary). Call from orchestrator BEFORE every main LLM call — never via model tool-choice. Returns injection bool + score; caller applies policy. Pass session_id for multi-turn sticky risk. Detection is imperfect — enforce tool allowlists, least privilege, and human approval for dangerous ops.

**Service id:** `promptguard`  
**Docs:** [https://mcp.glc-rag.hu/guide/promptguard](https://mcp.glc-rag.hu/guide/promptguard)  
**Markdown docs:** [https://mcp.glc-rag.hu/guide/promptguard.md](https://mcp.glc-rag.hu/guide/promptguard.md)  
**MCP resource:** `docs://promptguard/payload`

POST `https://mcp.glc-rag.hu/mcp`. Values below are **type slots** from the live input schema (e.g. `<string, required>`), not example data. Fill them from the user task.

RPC result wrapper: `result.structuredContent` is the object in **Output schema**. `result.isError` mirrors `structuredContent.is_error`.

## `promptguard_check`

Check one untrusted text for prompt injection (intent + source + impact; layered normalize/structural/discourse/intent/soft-neural/policy). Optional session_id enables multi-turn sticky risk floor. Returns injection: true|false, score, intent, policy. HOST MUST call before every main LLM call — not via model tool-choice.

**Required arguments:** `text`

**Request contract**

```json
{
  "jsonrpc": "2.0",
  "id": "<integer|string>",
  "method": "tools/call",
  "params": {
    "name": "promptguard_check",
    "arguments": {
      "text": "<string, required>",
      "context": "<string, optional, enum user_prompt|rag_chunk|tool_result, default 'user_prompt'>",
      "locale": "<string, optional>",
      "session_id": "<string, optional, maxLength 128>",
      "sticky_reset": "<boolean, optional, default False>"
    }
  }
}
```

**Input schema**

```json
{
  "type": "object",
  "properties": {
    "text": {
      "type": "string",
      "description": "Single new untrusted delta (not full history)"
    },
    "context": {
      "type": "string",
      "enum": [
        "user_prompt",
        "rag_chunk",
        "tool_result"
      ],
      "description": "Source of the text slice (changes policy)",
      "default": "user_prompt"
    },
    "locale": {
      "type": "string",
      "description": "Optional locale hint for audit/logging only (e.g. hu/en). Not required for detection — the pipeline is multilingual and does not switch models or rules based on this field."
    },
    "session_id": {
      "type": "string",
      "description": "Optional chat/run id (max 128). When set, enables server-side sticky risk across turns for this org (multi-turn / crescendo). Omit for classic single-delta checks.",
      "maxLength": 128
    },
    "sticky_reset": {
      "type": "boolean",
      "description": "If true with session_id, clear prior sticky state before this check (new conversation reuse of the same id).",
      "default": false
    }
  },
  "required": [
    "text"
  ],
  "additionalProperties": false
}
```

**Output schema** (`structuredContent` on success)

```json
{
  "type": "object",
  "properties": {
    "injection": {
      "type": "boolean"
    },
    "score": {
      "type": "integer"
    },
    "intent": {
      "type": "string"
    },
    "policy": {
      "type": "object"
    },
    "meta": {
      "type": "object"
    }
  },
  "additionalProperties": true,
  "required": [
    "injection",
    "score"
  ]
}
```

**Error object**

```json
{
  "type": "object",
  "required": [
    "error",
    "is_error"
  ],
  "properties": {
    "error": {
      "type": "string"
    },
    "is_error": {
      "type": "boolean",
      "const": true
    }
  },
  "additionalProperties": true
}
```

## `promptguard_status`

Health and config summary (free). Includes soft-neural pack enable/mode (attack, discourse, gated secondary semantic).

**Required arguments:** _(none)_

**Request contract**

```json
{
  "jsonrpc": "2.0",
  "id": "<integer|string>",
  "method": "tools/call",
  "params": {
    "name": "promptguard_status",
    "arguments": {}
  }
}
```

**Input schema**

```json
{
  "type": "object",
  "properties": {},
  "additionalProperties": false
}
```

**Output schema** (`structuredContent` on success)

```json
{
  "type": "object",
  "properties": {
    "ok": {
      "type": "boolean"
    }
  },
  "additionalProperties": true,
  "required": [
    "ok"
  ]
}
```

**Error object**

```json
{
  "type": "object",
  "required": [
    "error",
    "is_error"
  ],
  "properties": {
    "error": {
      "type": "string"
    },
    "is_error": {
      "type": "boolean",
      "const": true
    }
  },
  "additionalProperties": true
}
```
