Skip to main content

ory-pydantic-ai

Ory Agent Security for Pydantic AI.

Wraps any toolset in an Ory-gating WrapperToolset so every tool call is authorized against Ory Permissions, audited, and tied to the user → agent identity — built on ory-argus.

pip install ory-pydantic-ai
from pydantic_ai import Agent
from ory_pydantic_ai import wrap_toolset

agent = Agent(model, toolsets=[wrap_toolset(my_toolset)])

In enforce mode a denied tool never runs and the model receives the denial as a failed tool result: pydantic-ai's ToolFailed where available (it does not consume the tool's retry budget, so repeated denies never end the run), otherwise the denial text as the tool result. In observe mode (default) the tool runs and a permission.observe_deny activity event is recorded.

Sub-agents

Name the tools that run another agent (agent delegation):

wrap_toolset(toolset, subagent_tools={"research_agent"})

An allowed call to one registers a sub-agent of that name with its own identity, keyed by the tool call id, and the tool runs as that sub-agent, so tool calls the delegate agent makes inside it (through a wrapped toolset sharing the same client) are checked and recorded as the sub-agent's. Tools that are not named are attributed to the calling agent.

MCP servers

Tools from an MCP server toolset — MCPToolset (or the MCPServer* classes of older releases), directly or behind .prefixed() / .renamed() — are checked as McpServer:<server> and McpTool:<server>:<tool> instead of plain tools:

from pydantic_ai.mcp import MCPToolset, load_mcp_toolsets

github = MCPToolset("https://api.githubcopilot.com/mcp/", id="github")
agent = Agent(model, toolsets=[wrap_toolset(github), *map(wrap_toolset, load_mcp_toolsets("mcp.json"))])

The guard walks from each called tool to the server toolset that listed it. It reports the server as the .prefixed() prefix closest to the server, else the toolset id, else the server-reported server_info.name (else a legacy tool_prefix), and the server's raw tool name with prefixes and renames undone. It also sends hashed fingerprints of the server's URL host or launched package, so Agent Security matches the server to its catalog whatever it is named; launch arguments and URLs themselves are not sent. Give servers an id or a prefix so the reported name is meaningful. Wrap each MCP toolset (or a toolset containing it) once; tools from other toolsets keep their native checks.

Credentials come from the shared ~/.config/ory-agent-plugins/config.json.

Metadata

Release files for ory-pydantic-ai 1.12.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ory-pydantic-ai 1.12.0
File Size Uploaded Provenance Actions
ory_pydantic_ai-1.12.0.tar.gz 9.3 kB Without provenance Details for ory_pydantic_ai-1.12.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ory-pydantic-ai 1.12.0
File Interpreter ABI Platform Actions
ory_pydantic_ai-1.12.0-py3-none-any.whl Python 3 none any Details for ory_pydantic_ai-1.12.0-py3-none-any.whl

Total release size: 15.4 kB

Release files / ory_pydantic_ai-1.12.0.tar.gz

Download URL ory_pydantic_ai-1.12.0.tar.gz
Size 9.3 kB
Tags Source
SHA-256 checksum
How to use checksums
3dd9594c2f74ba95d2412725ac644d80b071e5d9aab81a6110d7d49491de427c
BLAKE2b-256 checksum
How to use checksums
5bb51d3e8a3a586539fef63834ce84de270b0884ca888cb8b5c5cbd6479f9208
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / ory_pydantic_ai-1.12.0-py3-none-any.whl

Download URL ory_pydantic_ai-1.12.0-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c671f04872e10f2fb45703d0b96c4ebb5d25e0d44411877d83c1a049ae111fb2
BLAKE2b-256 checksum
How to use checksums
57f71e276026de19ed27da000c614de3103198248ecdbd578cce90a7d5ee63a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for ory-pydantic-ai 1.12.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.12.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page