MCP tool not found. Back to MCP setup

'; exit; } // ── Load translations ───────────────────────────────────────────────────────── $toolTranslations = []; $toolTransFile = __DIR__ . '/includes/mcp-tool-translations.php'; if (file_exists($toolTransFile)) { $toolTranslations = (array)include $toolTransFile; } function mcpToolT(string $slug, string $field, string $lang, array $trans): string { $fallback = $trans[$slug]['en'][$field] ?? ''; return (string)($trans[$slug][$lang][$field] ?? $fallback); } function mcpToolParamT(string $slug, string $param, string $lang, array $trans): string { $fallback = $trans[$slug]['en']['params'][$param] ?? ''; return (string)($trans[$slug][$lang]['params'][$param] ?? $fallback); } // ── Resolved display data ──────────────────────────────────────────────────── $slug = (string)($toolDef['slug'] ?? ''); $displayName = mcpToolT($slug, 'display_name', $uiLang, $toolTranslations) ?: (string)($toolDef['display_name'] ?? $slug); $description = mcpToolT($slug, 'description', $uiLang, $toolTranslations) ?: (string)($toolDef['description'] ?? ''); $props = (array)($toolDef['config']['input_schema']['properties'] ?? []); $required = (array)($toolDef['config']['input_schema']['required'] ?? []); $toolIcons = [ 'dbn.search_legal' => '🔍', 'dbn.ask' => '💬', 'dbn.summarize' => '📋', 'dbn.timeline' => '📅', 'dbn.redact' => '🔒', 'dbn.translate' => '🌍', 'dbn.legal_analysis' => '⚖️', 'dbn.korrespond' => '✉️', 'dbn.barnevernet_analyze' => '📄', 'dbn.advocate_brief' => '🏛️', 'dbn.deep_research' => '🔬', 'dbn.discrepancy_find' => '🔄', 'dbn.transcribe_audio' => '🎤', 'dbn.corpus_stats' => '📊', 'dbn.list_documents' => '📚', 'dbn.get_document' => '📖', 'dbn.citation_graph' => '🔗', 'dbn.case_workbench_plan' => '🗂️', 'dbn.save_to_case' => '💾', ]; $toolIcon = $toolIcons[$slug] ?? '🔧'; // ── Example requests (per tool) ─────────────────────────────────────────────── $exampleRequests = [ 'dbn.search_legal' => <<<'JSON' { "query": "emergency care order requirements barnevernet", "language": "en", "limit": 5, "corpus_scope": "shared" } JSON, 'dbn.ask' => <<<'JSON' { "question": "Can Barnevernet remove a child without a court hearing?", "language": "en", "use_case_context": false } JSON, 'dbn.summarize' => <<<'JSON' { "text": "Paste the case document text here...", "language": "en", "use_legal_corpus": true, "use_case_context": false } JSON, 'dbn.timeline' => <<<'JSON' { "text": "Paste case notes or decision letter here...", "language": "en", "focus": "all", "use_case_context": false } JSON, 'dbn.redact' => <<<'JSON' { "text": "On 15.03.2024 caseworker Anna Hansen met with...", "language": "no", "mode": "standard", "output_format": "contextual" } JSON, 'dbn.translate' => <<<'JSON' { "text": "Barnevernet fattet vedtak om omsorgsovertakelse...", "source_lang": "no", "target_lang": "en", "doc_type": "barnevernet" } JSON, 'dbn.legal_analysis' => <<<'JSON' { "text": "Paste the document text to analyze here...", "language": "en", "doc_type": "auto" } JSON, 'dbn.korrespond' => <<<'JSON' { "narrative": "Barnevernet issued an emergency placement order without notification.", "recipient_body": "Barnevernet", "goal": "Appeal the decision and request access to case documents.", "mode": "initiate", "language": "en" } JSON, 'dbn.barnevernet_analyze' => <<<'JSON' { "document_text": "Paste the Barnevernet document text here...", "filename": "vedtak-omsorgsovertakelse.pdf", "advocate_role": "parent", "language": "en" } JSON, 'dbn.advocate_brief' => <<<'JSON' { "query": "Grounds for challenging a care order under BVL §4-12", "advocate_role": "parent", "language": "en", "use_case_context": false } JSON, 'dbn.deep_research' => <<<'JSON' { "query": "ECHR Article 8 violations in Norwegian child welfare cases", "language": "en", "use_case_context": false } JSON, 'dbn.discrepancy_find' => <<<'JSON' { "document_a_text": "Text of the first document version...", "document_b_text": "Text of the second document version...", "filename_a": "report-2023.pdf", "filename_b": "report-2024.pdf", "language": "en" } JSON, 'dbn.transcribe_audio' => <<<'JSON' { "audio_url": "https://example.com/meeting-recording.mp3", "language": "no", "diarize": true } JSON, 'dbn.corpus_stats' => '{}', 'dbn.list_documents' => <<<'JSON' { "category": "barnevernet", "limit": 20, "offset": 0 } JSON, 'dbn.get_document' => <<<'JSON' { "document_id": 42 } JSON, 'dbn.citation_graph' => <<<'JSON' { "doc_id": 42, "action": "cites", "depth": 2 } JSON, 'dbn.case_workbench_plan' => <<<'JSON' { "situation": "Barnevernet has scheduled a Fylkesnemnda hearing in 3 weeks. I need to prepare a response.", "goal": "Challenge the care order and request return of the child.", "deadline": "2024-06-15", "language": "en" } JSON, 'dbn.save_to_case' => <<<'JSON' { "tool": "dbn.legal_analysis", "title": "Legal analysis of care order decision", "input_payload": { "text": "...", "language": "en" }, "output_payload": { "issues": [...], "summary": "..." } } JSON, ]; // ── Example responses (per tool) ────────────────────────────────────────────── $exampleResponses = [ 'dbn.search_legal' => <<<'JSON' { "ok": true, "results": [ { "title": "BVL §4-12 — Vedtak om omsorgsovertakelse", "chunk_text": "§ 4-12. Vedtak om å overta omsorgen for et barn kan treffes dersom...", "score": 0.91, "source": "barnevernsloven" }, { "title": "NOU 2012:5 — Bedre beskyttelse av barns utvikling", "chunk_text": "Utvalget vurderer at terskelen for akuttvedtak bør klargjøres...", "score": 0.84, "source": "nou" } ], "total": 2 } JSON, 'dbn.ask' => <<<'JSON' { "ok": true, "answer": "Under Norwegian law, Barnevernet may issue an emergency care order (akuttvedtak) under BVL §4-6 without a prior court hearing if there is immediate risk of serious harm. However, the case must be reviewed by Fylkesnemnda within six weeks...", "sources": [ { "title": "BVL §4-6 — Midlertidige vedtak", "url": "/corpus/bvl-4-6" }, { "title": "Strand Lobben m.fl. mot Norge (EMD)", "url": "/corpus/echr-strand-lobben" } ], "credits_used": 3 } JSON, 'dbn.summarize' => <<<'JSON' { "ok": true, "summary": "The document is a Barnevernet investigation report concerning a family with two children. Key findings include...", "key_points": [ "Home visit conducted 12.03.2024 — no immediate danger found", "Tiltaksplan proposed with three support measures", "Next review scheduled for 15.06.2024" ], "credits_used": 5 } JSON, 'dbn.timeline' => <<<'JSON' { "ok": true, "events": [ { "date": "2024-03-12", "date_type": "ABSOLUTE", "confidence": "HIGH", "actor": "Barnevernet", "description": "Home visit conducted following anonymous report", "source_excerpt": "12.03.2024: hjemmebesøk ble gjennomført..." }, { "date": "2024-06-15", "date_type": "ABSOLUTE", "confidence": "HIGH", "actor": "Fylkesnemnda", "description": "Scheduled hearing date", "source_excerpt": "Nemnda berammer møte til 15. juni 2024" } ], "next_practical_step": "File your written submission before the 06.06.2024 deadline.", "credits_used": 4 } JSON, 'dbn.redact' => <<<'JSON' { "ok": true, "redacted_text": "On [DATE A] caseworker [PERSON A] met with [PERSON B] at [ADDRESS A]...", "replacements": [ { "original": "15.03.2024", "replacement": "[DATE A]" }, { "original": "Anna Hansen", "replacement": "[PERSON A]" }, { "original": "Ola Nordmann", "replacement": "[PERSON B]" } ], "credits_used": 2 } JSON, 'dbn.translate' => <<<'JSON' { "ok": true, "source_lang": "no", "target_lang": "en", "translated_text": "Barnevernet issued a care order decision (vedtak om omsorgsovertakelse)...", "annotations": [ { "term": "omsorgsovertakelse", "note": "Care order — formal transfer of parental responsibility to the state under BVL §4-12" }, { "term": "Fylkesnemnda", "note": "County Social Welfare Board — the quasi-judicial body that reviews Barnevernet decisions" } ], "credits_used": 6 } JSON, 'dbn.legal_analysis' => <<<'JSON' { "ok": true, "issues": [ { "issue": "Procedural rights under forvaltningsloven §17", "analysis": "The parent was not given an opportunity to be heard before the decision was made, potentially violating fvl §17...", "legal_basis": ["forvaltningsloven §17", "BVL §6-3"], "sources": [{ "title": "fvl §17 — Plikten til å påse at saken er opplyst" }] } ], "overall_assessment": "The document shows potential procedural violations that may form grounds for an appeal.", "credits_used": 8 } JSON, 'dbn.korrespond' => <<<'JSON' { "ok": true, "letter_no": "Til Barnevernet\nDato: 24.05.2024\n\nAnke på vedtak om omsorgsovertakelse...", "letter_en": "To Barnevernet\nDate: 24.05.2024\n\nAppeal against care order decision...", "cited_sources": ["BVL §4-12", "forvaltningsloven §28", "EMK artikkel 8"], "credits_used": 10 } JSON, 'dbn.barnevernet_analyze' => <<<'JSON' { "ok": true, "red_flags": [ "Decision issued without notification to parent (fvl §16 violation)", "No tiltaksplan offered before escalating to care order (BVL §4-4)" ], "legal_issues": [ "Potential violation of proportionality principle — less intrusive measures not exhausted", "ECHR Art. 8 family life rights not addressed in reasoning" ], "recommendations": [ "File an appeal within 3 weeks citing fvl §28", "Request full case file under fvl §18", "Consult Fylkesnemnda procedural timeline" ], "credits_used": 7 } JSON, 'dbn.advocate_brief' => <<<'JSON' { "ok": true, "brief": "On behalf of the parent, the following legal arguments support challenging the care order under BVL §4-12...", "legal_arguments": [ "The threshold for care order under §4-12(a) requires 'serious deficiencies' — the report does not meet this standard", "Proportionality requires exhausting support measures (§4-4) before removal" ], "sources": [ { "title": "BVL §4-12", "type": "statute" }, { "title": "Rt-2015-110", "type": "case_law" } ], "credits_used": 9 } JSON, 'dbn.deep_research' => <<<'JSON' { "ok": true, "research_angles": [ "Procedural safeguards under ECHR Art. 6 in child welfare proceedings", "Substantive requirements for care order threshold (BVL §4-12)", "Norwegian Supreme Court interpretation of best interests standard" ], "brief": "Research synthesis: The European Court of Human Rights has found Norway in violation of Art. 8 in 14 cases since 2015, with the core issue being...", "citations": [ "Strand Lobben m.fl. mot Norge, EMD-37283/13 (10.09.2019)", "Johansen mot Norge, EMD-17383/90 (07.08.1996)" ], "credits_used": 15 } JSON, 'dbn.discrepancy_find' => <<<'JSON' { "ok": true, "discrepancies": [ { "type": "deletion", "location": "Section 3, paragraph 2", "original": "The child expressed a wish to return home.", "modified": "[removed]", "significance": "HIGH — child's stated preference is a legally relevant factor under BVL §6-3" }, { "type": "added_claim", "location": "Section 5", "original": "[absent]", "modified": "The parent failed to attend the scheduled meeting.", "significance": "MEDIUM — unverified claim added in the later version" } ], "credits_used": 6 } JSON, 'dbn.transcribe_audio' => <<<'JSON' { "ok": true, "transcript": "Full transcript of the audio recording...", "segments": [ { "speaker": "A", "start": 0.0, "end": 4.2, "text": "God morgen, vi er samlet for å diskutere..." }, { "speaker": "B", "start": 4.5, "end": 9.1, "text": "Takk. Jeg ønsker å starte med å si at..." } ], "language_detected": "no", "credits_used": 8 } JSON, 'dbn.corpus_stats' => <<<'JSON' { "ok": true, "documents": 2847, "chunks": 94231, "sources": { "statutes": 42, "tribunal_decisions": 1204, "echr_cases": 187, "government_reports": 1414 }, "last_updated": "2024-05-01" } JSON, 'dbn.list_documents' => <<<'JSON' { "ok": true, "documents": [ { "id": 42, "title": "BVL §4-12 — Vedtak om omsorgsovertakelse", "category": "statute" }, { "id": 87, "title": "FNV-2023-142 — Fylkesnemnda for barnevern og sosiale saker", "category": "tribunal" }, { "id": 203, "title": "Strand Lobben m.fl. mot Norge (EMD-37283/13)", "category": "echr" } ], "total": 847, "offset": 0 } JSON, 'dbn.get_document' => <<<'JSON' { "ok": true, "document": { "id": 42, "title": "BVL §4-12 — Vedtak om omsorgsovertakelse", "category": "statute", "chunks": [ { "chunk_id": 1, "text": "§ 4-12. Vedtak om å overta omsorgen for et barn kan treffes dersom..." }, { "chunk_id": 2, "text": "(a) det er alvorlige mangler ved den daglige omsorg som barnet får..." } ] } } JSON, 'dbn.citation_graph' => <<<'JSON' { "ok": true, "action": "cites", "root": { "id": 42, "title": "BVL §4-12" }, "nodes": [ { "id": 42, "title": "BVL §4-12", "type": "statute" }, { "id": 15, "title": "BVL §4-4 — Hjelpetiltak", "type": "statute" }, { "id": 203, "title": "Strand Lobben m.fl. mot Norge", "type": "echr" } ], "edges": [ { "from": 42, "to": 15, "type": "cites" }, { "from": 42, "to": 203, "type": "cites" } ], "depth": 1 } JSON, 'dbn.case_workbench_plan' => <<<'JSON' { "ok": true, "plan": { "situation_summary": "Fylkesnemnda hearing scheduled in 3 weeks — care order challenge.", "steps": [ "1. Request full case file under forvaltningsloven §18 — submit by 01.06.2024", "2. Run Legal Analysis tool on the original care order decision", "3. Create Advocate Brief (parent role) with the grounds for challenge", "4. Draft formal response letter using Korrespond (Fylkesnemnda preset)", "5. Compile timeline of all procedural dates" ], "recommended_tools": ["dbn.legal_analysis", "dbn.advocate_brief", "dbn.korrespond", "dbn.timeline"], "deadline": "2024-06-15" }, "credits_used": 3 } JSON, 'dbn.save_to_case' => <<<'JSON' { "ok": true, "saved": true, "case_entry_id": "entry_abc123", "title": "Legal analysis of care order decision", "saved_at": "2024-05-24T09:15:00Z" } JSON, ]; $exReq = trim($exampleRequests[$slug] ?? '{}'); $exResp = trim($exampleResponses[$slug] ?? '{"ok":true}'); ?> <?= htmlspecialchars($displayName) ?> — <?= htmlspecialchars(dbnToolsT('mcp_page_title', $uiLang)) ?>

$paramDef): $isReq = in_array($paramName, $required, true); $paramType = (string)($paramDef['type'] ?? 'string'); $enumVals = (array)($paramDef['enum'] ?? []); $paramDesc = mcpToolParamT($slug, $paramName, $uiLang, $toolTranslations); if ($paramDesc === '') { $paramDesc = (string)($paramDef['description'] ?? ''); } ?>

*

POST /api/mcp/user/tools//invoke