Skip to main content
Glama
AlexlaGuardia

ToolBridge

README.md
# ToolBridge

A governed MCP integration connecting an AI agent to a mock CRM, support ticket store, and knowledge base, with role-based access control and field redaction enforced outside the model. Built to demonstrate production-safe agent wiring: the model cannot widen its own access, sensitive fields are stripped before the agent ever sees them, and every reply draft goes through a human-review checkpoint before it can be sent.

## What it demonstrates

- **Governed MCP server** built with the official Python `mcp` SDK (`FastMCP`), exposing five tools across three data sources.
- **Role-based access control**: the `support_agent` role cannot call the deal-pipeline tool at all; `admin` has full access. The role is fixed from the environment at startup, not negotiable by the model.
- **Field redaction outside the model**: billing fields (`payment_method`, `billing_email`, `contract_value_usd`) are stripped from customer records for `support_agent` before the data reaches the agent. The model sees a clean, role-scoped view.
- **Grounded KB lookup**: `search_kb` surfaces documented answers for the agent to cite, reducing hallucination.
- **Human-in-the-loop draft step**: `draft_reply` returns a review-pending object and explicitly does not send anything automatically.

## Quick start

```bash
pip install -r requirements.txt
python3 demo.py
```

No API key required. The demo simulates a full support workflow and prints a narrated transcript showing governance at each step.

To see the admin path (unredacted data, deal pipeline access):

```bash
TOOLBRIDGE_ROLE=admin python3 demo.py
```

To run the governance test suite (12 tests, no pytest needed):

```bash
python3 -m tests.test_governance
```

Optional: if you have an Anthropic API key, you can run a real Claude tool-loop:

```bash
ANTHROPIC_API_KEY=sk-... USE_CLAUDE=1 python3 demo.py
```

## File layout

```
toolbridge/
  policy.py       Role definitions and governance primitives (access check, redact)
  store.py        In-memory mock data: CRM, tickets, knowledge base
  server.py       MCP server -- five tools, all gated through policy
demo.py           Runnable demo: narrated transcript, zero API key needed
tests/
  test_governance.py  12 assertions covering redaction and access control
requirements.txt
```

## Extending this

The governance layer (`policy.py`) and the data layer (`store.py`) are decoupled from the tool definitions. To connect real systems, replace the in-memory dicts in `store.py` with API clients (HubSpot, Zendesk, Confluence) while keeping `policy.py` and `server.py` unchanged. Add new roles by editing the `ROLES` dict in `policy.py`.