Skip to main content
Glama
alberthild

ShieldAPI MCP

by alberthild

shieldapi.check_prompt

Read-onlyIdempotent

Analyze text for prompt injection attacks across 4 categories using 200+ detection patterns before processing untrusted user input.

Instructions

Detect prompt injection in text. Analyzes across 4 categories (direct injection, encoding tricks, exfiltration, indirect injection) with 200+ detection patterns. Designed for real-time inline usage before processing untrusted user input. Returns boolean verdict, confidence score (0-1), matched patterns with evidence, and decoded content if encoding obfuscation was detected. Response time <100ms p95.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYesThe text to analyze for prompt injection
contextNoContext hint for sensitivity: user-input (default), skill-prompt (higher tolerance), system-prompt (highest sensitivity)

Implementation Reference

  • The 'shieldapi.check_prompt' tool registration and handler implementation. It uses 'callShieldApiPost' to send the prompt to the ShieldAPI backend.
    server.tool(
      'shieldapi.check_prompt',
      'Detect prompt injection in text. Analyzes across 4 categories (direct injection, encoding tricks, exfiltration, indirect injection) with 200+ detection patterns. Designed for real-time inline usage before processing untrusted user input. Returns boolean verdict, confidence score (0-1), matched patterns with evidence, and decoded content if encoding obfuscation was detected. Response time <100ms p95.',
      {
        prompt: z.string().describe('The text to analyze for prompt injection'),
        context: z.enum(['user-input', 'skill-prompt', 'system-prompt']).optional()
          .describe('Context hint for sensitivity: user-input (default), skill-prompt (higher tolerance), system-prompt (highest sensitivity)'),
      },
      { title: 'Detect Prompt Injection', readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
      async (params) => {
        const body: Record<string, unknown> = { prompt: params.prompt };
        if (params.context) body.context = params.context;
        return formatResult(await callShieldApiPost('check-prompt', body));
      }
    );
  • The helper function that communicates with the ShieldAPI backend for the tools.
    async function callShieldApiPost(endpoint: string, body: Record<string, unknown>): Promise<unknown> {
      const url = new URL(`${SHIELDAPI_URL}/api/${endpoint}`);
      if (demoMode) {
        url.searchParams.set('demo', 'true');
      }
    
      const response = await paymentFetch(url.toString(), {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const body = await response.text();
        throw new Error(`ShieldAPI ${endpoint} failed (${response.status}): ${body.substring(0, 200)}`);
      }
      return response.json();
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv3.0.0

TDQS

A4.5/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description goes beyond annotations by detailing the return structure (boolean verdict, confidence, matched patterns, decoded content), the detection scope (4 categories, 200+ patterns), and performance (<100ms p95). This is rich behavioral context not provided by the readOnly/idempotent annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Four efficiently written sentences front-load the purpose, then pack concrete details about categories, return values, and performance. No redundant or vague wording.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Even without an output schema, the description fully covers return fields, performance expectations, and usage context, making the tool's behavior completely understandable for a real-time content moderation tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with both prompt and context well-described in the schema. The description adds no parameter-specific details beyond what the schema already provides, so the baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description starts with a specific verb and resource: 'Detect prompt injection in text'. It further distinguishes itself from sibling check_* tools by naming the detection categories and target input type, making its scope unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It explicitly states the intended use case: 'Designed for real-time inline usage before processing untrusted user input'. This gives clear context for when to use it, though it doesn't explicitly contrast with alternatives like full_scan.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.