Metadata-Version: 2.4
Name: langchain-mcp-trust-gate
Version: 0.3.0
Summary: Trust-gated MCP tool calls for LangChain via Dominion Observatory
Author-email: Dinesh Kumar <vdineshk@users.noreply.github.com>
License: MIT
Project-URL: Homepage, https://github.com/vdineshk/daee-engine
Project-URL: Repository, https://github.com/vdineshk/daee-engine/tree/main/packages/langchain-mcp-trust-gate
Project-URL: Issues, https://github.com/vdineshk/daee-engine/issues
Keywords: langchain,mcp,trust,security,agents,dominion-observatory
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: langchain-mcp-adapters>=0.1.0
Requires-Dist: httpx>=0.24.0
Dynamic: license-file

# langchain-mcp-trust-gate

[![PyPI](https://img.shields.io/pypi/v/langchain-mcp-trust-gate)](https://pypi.org/project/langchain-mcp-trust-gate/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

Trust-gated MCP tool calls for LangChain. Automatically checks behavioral trust scores via [Dominion Observatory](https://github.com/vdineshk/daee-engine) before every MCP tool call.

## Install

```bash
pip install langchain-mcp-trust-gate
```

## Quick Start

```python
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

```python
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
