MCP/Tools
MCP Tools
[edit | edit source]Dura Lex exposes 5 MCP tools. All are jurisdiction-agnostic. Jurisdiction plugins provide tag schemas, formatters, and reference resolvers — not tools.
search
[edit | edit source]Search the corpus with full-text search, tag filters, and faceted discovery.
ALL filters go in the tags parameter. Tag values support Overpass QL-inspired
operators (see Tag filter operators below).
<syntaxhighlight lang="text"> search(
language: str # REQUIRED — ISO 639-1 (fr, en, de, ar...) query: str | None # FTS query (websearch syntax: AND, OR, "phrase", -exclude) tags: dict | None # ALL filters — kind, jurisdiction, source, court, etc. edges: dict | None # Edge filters — key=edge kind, value=target document ID discover: str | None # tag key to discover values for, or "*" for available keys at_date: str | None # historical date (YYYY-MM-DD) — versions in force at that date date_from: str | None # minimum date (YYYY-MM-DD) date_to: str | None # maximum date (YYYY-MM-DD) should_expand_synonyms: bool = true # expand query with legal synonyms limit: int = 20 # results per page (max 100) offset: int = 0 # pagination offset
) </syntaxhighlight>
Tag filter operators (Overpass QL-inspired)
[edit | edit source]Tag values support these operators:
"value"— exact match (default)"!=value"— negation: key exists, value differs"val1|val2"— any of (OR)"!=val1|val2"— none of (negated OR)"*"— key exists (any value)"!*"— key absent
Virtual tag keys (promoted columns filterable as tags)
[edit | edit source]kind:legislation,decision,record,notice. Operators:"legislation|decision","!=record". Drives the fan-out UNION ALL query.jurisdiction(REQUIRED): ISO code. Subdivision-aware:"fr"matchesfr,fr-alsace. Multi:"eu|fr". Wildcard:"*"(no filter). Negation:"!=eu". Omittingtags["jurisdiction"]raises a ToolError — the LLM must always be explicit about jurisdiction scope.source: data source."legi","cass","acco","kali"... Exclusion:"!=acco|kali".language: overrides the auto-filter from thelanguageparameter."fr|en"returns French AND English.
Primary tag filters (T1)
[edit | edit source]T1 tags (cross-jurisdiction enums, documented in TAG-CONVENTIONS.md) are the intended primary search filters — stable English vocabularies, safe to use regardless of jurisdiction: type, document_form, court_level, enforcement_status, importance_level, formation_solemnity, content_quality. For jurisdiction-local precision, fall back to T2/T3 keys (e.g. FR nature) — see spec/TAG-CONVENTIONS.md and the per-plugin tag references.
Edge filters
[edit | edit source]The edges parameter filters documents by their relationships to other
documents. Key = edge kind (from EDGE-TYPES.md), value = target document ID.
Semantics: return documents that have an outgoing edge of this kind to this
target.
| Syntax | Semantics |
|---|---|
"cites": "id1" |
cites id1 |
"cites": "id1|id2" |
cites id1 OR id2 |
"cites": "id1&id2" |
cites id1 AND id2 |
"cites": "id1", "amends": "id2" |
cites id1 AND amends id2 |
"*": "id1" |
any edge kind to id1 |
Edge filters compose with all other search parameters (query, tags, dates,
pagination). The edges parameter is separate from tags because edges are
relationships between documents, not intrinsic properties.
Searchable kinds
[edit | edit source]The search tool only accepts legislation, decision, record, and notice as kind values. section (navigated via browse_structure) and chunk (processing artifact) are valid document kinds in the corpus but are filtered out of search.
Modes
[edit | edit source]- Search mode (query and/or tags provided): FTS + tag filters + date range. Returns ranked results with snippets.
- Browse mode (tags only, no query): returns documents matching tag filters, ordered by date descending.
- Discover mode (discover parameter set): returns distinct values for the given tag key from
tag_stats. Usediscover="*"to list all available tag keys. Usediscover="edge_kinds"to list available edge kinds.
Examples
[edit | edit source]All examples pass tags["jurisdiction"] (REQUIRED).
<syntaxhighlight lang="text"> search(language="fr", query="responsabilite civile", tags={"jurisdiction": "fr", "kind": "decision", "court": "cassation"}) search(language="fr", tags={"jurisdiction": "fr", "kind": "legislation", "type": "collective_agreement", "idcc": "3239"}) search(language="fr", tags={"jurisdiction": "fr", "kind": "legislation", "source": "acco", "type": "collective_agreement"}) search(language="fr", tags={"jurisdiction": "fr", "kind": "decision"}, discover="court") search(language="fr", discover="*", tags={"jurisdiction": "fr", "kind": "decision"}) search(language="fr", query="article 1240", tags={"jurisdiction": "fr", "kind": "legislation"}, at_date="2015-06-15") search(language="fr", tags={"jurisdiction": "fr", "kind": "decision", "importance_level": "highest_importance"}) search(language="fr", tags={"jurisdiction": "fr", "kind": "decision", "official_grade": "A"}) search(language="fr", tags={"jurisdiction": "eu|fr", "kind": "decision", "court_level": "supreme|supranational"}) # apex-court rulings only
- Overpass QL operators
search(language="fr", tags={"jurisdiction": "fr", "kind": "legislation", "source": "!=acco|kali"}) # exclude conventions search(language="fr", tags={"jurisdiction": "eu|fr", "kind": "legislation|decision"}) # multi-kind, multi-jurisdiction search(language="fr", tags={"jurisdiction": "*", "kind": "decision", "official_grade": "*"}) # all jurisdictions, only graded decisions
- Edge filters
search(language="fr", tags={"jurisdiction": "fr", "kind": "decision"}, edges={"cites": "fr.legiarti000032041571"}) # decisions citing article 1240 code civil search(language="fr", query="preuve deloyale", tags={"jurisdiction": "fr"}, edges={"cites": "fr.legiarti000032041571"}) # + FTS search(language="fr", tags={"jurisdiction": "fr"}, edges={"cites": "fr.legiarti000032041571&fr.legiarti000006436298"}) # citing both articles search(language="fr", tags={"jurisdiction": "fr"}, edges={"*": "fr.jorftext000032004539"}) # any relationship to this law search(language="fr", tags={"jurisdiction": "fr"}, discover="edge_kinds") # list available edge kinds </syntaxhighlight>
get_document
[edit | edit source]Retrieve a single document by ID or legal reference.
<syntaxhighlight lang="text"> get_document(
reference: str # document ID or natural language reference
language: str # REQUIRED — ISO 639-1 (fr, en, de...). Disambiguates language variants.
highlight: str | None # select matching blocks (non-contiguous, ±1 context, capped at 40)
blocks: str | None # block range for large documents ("30-50")
at_date: str | None # historical date (YYYY-MM-DD) — version in force at that date
) </syntaxhighlight>
The reference resolver (jurisdiction-specific) parses the reference into a TagQuery and executes it against the store. Falls back to direct ID lookup. For decisions, the output includes grade and formation display: Grade : A — Publié au Recueil Lebon — highest_importance / Formation : Assemblée du contentieux (full_court).
Examples
[edit | edit source]<syntaxhighlight lang="text"> get_document(reference="article 1240 du code civil") get_document(reference="fr.juritext000041701651", highlight="preuve deloyale") get_document(reference="[2024] UKSC 1") </syntaxhighlight>
browse_structure
[edit | edit source]Navigate hierarchical structure (table of contents of codes, conventions, doctrine).
<syntaxhighlight lang="text"> browse_structure(
language: str # REQUIRED — filters the tree (not just labels) tags: dict # REQUIRED, must contain "jurisdiction" root_id: str | None # node ID to start from (NULL = top-level roots) depth: int | None # maximum tree depth (capped at 20 internally) limit: int = 50 # max nodes returned per page offset: int = 0 # pagination offset
) </syntaxhighlight>
tags["jurisdiction"] is REQUIRED — same syntax as search: "fr", "eu",
"eu|fr" (combined), "*" (all jurisdictions). Other tag filters
(e.g., "structure_type": "legislation") are passed through as JSONB
containment filters.
Operates on documents with kind=section. Uses recursive CTE on parent_id.
The jurisdiction and language filters are applied to BOTH the anchor and the
recursive part of the CTE so a parent's children inherit the same scope (no
mixed-jurisdiction or mixed-language trees). Multi-jurisdiction uses
s.jurisdiction = ANY(%(jurisdictions)s) in both anchor and recursive WHERE.
safety_guidelines
[edit | edit source]Retrieve mandatory guidelines for legal research. Two-call workflow: core once at session start, jurisdiction per jurisdictional context.
<syntaxhighlight lang="text"> safety_guidelines(
category: str # REQUIRED — "core" or "jurisdiction" jurisdiction: str | None # REQUIRED iff category="jurisdiction"; ignored (with warning) if category="core"
) </syntaxhighlight>
Categories
[edit | edit source]"core": foundational rules (8 non-negotiable, methodology, defensive posture, response format). Independent of jurisdiction. Called ONCE per session. Passingjurisdictionis non-fatal: the parameter is ignored and a warning is prepended to the returned text instructing the LLM to make a separatecategory="jurisdiction"call."jurisdiction": jurisdiction-specific rules + corpus provenance filtered by jurisdiction. Called when entering a jurisdictional research context. Supports the same Overpass QL syntax astags["jurisdiction"]:"fr","eu","eu|fr"(concatenated),"*"(all jurisdictions),"!=eu"(exclusion). The"!*"operator is not allowed.
Returns jurisdiction-specific guidance: citation rules, search strategy, authority hierarchy, data freshness, caveats.
The plugin protocol (get_guidelines() -> str) returns a single jurisdiction-scoped supplement; the core text lives in duralex.mcp/core.md and is loaded by the MCP server, not by plugins.
quality_check
[edit | edit source]Mandatory research debrief. Fire-and-forget. Two modes:
research— called ONCE per research sequence, at the END, before presenting the answer to the user. Captures the full research journey.correction— called immediately when the model detects an error, or when the user signals one.
PRIVACY: ABSOLUTE. Only technical and structural data. Never user facts, names, conversation content, or anything that could identify a party.
<syntaxhighlight lang="text"> quality_check(
mode: str # "research" or "correction" model: str # LLM model identifier jurisdiction: str | None # jurisdiction(s) researched (fr, eu, eu|fr, *) — always include
# Research-mode fields queries_attempted: list[str] | None # legal-concept queries (no user facts) tools_sequence: list[str] | None # ordered tool calls (e.g. ["search","get_document"]) documents_cited: list[str] | None # IDs of documents cited in the answer tags_used: dict | None # tag filters applied satisfaction: str | None # sufficient | partial | insufficient confidence: str | None # high | moderate | low gaps: list[str] | None # coverage gaps identified difficulties: list[str] | None # technical issues encountered concept: str | None # legal concept label for synonym groups
# Correction-mode fields
error_type: str | None # fabricated_citation | wrong_jurisdiction
# | repealed_law | misattribution
# | temporal_error | wrong_article
# | user_correction
document_ids: list[str] | None # documents involved in the error
detail: str | None # technical description (no user facts)
severity: str | None # critical | important | minor
# Self-audit checklist (11 booleans, all default False) # Pure presence-of-string checks on the pending response / visible context. # Declared-true values trigger adaptive alerts tiered STOP / DANGER / # DRIFT / ATTENTION; the tool returns a structured block the model must # translate-and-relay to the user before emitting. context_contains_compaction_marker: bool response_self_references_previous_turn: bool response_contains_flattery: bool response_contains_prescriptive_legal_advice: bool response_contains_outcome_prediction: bool response_contains_legal_assertion_verb: bool response_contains_hedge_marker: bool response_cites_document_without_verbatim_or_locator: bool response_cites_document_without_permanent_link: bool response_claims_settled_case_law: bool response_asserts_legal_absence_as_inexistence: bool safety_guidelines_not_fully_loaded: bool safety_guidelines_distant_or_unclear: bool
) </syntaxhighlight>
The feedback server is schema-agnostic; the tool adds "tool_name": "quality_check" automatically so downstream JSONL analysis can distinguish quality_check payloads from older report payloads.
The 11 self-audit booleans and the computed highest_alert_severity are persisted in the payload for forensic analysis of declaration rates per boolean. See ADR 2026-04-15-quality-check-self-audit-checklist for the full rationale and the alert-severity tiering.