API Reference

MCP tool signatures and parameters

Berry exposes 11 MCP tools. Two are verification tools, the rest are for evidence management.

detect_hallucination

Information-budget diagnostic per claim. Takes an answer with citations and checks whether each sentence is supported by the cited evidence.

Parameters

NameTypeDefaultDescription
answerstringrequiredThe answer text with [S#] citations
spansarrayrequiredEvidence spans: [{sid: "S0", text: "..."}]
verifier_modelstring"gpt-4o-mini"Model to use for verification
default_targetfloat0.95Confidence threshold
max_claimsint25Maximum claims to verify
require_citationsboolfalseFlag claims without citations
context_modestring"cited""cited" = only cited spans count
timeout_sfloat60.0Timeout in seconds

Returns

{
  "flagged": true/false,
  "summary": { "claims_scored": N, "flagged_claims": N },
  "details": [
    { "idx": 0, "claim": "...", "cites": [...], "flagged": true/false }
  ]
}

audit_trace_budget

Score explicit (claim, cites) steps. Takes a structured trace of reasoning steps and verifies each step has sufficient evidence.

Parameters

NameTypeDefaultDescription
stepsarrayrequiredClaim steps: [{claim: "...", cites: ["S0"]}]
spansarrayrequiredEvidence spans: [{sid: "S0", text: "..."}]
verifier_modelstring"gpt-4o-mini"Model to use for verification
default_targetfloat0.95Confidence threshold
require_citationsboolfalseFlag claims without citations
context_modestring"cited""cited" = only cited spans count
timeout_sfloat60.0Timeout in seconds

Returns

{
  "flagged": true/false,
  "details": [
    { "idx": 0, "claim": "...", "cites": [...], "flagged": true/false }
  ]
}

start_run

Create a new run directory with a problem statement and immutable deliverable anchor.

Parameters

NameTypeDefaultDescription
problem_statementstringrequiredWhat you're trying to solve
deliverablestringrequiredWhat the output should be
run_idstringautoOptional custom run ID

Returns

{
  "run_id": "abc123",
  "run_dir": "/path/to/.berry/runs/abc123",
  "problem_sid": "S0",
  "deliverable_sid": "S1"
}

load_run

Resume an existing run (loads from disk if necessary) and set it active.

Parameters

NameTypeDefaultDescription
run_idstringrequiredThe run ID to load

Returns

{
  "run_id": "abc123",
  "run_dir": "/path/to/.berry/runs/abc123",
  "status": "loaded" | "active"
}

get_deliverable

Get the immutable deliverable anchor for the active run.

Parameters

NameTypeDefaultDescription
run_idstringactiveOptional run ID (uses active run if not provided)

Returns

{
  "run_id": "abc123",
  "deliverable_sid": "S1",
  "text": "The deliverable text",
  "meta": {}
}

add_span

Add evidence from text.

Parameters

NameTypeDefaultDescription
textstringrequiredThe evidence text
sourcestring"manual"Source label
run_idstringactiveOptional run ID
metaobjectnullOptional metadata

Returns

{
  "run_id": "abc123",
  "sid": "S2",
  "chars": 150
}

add_file_span

Capture lines from a local file (path + line range) as evidence.

Parameters

NameTypeDefaultDescription
pathstringrequiredPath to the file
start_lineintrequiredFirst line (1-indexed)
end_lineintrequiredLast line (inclusive)
sourcestring"file"Source label
run_idstringactiveOptional run ID
metaobjectnullOptional metadata

Returns

{
  "run_id": "abc123",
  "sid": "S3",
  "path": "/path/to/file.py",
  "start_line": 10,
  "end_line": 25
}

distill_span

Extract key lines from a large span (regex-based), creating a new span.

Parameters

NameTypeDefaultDescription
parent_sidstringrequiredThe span to distill from
patternstringrequiredRegex pattern to match
run_idstringactiveOptional run ID
sourcestring"distill"Source label
flagsstring"i"Regex flags (i=ignore case, m=multiline)
max_linesint200Maximum lines to extract

Returns

{
  "run_id": "abc123",
  "sid": "S4",
  "parent_sid": "S3",
  "lines": 15
}

list_spans

List all spans (metadata only).

Parameters

NameTypeDefaultDescription
run_idstringactiveOptional run ID
limitint200Maximum spans to return

Returns

{
  "run_id": "abc123",
  "spans": [
    { "sid": "S0", "source": "manual", "chars": 150 }
  ]
}

get_span

Fetch full span text.

Parameters

NameTypeDefaultDescription
sidstringrequiredThe span ID to fetch
run_idstringactiveOptional run ID

Returns

{
  "run_id": "abc123",
  "sid": "S0",
  "text": "The full span text",
  "source": "manual",
  "created_at": 1234567890.0,
  "meta": {}
}

search_spans

Search over span texts (lightweight token match scoring).

Parameters

NameTypeDefaultDescription
querystringrequiredSearch query
run_idstringactiveOptional run ID
limitint10Maximum results

Returns

{
  "run_id": "abc123",
  "query": "auth",
  "results": [
    { "sid": "S0", "score": 5.0, "preview": "...", "source": "manual" }
  ]
}