FastPII Docs
Integrations

MCP Server

Expose FastPII as an MCP server with tools for PII detection, identifier validation, and detector discovery.

MCP server integration

FastPII includes an MCP-compatible server wrapper that exposes three tools backed by PrivacyGuard.

Installation

Install FastPII first:

pip install fastpii

Setup

from fastpii.integrations.mcp import MCPServer

server = MCPServer(regions=["cz"])

Usage examples

List available tools

from fastpii.integrations.mcp import MCPServer

server = MCPServer(regions=["cz"])
tools = server.list_tools()

Detect PII with detect_pii

from fastpii.integrations.mcp import MCPServer

server = MCPServer(regions=["cz"])

result = server.call_tool(
    "detect_pii",
    {
        "text": "Jan Novak, rodne cislo 8001011234",
        "detector_names": ["rodne_cislo"],
    },
)

Validate an identifier with validate_identifier

from fastpii.integrations.mcp import MCPServer

server = MCPServer(regions=["cz"])

result = server.call_tool(
    "validate_identifier",
    {
        "value": "8001011234",
        "detector_name": "rodne_cislo",
    },
)

List detectors with list_detectors

from fastpii.integrations.mcp import MCPServer

server = MCPServer(regions=["cz"])

result = server.call_tool("list_detectors", {})

Tools reference

detect_pii

Input shape:

{
  "text": "string",
  "regions": ["cz"],
  "detector_names": ["string"]
}
  • Required: text
  • Optional: regions, detector_names

Result shape:

{
  "text": "string",
  "findings": [
    {
      "type": "string",
      "value": "string",
      "start": 0,
      "end": 0,
      "confidence": 0.0,
      "region": "string",
      "metadata": {}
    }
  ],
  "detector_names": ["string"],
  "processing_time_ms": 0
}

If text is missing or empty, the server returns:

{
  "error": "Missing required parameter: text"
}

validate_identifier

Input shape:

{
  "value": "string",
  "detector_name": "string",
  "regions": ["cz"]
}
  • Required: value, detector_name
  • Optional: regions

Success result shape:

{
  "detector": "string",
  "value": "string",
  "is_valid": true,
  "metadata": {}
}

Unknown detector result:

{
  "error": "Detector 'name' not found",
  "available_detectors": ["string"]
}

list_detectors

Input shape:

{
  "regions": ["cz"]
}

Result shape:

{
  "detectors": [
    {
      "name": "string",
      "region": "string",
      "description": "string"
    }
  ]
}

Server methods

  • list_tools() -> list[dict[str, object]]
  • call_tool(name, arguments) -> dict[str, object]

On this page