ory-langchain
Ory Agent Security for LangChain / LangGraph.
Adds three things to a LangChain agent with one line:
- Authorization — every tool call is checked against Ory Permissions before it runs.
- Activity auditing — every invocation is recorded in the unified privacy-safe NDJSON log.
- Identity propagation — user → agent → sub-agent delegation, recorded in Ory.
Install
pip install ory-langchain
Use
from langchain.agents import create_agent
from ory_langchain import OryMiddleware
agent = create_agent(
model,
tools=[search, send_email],
middleware=[OryMiddleware()], # gate every tool call through Ory
)
OryMiddleware() reads the shared Ory config at ~/.config/ory-agent-plugins/config.json,
so a login performed by any Ory coding-agent harness — or by ory-argus login — is reused
transparently. Configure a project explicitly with OryMiddleware(project_url=...).
Permission mode
observe(default) — denied tools still run, but apermission.observe_denyactivity event is recorded. Use this to see what would be blocked before enforcing.enforce— denied tools are blocked: the model receives an errorToolMessageand the tool never executes. The posture is read from the Ory project — an admin promotes it to enforce in the Ory Console (Agent Security);ory-argus permissionsshows what this machine resolves.
MCP tools
Tools loaded with langchain-mcp-adapters
are checked as McpServer:<server> and McpTool:<server>:<tool> when the MCP client carries
Ory's tool interceptor:
from langchain_mcp_adapters.client import MultiServerMCPClient
connections = {
"github": {"transport": "streamable_http", "url": "https://api.githubcopilot.com/mcp/"},
"playwright": {"transport": "stdio", "command": "npx", "args": ["-y", "@playwright/mcp"]},
}
ory = OryMiddleware()
mcp = MultiServerMCPClient(connections, tool_interceptors=[ory.mcp_interceptor(connections=connections)])
agent = create_agent(model, tools=[search, *await mcp.get_tools()], middleware=[ory])
The interceptor reports the connections key as the server, the server's raw tool name
(without the tool_name_prefix prefix), and hashed fingerprints of the server's URL host or
launched package, so Agent Security matches the server to its catalog whatever you named it.
Only the hashes leave the process; URLs, arguments, and headers do not. In enforce mode a denied
call returns an MCP error result to the model and the server is never called.
OryMiddleware leaves tools whose MCP client carries an Ory interceptor to that interceptor, so
each MCP call is checked and recorded once. Without the interceptor, the middleware still gates
MCP tools, but as plain tools. OryMcpInterceptor(client=..., connections=...) also works on
its own, for MCP tools used outside an agent with the middleware.
Activity only
If you only want lifecycle activity (no enforcement), use the callback handler instead:
from ory_langchain import OryCallbackHandler
agent.invoke({"messages": [...]}, config={"callbacks": [OryCallbackHandler()]})
Built on ory-argus, the shared Ory Agent Security core.
Metadata
Release files for ory-langchain 1.10.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ory_langchain-1.10.3.tar.gz | 10.8 kB | Without provenance | Details for ory_langchain-1.10.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ory_langchain-1.10.3-py3-none-any.whl | Python 3 | none | any | Details for ory_langchain-1.10.3-py3-none-any.whl |
Total release size: 19.8 kB
Release files / ory_langchain-1.10.3.tar.gz
| Download URL | ory_langchain-1.10.3.tar.gz |
|---|---|
| Size | 10.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f3b42d89e74d19c16fe12a66a4dc1abbcbbe3682a5d4b135fb3d16a2f2242d96
|
|
BLAKE2b-256 checksum How to use checksums |
cd973e446ca355dd75d9b803040e68d97e995094b113aa147e6af64f515bd32b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","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_langchain-1.10.3-py3-none-any.whl
| Download URL | ory_langchain-1.10.3-py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5d3a6d49c83493f02e634788110009256a63d2aed645790810e61297afa78d84
|
|
BLAKE2b-256 checksum How to use checksums |
a0720f3784d7473d9ea7c0efeb1f401e04ed521ce3cf83497266c0eaa2252e8c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","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-langchain 1.10.3
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.