Skip to main content

legion-guard — verify before connect

An agent reads an MCP server's tool descriptions as instructions. The server you approved last week can expose other tools, or the same tools with other descriptions, today. legion-guard checks the tools/list your client actually receives, at connect time, before the agent sees the tools:

  1. against the tools you approved (lockfile .mcp-tools.lock.json, same format as legion-lock);
  2. against the latest tool list signed by LEGION's public transparency log (record + RFC 9162 inclusion proof + signed head, checked from a pinned root key). A difference means this client receives a list LEGION did not sign: either the server changed since LEGION's last probe, or it serves different tools to different clients.

mode="warn" reports. mode="block" hides unapproved or changed tools from list_tools() and refuses call_tool() on them. The guard never calls a tool itself.

Use it with the MCP Python SDK (tested)

import legion_guard
from mcp import ClientSession

async with ClientSession(read, write) as session:
    await session.initialize()
    report = await legion_guard.guard_session(session, "com.dexpaprika/dexpaprika", mode="block")
    tools = await session.list_tools()          # only approved, unchanged tools

Frameworks that build on ClientSession (for example LangChain's MCP adapters loading tools from a session) see the filtered list when the guard runs first; those integrations are not tested yet.

Command line

python3 -m legion_guard approve https://mcp.dexpaprika.com/streamable-http com.dexpaprika/dexpaprika   # after review
python3 -m legion_guard check   https://mcp.dexpaprika.com/streamable-http com.dexpaprika/dexpaprika   # exit 1 on drift

Measured on 2026-10-17: the 20-tool list served by mcp.dexpaprika.com/streamable-http to this client has the fingerprint 20b17583… that LEGION signed (record 20315, observed on /sse) — MATCHES_SIGNED.

Limits

  • LEGION observes only part of the servers; absence from the log is not a verdict (UNKNOWN).
  • A change is not an attack. This does not certify that a server is secure, and says nothing about what the tools do.
  • Approval is yours: the guard compares, it does not judge a description.
  • Fingerprints cover name, description and inputSchema (JCS RFC 8785), as in the LEGION log.

Metadata

Release files for legion-guard 0.1.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 legion-guard 0.1.0
File Size Uploaded Provenance
legion_guard-0.1.0.tar.gz 40.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for legion-guard 0.1.0
File Interpreter ABI Platform
legion_guard-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 80.9 kB

Release files / legion_guard-0.1.0.tar.gz

Download URL legion_guard-0.1.0.tar.gz
Size 40.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f4ddba149e8b2b6eb1aff9e894f8edd4246c085561ddffef74ec79698c334891
BLAKE2b-256 checksum
How to use checksums
66996d6f3745929b10a2d8c9e15465dd61ba8a3b80a30b1b18ae2e5d3b241edd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.12

Release files / legion_guard-0.1.0-py3-none-any.whl

Download URL legion_guard-0.1.0-py3-none-any.whl
Size 40.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
af7b64749f28266e1df50aac06160abbc909a4b47102f85f72e8b435ea41c190
BLAKE2b-256 checksum
How to use checksums
2d8e1b3c5b967039cae58c08d706e6b7d929e18db949f3d89d1d30d65be7c339
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.12

Security for legion-guard 0.1.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.

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