Skip to main content

The security, access-control, and governance layer for MCP servers.

Project description

pontifex-mcp

Enterprise-grade capabilities for MCP servers, built on the official MCP Python SDK.

pontifex-mcp lets you build MCP servers that connect AI agents to real systems without giving up control over who can call what. You write the tools; it handles authentication, per-caller scopes, rate limits, and a full audit trail.

Key features

  • Secure by default — OAuth 2.1 JWTs and sk_… API keys; every tool call is authenticated. Any OIDC provider (Auth0, Entra, Clerk, Keycloak).
  • Least-privilege scopesdomain:resource:action, checked before every call. Callers can't widen their own access.
  • Auditable — every call recorded: who, what, when, data source, cache hit, latency.
  • Standards-based — RFC 9728 discovery + WWW-Authenticate; MCP clients bootstrap auth on their own.
  • Resilient — per-caller rate limiting, adapter failover, circuit breaking.
  • Observable — Logfire / OpenTelemetry tracing and metrics wired in.
  • Built on the MCP SDK — keep its tools, protocol, and transports; add the controls a production server needs.

Security is deliberate: asymmetric-only JWT validation, generic auth errors, and no token claim can escalate a caller — all verifiable in the source.

Status: 0.x, building in public. The security model is solid; the public API (everything exported from pontifex_mcp) is still settling — expect occasional breaking changes before 1.0.

Install

pip install pontifex-mcp     # or: uv add pontifex-mcp

Requires Python 3.12+, Postgres, and Redis.

Build your own domain

A domain is: a settings class, one or more data adapters, and tools wrapped with tool_runtime. Everything below comes from the top-level package.

from typing import Any

from mcp.server.fastmcp import Context, FastMCP
from pontifex_mcp import (
    AuditWriter,
    CoreSettings,
    create_mcp_http_app,
    tool_runtime,
)


class OrdersSettings(CoreSettings):
    orders_api_base: str = "https://orders.internal.example.com"


def register_tools(mcp: FastMCP, audit: AuditWriter) -> None:
    @mcp.tool(name="orders_get_status", description="Look up the status of an order.")
    @tool_runtime(
        domain="orders",
        tool_name="orders_get_status",
        resource="order",        # scope checked: orders:order:read
        action="read",
        audit=audit,
    )
    async def get_order_status(order_id: str, ctx: Context | None = None) -> dict[str, Any]:
        # ... fetch from your internal system (ideally through a DataAdapter) ...
        return {"source": "orders-api", "cache_hit": False, "order_id": order_id, "status": "shipped"}


async def health() -> dict[str, Any]:
    return {"status": "ok"}


settings = OrdersSettings()
app = create_mcp_http_app("orders", settings, register_tools, health)
# `uv run uvicorn your_module:app` → MCP endpoint at /mcp, health at /health/ready

Auth, scope checks, rate limiting, the audit row, and the structured error envelope are all applied by tool_runtime and the server's middleware — your handler just returns data.

Configuration

Infrastructure settings read from bare, unprefixed env vars:

DATABASE_URL, REDIS_URL          # required (the app fails fast if unset)
AUTH_JWKS_URL, AUTH_ISSUER, AUTH_AUDIENCE, AUTH_SCOPES_CLAIM   # enable the OAuth/JWT path
PUBLIC_BASE_URL                  # canonical URL advertised in OAuth discovery

Domain-specific settings on your subclass read with your domain's env_prefix.

Who it's for

Reach for pontifex-mcp when you're exposing internal or proprietary systems — an orders API, a customer database, an analytics warehouse — to AI agents (Claude Desktop, your own agents, anything that speaks MCP), and unauthenticated tool access isn't an option.

If you're shipping a single public tool over non-sensitive data, the MCP SDK on its own is simpler. Come here when access control and an audit trail start to matter.

License

MIT © Chris Dare. Part of Argonauts.

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

pontifex_mcp-0.2.0.tar.gz (29.1 kB view details)

Uploaded Source

Built Distribution

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

pontifex_mcp-0.2.0-py3-none-any.whl (42.0 kB view details)

Uploaded Python 3

File details

Details for the file pontifex_mcp-0.2.0.tar.gz.

File metadata

  • Download URL: pontifex_mcp-0.2.0.tar.gz
  • Upload date:
  • Size: 29.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for pontifex_mcp-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0226be359d283400ec0ccfed829471da337df8e094603a349061302d6b3dd27c
MD5 e9fbb4723e6e1f2044f86df69058d6ba
BLAKE2b-256 4f0a6bb60ea50780ad576189e513bbfbe78405d5bae446f0ac24a54e9868ab20

See more details on using hashes here.

Provenance

The following attestation bundles were made for pontifex_mcp-0.2.0.tar.gz:

Publisher: publish-pypi.yml on chris-dare/pontifex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pontifex_mcp-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pontifex_mcp-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 42.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for pontifex_mcp-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 86e73c611696b4f1241935d8227a848d49b39e5a137f0fca0a0e3905eaf00242
MD5 720ab1388fdf26024fcb307cdfcc567c
BLAKE2b-256 95fc70048d030071abffba1bc6a35d0a989489d4f415906661d3d8daa8685d9d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pontifex_mcp-0.2.0-py3-none-any.whl:

Publisher: publish-pypi.yml on chris-dare/pontifex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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