CALIBER
Quickstart

Cookbook 05 · Foundations

Governed Tool Connectivity (MCP)

Connect an MCP server, classify every tool before anything calls it, and prove from the server's own ledger that a refused call never ran.

FoundationsCore20–40 min
What you build. A governed connection to the lab's own MCP server (assets/server/repo_tracker_mcp.py, run over stdio) with six tools: four read tools, the write tool issue_write and the external action create_release. You discover the tools, classify each one, call an allowed read tool, calibrate the three read tools on 28 saved cases, and bind issue_write in a workflow that stops at waiting_approval until a second person approves. No model is involved, so nothing is simulated.
Surfaces: MCP Servers Workflows Observability Audit Log
What you learn
  • Register a stdio MCP server in MCP Servers, run Test and read the 6 discovered tools and their schemas
  • Classify every tool (Allow tool, Requires approval, Side effect level, Rate limit / minute): discovery is not authorization
  • Invoke an allowed read tool, then meet each refusal (blocked, unknown, rate-limited) and each failed call (tool error, missing argument, timeout)
  • Calibrate the read tools with saved cases, and see one wrong expectation fail exactly one case
  • Hold issue_write in a workflow for a second person, and read the audit log and mcp.<server>.<tool> traces

Implementation flow

flowchart LR
  R["Register stdio server"] --> T["Test: discover 6 tools"]
  T --> U["All unclassified, so denied"]
  U --> C["Classify each tool"]
  C --> RD["Read tool: invoke and calibrate"]
  C --> BL["Blocked, unknown or rate-limited call: refused"]
  BL --> LG[("Server ledger: no line written")]
  C --> WR["issue_write in a workflow"]
  WR --> AP{{"waiting_approval: second person"}}
  AP -->|approve and Resume| OK["Write runs"]
  RD --> TR["Audit log and mcp traces"]

Step-by-step UI only

Each step shows the exact navigation path, the fields to fill, the button to click, and a snapshot of the CALIBER screen you'll be on.

  1. Admin › Administration creates · accounts + workspace
    Before you start: start CALIBER with CALIBER_FEATURE_INTEGRATIONS=true, the lab's MCP server script in CALIBER_MCP_STDIO_PYTHON_SCRIPT_ALLOWLIST, and CALIBER_OPERATOR_USERS / CALIBER_APPROVER_USERS naming lab05-operator / lab05-approver. Create the three accounts, then a workspace mcp-ops (top bar +) and add them as Editor, Reviewer and Viewer under Project access.
    You'll see: mcp-ops is selected; the three people are members with those roles.
    Screen snapshot
    caliber · Admin › Administration
    Administration
    Read / inspect this surface — no form to fill.
  2. Integrations › MCP Servers creates · mcp server: repo-tracker repo_tracker_mcp.py ↓
    Click Add Server. The server is the lab's own repo_tracker_mcp.py, started by CALIBER over stdio (a loopback HTTP endpoint would be refused by the egress policy).
    Fill in
    Namerepo-tracker
    Transportstdio (local process)
    Command${PYTHON}
    Arguments<repo>/docs-site/cookbooks/05-mcp-connectivity-governance-lab/assets/server/repo_tracker_mcp.py --ledger <state dir>/lab05-ui-ledger.jsonl
    Click Register Server
    You'll see: A row repo-tracker reading Runtime ready · local containment.
    Screen snapshot
    caliber · Integrations › MCP Servers
    MCP ServersMCP Servers
    Register Server
  3. Integrations › MCP Servers › Servers
    On the row click Test.
    Click Test
    You'll see: Connected · 6 tools.
    Screen snapshot
    caliber · Integrations › MCP Servers › Servers
    MCP ServersServers
    Test
  4. Integrations › MCP Servers › Playground
    Open the Playground tab, pick repo-tracker under Server, click Test Connection. Nothing is callable yet: discovery is inventory, not authorization.
    Click Test Connection
    You'll see: Connection Successful, 6 tools discovered, every tool with an amber Unclassified badge; the selected tool's button reads Classify Tool Before Invoking and is disabled.
    Screen snapshot
    caliber · Integrations › MCP Servers › Playground
    MCP ServersPlayground
    Test Connection
  5. Integrations › MCP Servers › Playground › Tool Policy creates · classification tool-classification.jsonl ↓
    For each tool set Allow tool, Requires approval, Side effect level and Rate limit / minute from tool-classification.jsonl and click Save Policy. On issue_write set write first and leave approval off: the save is refused (set requires_approval=true for side_effect_level 'write'). Tick Requires approval and save. create_release stays unallowed.
    Click Save Policy
    You'll see: Policy saved. No tool is Unclassified now; create_release wears Blocked, issue_write Approval.
    Screen snapshot
    caliber · Integrations › MCP Servers › Playground › Tool Policy
    MCP ServersTool Policy
    Save Policy
  6. Integrations › MCP Servers › Playground
    Select search_repositories, type language:python topic:mcp into query and click Invoke Tool. Then invoke it again with stars:>>not-a-number.
    Click Invoke Tool
    You'll see: Success with acme/mcp-gateway and acme/mcp-servers-internal and a duration; a row under History (browser memory only). The second call is Failed with the server's own message.
    Screen snapshot
    caliber · Integrations › MCP Servers › Playground
    MCP ServersPlayground
    Invoke Tool
  7. Integrations › MCP Servers › Playground creates · refusals invoke-checks.jsonl ↓
    Select create_release. Its button is disabled, so the refusal payload comes from the API (POST /mcp-servers/{id}/invoke-tool: success:false, is blocked by policy, duration_ms:0). Then select issue_write, fill repo and title and invoke it: it runs, although it requires approval, because the admin Playground is a break-glass surface.
    You'll see: Tool Blocked by Policy (disabled) and This tool is blocked by its saved policy.; then Success for the write.
    Screen snapshot
    caliber · Integrations › MCP Servers › Playground
    MCP ServersPlayground
    Read / inspect this surface — no form to fill.
  8. Integrations › MCP Servers › Playground › Calibration creates · calibration cases calibration-cases.jsonl ↓
    Select search_repositories. Use Add case for six cases (S01 to S06) from calibration-cases.jsonl: name, Test case input JSON, Assertion type output_contains, Assertion value. Save cases, then Run calibration. Change case 1's value to "total_count": 9 and run again, then put it back.
    Click Run calibration
    You'll see: Pass rate 100% — 6/6 passed; with the wrong value Pass rate 83% — 5/6 passed and case 1 shows fail.
    Screen snapshot
    caliber · Integrations › MCP Servers › Playground › Calibration
    MCP ServersCalibration
    Run calibration
  9. Agent resources › Workflows creates · approval-gated workflow file-issue.workflow.yaml ↓
    Copy the server id from the row. Fill __SERVER_ID__, __TOOL__=issue_write, __LEVEL__=write, __APPROVAL__=true in a copy of file-issue.workflow.yaml. Import, name it mcp-file-issue, Choose file, Validate dependencies, Import as new. In Run Monitor paste {"repo": "acme/release-notes-bot", "title": "..."} and Run. Approve yourself (refused), approve as lab05-approver in a second session, then Resume.
    Click Run
    You'll see: Awaiting approval at node call_tool; the account that triggered this run cannot approve it; a second person must decide; after the second person approves and you Resume, completed.
    Screen snapshot
    caliber · Agent resources › Workflows
    WorkflowsWorkflows
    Run
  10. Agent resources › Workflows
    In the editor press Publish (v1 becomes read-only), then Restore as draft for v2 · draft. Close the Run Monitor with its ✕, click call_tool in the Outline, then an empty spot on the canvas to open the workflow settings, and untick Approval under Tool bindings for issue_write. Save, open Run Monitor, paste {"repo": "acme/release-notes-bot", "title": "This must never be filed"} and Run.
    Click Run
    You'll see: The run is refused: tool policy requires approval but the workflow binding does not. The server's ledger still shows two issue_write calls.
    Screen snapshot
    caliber · Agent resources › Workflows
    WorkflowsWorkflows
    Run
  11. Integrations › MCP Servers
    Click Add Server with command /bin/sh and arguments -c echo pwned, register it, and click Test on its row. Then read Operate › Audit Log (filter update_mcp_tool_policy, then calibrate_mcp_tool) and Operate › Observability.
    Click Test
    You'll see: Runtime blocked and stdio command '/bin/sh' is not in CALIBER_MCP_STDIO_COMMAND_ALLOWLIST; the audit rows; mcp.repo-tracker.search_repositories and mcp.repo-tracker.issue_write traces and none for create_release.
    Screen snapshot
    caliber · Integrations › MCP Servers
    MCP ServersMCP Servers
    Test

Assets (copy-paste)

The exact files this cookbook uses — copy each into the matching field. Source: docs-site/cookbooks/05-mcp-connectivity-governance-lab/assets/.

assets/server/repo_tracker_mcp.py
"""A small, real MCP server for the lab: an engineering "repo tracker".

It stands in for a hosted MCP server (the lab's real-world variant is GitHub's) so the lab can run with
no network and no credentials. It speaks the actual protocol through the official ``mcp`` SDK, over
streamable HTTP (the transport CALIBER's catalog uses for remote servers) or stdio, and it is
deliberately shaped like a work tracker: read tools, a write tool and an external-action tool.

Tools
-----
``search_repositories``   read             GitHub-style query: free text plus ``language:`` ``topic:`` ``org:``
                                           ``archived:`` ``stars:>N`` qualifiers
``list_issues``           read             issues of one repository, filtered by state
``get_issue``             read             one issue
``scan_dependencies``     read             a deliberately slow upstream call (``delay_seconds``) for the timeout drill
``issue_write``           write            files an issue (in memory)
``create_release``        external_action  "publishes" a release and "notifies" a channel (in memory)

State is a ledger file, not memory, because CALIBER starts a stdio server fresh for every call: pass
``--ledger /absolute/path`` (or set ``REPO_TRACKER_LEDGER``) and every tool that actually executes appends one JSON line
(``{"tool", "ok", "arguments"}``; ``ok`` is whether it succeeded). Issues and releases the write tools create are replayed from that ledger by
``list_issues`` and ``get_issue``. The ledger is how the lab proves, out of band and without trusting
CALIBER's own answer, that a refused call never reached the server (no line was written). With no
ledger nothing is recorded and the write tools only return a result.

Over streamable HTTP, ``GET /stats`` summarises the same ledger and ``GET /healthz`` is the readiness probe.
When ``REPO_TRACKER_TOKEN`` is set, every other request needs ``Authorization: Bearer <token>``; a missing
or wrong token is answered 401 before MCP sees it.

Run it::

    python repo_tracker_mcp.py --transport stdio --ledger /abs/ledger.jsonl    # what the lab registers
    python repo_tracker_mcp.py --transport streamable-http --port 8765        # http://127.0.0.1:8765/mcp
"""

from __future__ import annotations

import argparse
import functools
import hmac
import json
import os
import re
import threading
import time
from pathlib import Path
from typing import Annotated, Any, Literal

from mcp.server.mcpserver import MCPServer
from mcp.server.mcpserver.exceptions import ToolError
from pydantic import Field

DATASET = Path(__file__).resolve().parent.parent / "dataset"
MAX_DELAY_SECONDS = 30
LABEL_RE = re.compile(r"^[a-z0-9][a-z0-9 _.-]{0,39}$")

REPOSITORIES: list[dict[str, Any]] = json.loads((DATASET / "repositories.json").read_text())
ISSUES: list[dict[str, Any]] = json.loads((DATASET / "issues.json").read_text())
REPO_NAMES = {repo["full_name"] for repo in REPOSITORIES}

_LOCK = threading.Lock()


def _ledger_path() -> Path | None:
    raw = os.environ.get("REPO_TRACKER_LEDGER", "").strip()
    return Path(raw) if raw else None


def _record(tool: str, arguments: dict[str, Any], *, ok: bool) -> None:
    """Append one executed call to the ledger (a no-op when no ledger is configured)."""
    path = _ledger_path()
    if path is None:
        return
    with _LOCK, path.open("a", encoding="utf-8") as handle:
        handle.write(
            json.dumps({"tool": tool, "ok": ok, "arguments": arguments}, sort_keys=True) + "\n"
        )


def _ledger() -> list[dict[str, Any]]:
    path = _ledger_path()
    if path is None or not path.exists():
        return []
    with _LOCK:
        lines = path.read_text(encoding="utf-8").splitlines()
    return [json.loads(line) for line in lines if line.strip()]


def _created(tool: str) -> list[dict[str, Any]]:
    """Arguments of every call of ``tool`` that executed and succeeded."""
    return [entry["arguments"] for entry in _ledger() if entry["tool"] == tool and entry["ok"]]


def _keyed(tool: str, key: str | None) -> tuple[int, dict[str, Any]] | None:
    """The first successful call of ``tool`` carrying ``key`` (its position among the tool's
    successful calls, and its arguments), or None. This is what makes a retried write safe:
    an MCP client or orchestrator may re-issue a call whose answer was lost, and the second
    call must not file a second issue or publish a second release."""
    if not key:
        return None
    for position, args in enumerate(_created(tool)):
        if args.get("idempotency_key") == key:
            return position, args
    return None


def _all_issues() -> list[dict[str, Any]]:
    """Seed issues plus the ones issue_write filed, numbered the way the write tool numbered them."""
    issues = [dict(issue) for issue in ISSUES]
    for args in _created("issue_write"):
        number = 1 + max([i["number"] for i in issues if i["repo"] == args["repo"]], default=0)
        issues.append(
            {
                "repo": args["repo"],
                "number": number,
                "title": args["title"],
                "state": "open",
                "labels": list(args.get("labels") or []),
                "author": "caliber-lab",
                "body": args.get("body", ""),
            }
        )
    return issues


def _require_repo(repo: str) -> None:
    if repo not in REPO_NAMES:
        raise ToolError(f"repository {repo!r} was not found")


def _parse_query(query: str) -> tuple[list[str], dict[str, str]]:
    words: list[str] = []
    qualifiers: dict[str, str] = {}
    for token in query.split():
        key, sep, value = token.partition(":")
        if sep and key in {"language", "topic", "org", "archived", "stars"}:
            if not value:
                raise ToolError(f"qualifier {key!r} needs a value")
            qualifiers[key] = value
        elif sep and re.fullmatch(r"[a-z]+", key):
            raise ToolError(f"unknown search qualifier {key!r}")
        else:
            words.append(token.lower())
    if "archived" in qualifiers and qualifiers["archived"] not in {"true", "false"}:
        raise ToolError("archived: must be true or false")
    if "stars" in qualifiers and not re.fullmatch(r"(>=|<=|>|<)?\d+", qualifiers["stars"]):
        raise ToolError(f"stars: expects a number such as stars:>100, got {qualifiers['stars']!r}")
    return words, qualifiers


def _stars_match(stars: int, expression: str) -> bool:
    match = re.fullmatch(r"(>=|<=|>|<)?(\d+)", expression)
    assert match is not None  # validated in _parse_query
    operator, number = match.group(1) or "=", int(match.group(2))
    return {
        ">": stars > number,
        ">=": stars >= number,
        "<": stars < number,
        "<=": stars <= number,
        "=": stars == number,
    }[operator]


def _recorded(tool: str) -> Any:
    """Decorator: append every executed call to the ledger, with whether it succeeded."""

    def wrap(fn: Any) -> Any:
        @functools.wraps(fn)
        def inner(**arguments: Any) -> Any:
            try:
                result = fn(**arguments)
            except Exception:
                _record(tool, arguments, ok=False)
                raise
            # A replayed write (same idempotency_key) executed nothing: it is on the ledger under
            # its own name, so the tool's real executions, and the issues replayed from them, are
            # not counted twice.
            replayed = isinstance(result, dict) and result.get("replayed") is True
            _record(f"{tool}.replay" if replayed else tool, arguments, ok=True)
            return result

        return inner

    return wrap


def build_server() -> MCPServer:
    server = MCPServer(
        "repo-tracker",
        instructions=(
            "An engineering repo tracker for the CALIBER MCP governance lab. "
            "Read tools search and list; issue_write and create_release change state."
        ),
    )

    @server.tool()
    @_recorded("search_repositories")
    def search_repositories(
        query: Annotated[
            str,
            Field(
                description="Free text plus qualifiers: language:, topic:, org:, archived:, stars:>N"
            ),
        ],
        per_page: Annotated[int, Field(ge=1, le=50)] = 10,
    ) -> dict[str, Any]:
        """Search repositories. Returns {total_count, items: [{full_name, language, stars, ...}]}."""
        if not query.strip():
            raise ToolError("query must not be empty")
        words, qualifiers = _parse_query(query)
        items = []
        for repo in REPOSITORIES:
            haystack = " ".join(
                [repo["full_name"], repo["description"], " ".join(repo["topics"])]
            ).lower()
            if not all(word in haystack for word in words):
                continue
            if (
                "language" in qualifiers
                and repo["language"].lower() != qualifiers["language"].lower()
            ):
                continue
            if "topic" in qualifiers and qualifiers["topic"].lower() not in repo["topics"]:
                continue
            if "org" in qualifiers and not repo["full_name"].startswith(qualifiers["org"] + "/"):
                continue
            if "archived" in qualifiers and repo["archived"] != (qualifiers["archived"] == "true"):
                continue
            if "stars" in qualifiers and not _stars_match(repo["stars"], qualifiers["stars"]):
                continue
            items.append(repo)
        items.sort(key=lambda repo: (-repo["stars"], repo["full_name"]))
        return {"total_count": len(items), "items": items[:per_page]}

    @server.tool()
    @_recorded("list_issues")
    def list_issues(
        repo: Annotated[str, Field(description="Repository as owner/name, e.g. acme/payments-api")],
        state: Literal["open", "closed", "all"] = "open",
    ) -> dict[str, Any]:
        """List the issues of one repository. Returns {repo, state, total_count, issues}."""
        _require_repo(repo)
        issues = [
            issue
            for issue in _all_issues()
            if issue["repo"] == repo and (state == "all" or issue["state"] == state)
        ]
        return {
            "repo": repo,
            "state": state,
            "total_count": len(issues),
            "issues": issues,
        }

    @server.tool()
    @_recorded("get_issue")
    def get_issue(
        repo: Annotated[str, Field(description="Repository as owner/name")],
        number: Annotated[int, Field(ge=1)],
    ) -> dict[str, Any]:
        """Fetch one issue by number."""
        _require_repo(repo)
        for issue in _all_issues():
            if issue["repo"] == repo and issue["number"] == number:
                return dict(issue)
        raise ToolError(f"issue #{number} was not found in {repo}")

    @server.tool()
    @_recorded("scan_dependencies")
    def scan_dependencies(
        repo: Annotated[str, Field(description="Repository as owner/name")],
        delay_seconds: Annotated[
            float,
            Field(ge=0, le=MAX_DELAY_SECONDS, description="Simulated upstream latency"),
        ] = 0,
    ) -> dict[str, Any]:
        """Scan a repository's dependencies (a slow upstream call: use delay_seconds to simulate it)."""
        _require_repo(repo)
        time.sleep(delay_seconds)
        language = next(r["language"] for r in REPOSITORIES if r["full_name"] == repo)
        return {
            "repo": repo,
            "language": language,
            "dependencies_scanned": 40 + len(repo),
            "vulnerable": 0,
        }

    @server.tool()
    @_recorded("issue_write")
    def issue_write(
        repo: Annotated[str, Field(description="Repository as owner/name")],
        title: Annotated[str, Field(min_length=3, max_length=200)],
        body: Annotated[str, Field(max_length=4000)] = "",
        labels: list[str] | None = None,
        idempotency_key: Annotated[
            str | None,
        
… truncated — open the file in the repo for the full content.
assets/dataset/tool-classification.jsonl
{"tool": "search_repositories", "side_effect_level": "read", "allowed": true, "requires_approval": false, "why": "Read-only search over the tracker. Safe to call freely."}
{"tool": "list_issues", "side_effect_level": "read", "allowed": true, "requires_approval": false, "why": "Read-only listing of one repository's issues."}
{"tool": "get_issue", "side_effect_level": "read", "allowed": true, "requires_approval": false, "why": "Read-only fetch of one issue."}
{"tool": "scan_dependencies", "side_effect_level": "read", "allowed": true, "requires_approval": false, "rate_limit_per_minute": 3, "why": "Read-only but slow and expensive upstream: capped at 3 calls a minute."}
{"tool": "issue_write", "side_effect_level": "write", "allowed": true, "requires_approval": true, "why": "Changes the tracker. Allowed, but only as an approved action: write tools must carry requires_approval."}
{"tool": "create_release", "side_effect_level": "external_action", "allowed": false, "requires_approval": true, "why": "Publishes a release and notifies a channel; cannot be undone. Blocked outright in this lab."}
assets/dataset/invoke-checks.jsonl
{"id": "F01", "phase": "before_classification", "what": "a discovered but unclassified tool is refused", "tool_name": "search_repositories", "arguments": {"query": "language:python"}, "expect": {"success": false, "error_contains": "has no explicit allow, side-effect, and approval classification", "executed": false, "trace": false}}
{"id": "F02", "phase": "governed", "what": "a blocked tool is refused before it reaches the server", "tool_name": "create_release", "arguments": {"repo": "acme/release-notes-bot", "tag": "v2.4.0", "notes": "Quarterly release"}, "expect": {"success": false, "error_contains": "is blocked by policy", "executed": false, "trace": false}}
{"id": "F03", "phase": "governed", "what": "a tool the server never advertised is refused", "tool_name": "drop_database", "arguments": {}, "expect": {"success": false, "error_contains": "not found on this server", "executed": false, "trace": false}}
{"id": "F04", "phase": "governed", "what": "a rate-limited tool is refused once its per-minute cap is spent", "tool_name": "scan_dependencies", "arguments": {"repo": "acme/ledger-core"}, "expect": {"success": false, "error_contains": "exceeded its process-local limit of 3/minute", "executed": false, "trace": false}, "after_calls": 3}
{"id": "F05", "phase": "governed", "what": "a malformed query is the server's error, surfaced as a failed call", "tool_name": "search_repositories", "arguments": {"query": "stars:>>not-a-number"}, "expect": {"success": false, "error_contains": "stars: expects a number", "executed": true, "trace": true}}
{"id": "F06", "phase": "governed", "what": "an empty query is the server's error", "tool_name": "search_repositories", "arguments": {"query": "   "}, "expect": {"success": false, "error_contains": "query must not be empty", "executed": true, "trace": true}}
{"id": "F07", "phase": "governed", "what": "a missing required argument fails schema validation on the server", "tool_name": "get_issue", "arguments": {"repo": "acme/docs"}, "expect": {"success": false, "error_contains": "Field required", "executed": false, "trace": true}}
{"id": "F08", "phase": "governed", "what": "an unknown repository is the server's error", "tool_name": "list_issues", "arguments": {"repo": "acme/does-not-exist"}, "expect": {"success": false, "error_contains": "was not found", "executed": true, "trace": true}}
{"id": "F09", "phase": "governed", "what": "a slow upstream call times out at the Playground's 10 second limit", "tool_name": "scan_dependencies", "arguments": {"repo": "acme/ledger-core", "delay_seconds": 14}, "expect": {"success": false, "error_contains": "timed out", "executed": false, "trace": true}, "slow": true}
{"id": "F10", "phase": "governed", "what": "an approved-class write tool still runs from the admin Playground (break-glass); it is the workflow that gates it", "tool_name": "issue_write", "arguments": {"repo": "acme/release-notes-bot", "title": "Release notes bot skips pre-release tags", "body": "Seen on v2.4.0-rc1: no Slack post.", "labels": ["bug"]}, "expect": {"success": true, "error_contains": null, "executed": true, "trace": true}}
assets/dataset/calibration-cases.jsonl
{"id": "S01", "tags": ["search"], "tool_name": "search_repositories", "name": "python repositories", "input": {"query": "language:python"}, "assertion": {"type": "output_contains", "value": "\"total_count\": 8"}}
{"id": "S02", "tags": ["search"], "tool_name": "search_repositories", "name": "go repositories", "input": {"query": "language:go"}, "assertion": {"type": "output_contains", "value": "\"total_count\": 4"}}
{"id": "S03", "tags": ["search"], "tool_name": "search_repositories", "name": "repositories tagged mcp", "input": {"query": "topic:mcp"}, "assertion": {"type": "output_contains", "value": "\"total_count\": 2"}}
{"id": "S04", "tags": ["search", "edge"], "tool_name": "search_repositories", "name": "archived repositories", "input": {"query": "archived:true"}, "assertion": {"type": "output_contains", "value": "\"total_count\": 2"}}
{"id": "S05", "tags": ["search"], "tool_name": "search_repositories", "name": "more than 200 stars", "input": {"query": "stars:>200"}, "assertion": {"type": "output_contains", "value": "\"total_count\": 4"}}
{"id": "S06", "tags": ["search"], "tool_name": "search_repositories", "name": "free text: payments", "input": {"query": "payments"}, "assertion": {"type": "output_contains", "value": "\"total_count\": 2"}}
{"id": "S07", "tags": ["search"], "tool_name": "search_repositories", "name": "go with at least 100 stars", "input": {"query": "language:go stars:>=100"}, "assertion": {"type": "output_contains", "value": "\"total_count\": 2"}}
{"id": "S08", "tags": ["search"], "tool_name": "search_repositories", "name": "free text: kubernetes finds the manifests repo", "input": {"query": "kubernetes"}, "assertion": {"type": "output_contains", "value": "\"full_name\": \"acme/k8s-manifests\""}}
{"id": "S09", "tags": ["search"], "tool_name": "search_repositories", "name": "mobile apps", "input": {"query": "topic:mobile"}, "assertion": {"type": "output_contains", "value": "\"total_count\": 2"}}
{"id": "S10", "tags": ["search"], "tool_name": "search_repositories", "name": "one on-call repository", "input": {"query": "org:acme topic:oncall"}, "assertion": {"type": "output_contains", "value": "\"full_name\": \"acme/oncall-runbooks\""}}
{"id": "S11", "tags": ["search", "edge"], "tool_name": "search_repositories", "name": "legacy but not archived finds nothing", "input": {"query": "legacy archived:false"}, "assertion": {"type": "output_contains", "value": "\"total_count\": 0"}}
{"id": "S12", "tags": ["search", "edge"], "tool_name": "search_repositories", "name": "paging does not change the total", "input": {"query": "language:python", "per_page": 3}, "assertion": {"type": "output_contains", "value": "\"total_count\": 8"}}
{"id": "S13", "tags": ["search", "edge"], "tool_name": "search_repositories", "name": "language qualifier is case-insensitive", "input": {"query": "language:PYTHON"}, "assertion": {"type": "output_contains", "value": "\"total_count\": 8"}}
{"id": "S14", "tags": ["search"], "tool_name": "search_repositories", "name": "fewer than 50 stars", "input": {"query": "stars:<50"}, "assertion": {"type": "output_contains", "value": "\"total_count\": 5"}}
{"id": "S15", "tags": ["search"], "tool_name": "search_repositories", "name": "free text: fraud", "input": {"query": "fraud"}, "assertion": {"type": "output_contains", "value": "\"full_name\": \"acme/fraud-rules\""}}
{"id": "S16", "tags": ["search", "edge"], "tool_name": "search_repositories", "name": "most-starred first", "input": {"query": "org:acme"}, "assertion": {"type": "output_contains", "value": "\"items\": [{\"archived\": false, \"description\": \"Double-entry ledger service.\""}}
{"id": "L01", "tags": ["issues"], "tool_name": "list_issues", "name": "payments-api open issues", "input": {"repo": "acme/payments-api", "state": "open"}, "assertion": {"type": "output_contains", "value": "\"total_count\": 5"}}
{"id": "L02", "tags": ["issues"], "tool_name": "list_issues", "name": "payments-api all issues", "input": {"repo": "acme/payments-api", "state": "all"}, "assertion": {"type": "output_contains", "value": "\"total_count\": 7"}}
{"id": "L03", "tags": ["issues"], "tool_name": "list_issues", "name": "ledger-core's one open issue is the flaky test", "input": {"repo": "acme/ledger-core", "state": "open"}, "assertion": {"type": "output_contains", "value": "\"title\": \"Flaky test: test_ledger_reconcile\""}}
{"id": "L04", "tags": ["issues"], "tool_name": "list_issues", "name": "mcp-gateway closed issues", "input": {"repo": "acme/mcp-gateway", "state": "closed"}, "assertion": {"type": "output_contains", "value": "\"total_count\": 4"}}
{"id": "L05", "tags": ["issues"], "tool_name": "list_issues", "name": "docs open issues", "input": {"repo": "acme/docs", "state": "open"}, "assertion": {"type": "output_contains", "value": "\"total_count\": 4"}}
{"id": "L06", "tags": ["issues"], "tool_name": "list_issues", "name": "checkout-web closed issues", "input": {"repo": "acme/checkout-web", "state": "closed"}, "assertion": {"type": "output_contains", "value": "\"total_count\": 2"}}
{"id": "L07", "tags": ["issues"], "tool_name": "list_issues", "name": "fraud-rules all issues", "input": {"repo": "acme/fraud-rules", "state": "all"}, "assertion": {"type": "output_contains", "value": "\"total_count\": 5"}}
{"id": "L08", "tags": ["issues", "edge"], "tool_name": "list_issues", "name": "mcp-gateway's open issue is about timeouts", "input": {"repo": "acme/mcp-gateway", "state": "open"}, "assertion": {"type": "output_contains", "value": "Timeouts are not propagated to stdio servers"}}
{"id": "G01", "tags": ["issue"], "tool_name": "get_issue", "name": "payments-api #1 is the refund timeout", "input": {"repo": "acme/payments-api", "number": 1}, "assertion": {"type": "output_contains", "value": "Refunds over $10,000 time out"}}
{"id": "G02", "tags": ["issue"], "tool_name": "get_issue", "name": "mcp-gateway #4 is the classification rule", "input": {"repo": "acme/mcp-gateway", "number": 4}, "assertion": {"type": "output_contains", "value": "Refuse tools without an explicit classification"}}
{"id": "G03", "tags": ["issue"], "tool_name": "get_issue", "name": "docs #3 is a good first issue", "input": {"repo": "acme/docs", "number": 3}, "assertion": {"type": "output_contains", "value": "good first issue"}}
{"id": "G04", "tags": ["issue"], "tool_name": "get_issue", "name": "ledger-core #5 is closed", "input": {"repo": "acme/ledger-core", "number": 5}, "assertion": {"type": "output_contains", "value": "\"state\": \"closed\""}}
assets/workflow/file-issue.workflow.yaml
# A one-tool workflow: the run input (JSON) becomes the arguments of one governed MCP tool.
# __SERVER_ID__, __TOOL__, __LEVEL__ and __APPROVAL__ are filled in by the lab script (or by hand, see the
# README): the server id from POST /mcp-servers, the tool name, its side-effect level, and whether the
# workflow gates it with requires_approval.
schema_version: 1
workflow_id: mcp-file-issue
name: mcp-file-issue
description: Call one governed MCP tool from a workflow; a write tool waits for a second person.
runtime:
  sdk: openai-agents-python
  sdk_version_policy: runtime-pinned
  compiler_version: caliber-workflow-compiler-v1
  default_model_ref: CALIBER_WORKFLOW_DEFAULT_MODEL
  session:
    type: none
nodes:
  start:
    id: start
    type: start
    outputs:
      user_message:
        type: string
  call_tool:
    id: call_tool
    type: tool
    tool_name: __TOOL__
    inputs:
      input:
        type: string
      arguments:
        type: structured
    outputs:
      text:
        type: string
      result:
        type: structured
      metadata:
        type: structured
  done:
    id: done
    type: output
    inputs:
      response:
        type: string
edges:
  - id: e_start_call
    from: start
    to: call_tool
    map:
      user_message: input
  - id: e_call_done
    from: call_tool
    to: done
    map:
      text: response
tools:
  __TOOL__:
    type: mcp_tool
    server_id: __SERVER_ID__
    tool_name: __TOOL__
    side_effect_level: __LEVEL__
    requires_approval: __APPROVAL__

Evaluation & quality gates

Quality gateTarget
Discovery6 tools, every one unclassified and denied until classified
Search callsearch_repositories returns the 2 repositories tagged mcp; the ledger shows exactly one execution
Calibration of the read tools16/16, 8/8 and 4/4; a wrong expectation gives 15/16 (pass rate 0.9375)
Refusals never run0 ledger lines and no trace for create_release, drop_database and a rate-limited call
Write tool in a workflowwaiting_approval, starter refused (403), runs only after a second person approves and the run is resumed
Developer notes & gotchas
  • Flags. CALIBER_FEATURE_INTEGRATIONS=true opens the MCP Servers page and /mcp-servers (404 feature_disabled otherwise); CALIBER_FEATURE_COOKBOOKS=true is needed only for the last gallery step. Both are preview areas, off by default. Start with scripts/cookbook-env.sh up lab05 --flags integrations,cookbooks.
  • Nothing is simulated. No model is involved; enforcement is deterministic and proved from the server's ledger (--ledger), not only from CALIBER's answer.
  • stdio, not HTTP. Set CALIBER_MCP_STDIO_PYTHON_SCRIPT_ALLOWLIST to the server script's absolute path. A loopback HTTP endpoint is registered and then refused by the egress policy, and /bin/sh or python -c are refused with the reason. A stdio server is a child process, not a sandbox.
  • Accounts and scopes. admin registers, classifies and invokes; lab05-operator saves cases and calibrates; lab05-approver approves. Set CALIBER_OPERATOR_USERS/CALIBER_APPROVER_USERS, leave CALIBER_APPROVAL_ALLOW_SELF_APPROVAL unset, and enable the run queue and runtime approvals or the workflow will not pause.
  • The admin Playground is break-glass. requires_approval does not gate it (issue_write runs there); it holds the tool only inside a workflow. A write or external-action tool must carry approval or be blocked (400 otherwise).
  • Limits. Classification is yours (a tool marked read that writes is invisible); policy lives on the server record; the rate limit is per tool, per minute, in one process. Calibration assertions are no_error, output_contains and equals, and calibrating an approval-class tool returns 409.
  • Not run. The GitHub remote MCP variant (assets/real-world/github-mcp.server.json) is documented but was not executed. Runnable: sdk/caliber-sdk/examples/cookbooks/cookbook_05_governed_tool_connectivity.py (about a minute) and caliber/caliber-ui/e2e/cookbooks/labs/05-mcp-governance.spec.ts.

CALIBER : Contextual Adaptive Lifecycle for Intelligent Build, Evaluation, and Refinement — Cookbooks — every recipe is UI-implementable on the shipped platform. Source + assets under docs-site/cookbooks/<nn>-…/. Regenerate with python3 docs-site/cookbooks/training/build.py.