Skip to main content

MCP server for PromptShield safety checks powered by zero-harm-ai-detectors.

Project description

Zero Harm AI MCP

Zero Harm AI MCP is a Model Context Protocol server that lets AI agents and runtime firewalls call Zero Harm AI safety checks for text, chat messages, prompts, tool inputs, and generated outputs.

The server is a thin adapter over zero-harm-ai-detectors. It should not duplicate detector logic from the detector package or from the PromptShield GitHub Action.

Goals

  • Expose PII, secret, and harmful-content detection through MCP tools.
  • Return structured findings that agents and firewalls can enforce.
  • Support local/self-hosted operation for sensitive data.
  • Keep logs privacy-safe by default.
  • Provide stable tool contracts that can be used by coding agents, chat agents, and firewall.

Non-Goals

  • Reimplementing zero-harm-ai-detectors.
  • Acting as a hosted service by default.
  • Making policy enforcement decisions that belong to a firewall or calling agent.
  • Replacing the PromptShield GitHub Action.

Relationship To Other Projects

zero-harm-ai-detectors
  Shared detector engine for PII, secrets, and harmful content.

promptshield
  GitHub Action and CI-oriented scanner for pull requests.

zero-harm-ai-mcp
  MCP server adapter that exposes detector functionality to AI agents.

promptshield-firewall (future)
  Runtime enforcement layer. It can call zero-harm-ai-mcp or use
  zero-harm-ai-detectors directly.

Installation

Install from PyPI:

pip install zero-harm-ai-mcp

For local development:

python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
pytest
ruff check .

MCP Client Configuration

{
  "mcpServers": {
    "promptshield": {
      "command": "zero-harm-ai-mcp",
      "args": []
    }
  }
}

MCP Tools

zero_harm.scan_text

Scan one text string for PII, secrets, and harmful content.

Use this for prompt inputs, generated outputs, tool arguments, logs, and arbitrary text.

zero_harm.scan_messages

Scan chat-style messages while preserving message roles and indexes.

Use this when an agent wants to inspect a conversation before sending it to a model or tool.

zero_harm.redact_text

Return a redacted version of text plus findings.

Use this when the caller wants to continue safely after removing sensitive spans.

zero_harm.evaluate_policy

Map detector findings to an action recommendation.

Use this when a caller wants a normalized decision such as allow, warn, redact, or block.

Working Examples

These examples are generated from the current local server implementation.

zero_harm.scan_text

Input:

{
  "text": "Contact alice@example.com before sharing the token.",
  "targets": ["pii", "secret", "harmful"],
  "redact": true
}

Output:

{
  "schema_version": "1.0.0",
  "risk_level": "medium",
  "recommended_action": "redact",
  "categories": [
    "pii"
  ],
  "summary": {
    "total_findings": 1,
    "pii": 1,
    "secret": 0,
    "harmful": 0
  },
  "findings": [
    {
      "type": "email",
      "category": "pii",
      "severity": "medium",
      "confidence": 0.99,
      "span": {
        "start": 8,
        "end": 25
      },
      "redacted": "[PII]",
      "message_index": null,
      "message_role": null,
      "evidence_available": false
    }
  ],
  "redacted_text": "Contact [PII] before sharing the token."
}

zero_harm.scan_messages

Input:

{
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful assistant."
    },
    {
      "role": "user",
      "content": "My email is alice@example.com."
    }
  ],
  "targets": ["pii", "secret", "harmful"],
  "redact": true
}

Output:

{
  "schema_version": "1.0.0",
  "risk_level": "medium",
  "recommended_action": "redact",
  "categories": [
    "pii"
  ],
  "summary": {
    "total_findings": 1,
    "pii": 1,
    "secret": 0,
    "harmful": 0
  },
  "findings": [
    {
      "type": "email",
      "category": "pii",
      "severity": "medium",
      "confidence": 0.99,
      "span": {
        "start": 12,
        "end": 29
      },
      "redacted": "[PII]",
      "message_index": 1,
      "message_role": "user",
      "evidence_available": false
    }
  ],
  "redacted_text": "[{\"role\": \"system\", \"content\": \"You are a helpful assistant.\"}, {\"role\": \"user\", \"content\": \"My email is [PII].\"}]"
}

zero_harm.redact_text

Input:

{
  "text": "aws_access_key_id = AKIAIOSFODNN7EXAMPLE",
  "targets": ["pii", "secret", "harmful"]
}

Output:

{
  "schema_version": "1.0.0",
  "risk_level": "high",
  "recommended_action": "block",
  "categories": [
    "secret"
  ],
  "summary": {
    "total_findings": 1,
    "pii": 0,
    "secret": 1,
    "harmful": 0
  },
  "findings": [
    {
      "type": "api_key",
      "category": "secret",
      "severity": "high",
      "confidence": 0.95,
      "span": {
        "start": 20,
        "end": 40
      },
      "redacted": "[SECRET]",
      "message_index": null,
      "message_role": null,
      "evidence_available": false
    }
  ],
  "redacted_text": "aws_access_key_id = [SECRET]"
}

zero_harm.evaluate_policy

Input:

{
  "text": "Contact alice@example.com before sharing the token.",
  "targets": ["pii", "secret", "harmful"],
  "redact": false
}

Output:

{
  "schema_version": "1.0.0",
  "risk_level": "medium",
  "recommended_action": "warn",
  "categories": [
    "pii"
  ],
  "summary": {
    "total_findings": 1,
    "pii": 1,
    "secret": 0,
    "harmful": 0
  }
}

Privacy Requirements

  • Do not log raw input text by default.
  • Do not log detected secret values by default.
  • Include a config option for audit logs that stores only counts, categories, severities, and request metadata.
  • Avoid sending data to external services unless explicitly configured.
  • Keep the default transport local-first.

Development

python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
pytest
ruff check .

Release

Build and validate distribution artifacts:

python -m build
twine check dist/*

See RELEASE.md for the full PyPI release flow.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zero_harm_ai_mcp-0.1.0.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zero_harm_ai_mcp-0.1.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file zero_harm_ai_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: zero_harm_ai_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.15

File hashes

Hashes for zero_harm_ai_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c5d4abda2aa7e6288ce8279b5e720481fddc20089670b05084fafa37a5a9ac46
MD5 b2f36ca7aa4b6e100d7e8790b4ccd0f7
BLAKE2b-256 0c2912fbd69f8075b056315f90fa37e0c0287b8d9dbec6668a97879f7ed5be71

See more details on using hashes here.

File details

Details for the file zero_harm_ai_mcp-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for zero_harm_ai_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e5c71b50ff97bacb070fe36fbfd536d8a62e1427e7b99974d3f6e8513c23b9e9
MD5 361c04e01af4c69c07b73cc7c0f19527
BLAKE2b-256 7b08a4e4319394903b9952ba0c22e66c8f7b2275d15891c3dd4733293666b6dd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page