Skip to main content

Trust-gated MCP tool calls for LangChain via Dominion Observatory

Project description

langchain-mcp-trust-gate

PyPI License: MIT

Trust-gated MCP tool calls for LangChain. Automatically checks behavioral trust scores via Dominion Observatory before every MCP tool call.

Install

pip install langchain-mcp-trust-gate

Quick Start

from langchain_mcp_trust_gate import TrustGateInterceptor
from langchain_mcp_adapters.client import MultiServerMCPClient

trust_gate = TrustGateInterceptor(min_score=70)

async with MultiServerMCPClient(
    connections={"my-server": {"url": "https://example.com/mcp", "transport": "streamable_http"}},
    interceptors=[trust_gate],
) as client:
    tools = await client.get_tools()
    # All tool calls now trust-gated automatically

How It Works

  1. Before each MCP tool call, queries Dominion Observatory for the server trust score
  2. Blocks calls to servers below the threshold (default: 60)
  3. After each call, reports the outcome back to the Observatory
  4. Scores are cached (5-minute TTL) to minimize latency

Configuration

TrustGateInterceptor(
    min_score=70,           # Minimum trust score (0-100)
    cache_ttl=300.0,        # Cache TTL in seconds
    block_on_error=False,   # Fail-open if Observatory unreachable
    report_outcomes=True,   # Report call outcomes back
)

Architecture

Implements the ToolCallInterceptor protocol from langchain-mcp-adapters. Composes with other interceptors in an onion pattern.

License

MIT

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

langchain_mcp_trust_gate-0.2.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

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

langchain_mcp_trust_gate-0.2.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for langchain_mcp_trust_gate-0.2.0.tar.gz
Algorithm Hash digest
SHA256 7d541cc4e409032b0ed5c32dac1dc99fe89a8f6642ab64adfaa71eb33f3897de
MD5 836577eaabb779c13f986e2a01148620
BLAKE2b-256 c15563fba4118ff8c6b974bac0952392d88e337a53101bb262c6e25efe94f7c4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for langchain_mcp_trust_gate-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 50f409b5777b9a0303b6a683a29c0e197734b826c2290a6d7509c43edcca9076
MD5 6a767d2c52c5a6fc8ce6a37c4df7730e
BLAKE2b-256 a37f12ca856c107076df212bbe9b0d57f8c619c182bd201cddf60eadba5d5812

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