feat(mcp): expose ai_summary in dbn_get_document response

LEFT JOIN doc_summaries so the document object includes ai_summary
and summary_model alongside id/title. Returns null for docs not yet
backfilled.
This commit is contained in:
2026-06-02 21:40:00 +02:00
parent c84ed2ed78
commit 9e707661af
+13 -2
View File
@@ -18,7 +18,13 @@ try {
$ragDb = dbnToolsRagDb(); $ragDb = dbnToolsRagDb();
$docStmt = $ragDb->prepare("SELECT id, title FROM documents WHERE id = ? LIMIT 1"); $docStmt = $ragDb->prepare("
SELECT d.id, d.title, ds.summary AS ai_summary, ds.summary_model
FROM documents d
LEFT JOIN doc_summaries ds ON ds.document_id = d.id
WHERE d.id = ?
LIMIT 1
");
$docStmt->execute([$documentId]); $docStmt->execute([$documentId]);
$doc = $docStmt->fetch(PDO::FETCH_ASSOC); $doc = $docStmt->fetch(PDO::FETCH_ASSOC);
if (!$doc) { if (!$doc) {
@@ -44,7 +50,12 @@ try {
echo json_encode([ echo json_encode([
'ok' => true, 'ok' => true,
'document' => ['id' => (int)$doc['id'], 'title' => (string)$doc['title']], 'document' => [
'id' => (int)$doc['id'],
'title' => (string)$doc['title'],
'ai_summary' => $doc['ai_summary'] ?? null,
'summary_model' => $doc['summary_model'] ?? null,
],
'chunks' => $chunks, 'chunks' => $chunks,
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);