MCP-RagDoc 3 tools — rag_search, rag_manage และ rag_status
MCP-RagDoc ตั้งใจให้ MCP surface เล็ก: มีเพียง 3 tools ที่จำเป็นต่อ document retrieval และ lifecycle ของ index โดย tool ที่เคยแยกเป็นหลายตัว (sync_kb, sync_status, cancel_sync, rag_health) ถูกรวมเข้าเป็นกลุ่มที่เลือกงานด้วย argument action / view ไม่มี shell, Python execution หรือ arbitrary filesystem tool
| งานที่ต้องการ | เรียกอย่างไร |
|---|---|
| ค้นเอกสาร | rag_search(query) |
| เริ่ม sync | rag_manage(action="sync") |
| ยกเลิก sync | rag_manage(action="cancel", job_id=...) |
| ดูสถานะ job | rag_status(view="job", job_id=...) |
| ตรวจ health | rag_status() หรือ rag_status(view="health") |
rag_search(query)
ใช้ค้น configured documents จาก:
- filename
- indexed keywords / SQLite FTS5 + BM25
- OCR text และ fuzzy recovery
- semantic meaning เมื่อ MiniLM index พร้อม
ผลลัพธ์รักษา source path/location เพื่อให้ caller อ่านเอกสารต้นฉบับต่อได้
Semantic ไม่พร้อมก็ไม่ทำให้ tool หยุด: search degrade ไป lexical/OCR path
rag_manage(action, job_id="")
จัดการ lifecycle ของ sync ผ่าน tool เดียว โดย action มี 2 ค่า:
sync— เริ่ม incremental background rebuild และคืนjob_idทันทีcancel— ขอ cooperative cancellation ของjob_idที่ระบุ ที่ safe checkpoints
Tool ไม่รับ source directory จาก caller เพราะ source root ถูก fix ตอน server launch แล้ว การ sync จึงไม่ใช่ช่องทางให้ model ขยายขอบเขต filesystem
การ cancel: document transaction ที่กำลังทำจะ rollback ถ้ายังไม่ commit ส่วนเอกสารที่ commit แล้วไม่ถูกย้อนทิ้ง และ semantic generation ที่ยังไม่ครบจะไม่ publish ready=1
rag_status(view="health", job_id="")
อ่านสถานะโดยไม่อ่าน full document bodies โดย view มี 2 ค่า:
health(ค่าเริ่มต้น) — source/index/semantic readinessjob— สถานะของ sync job ตามjob_id
view="job" คืนข้อมูลอย่าง:
phase
percentage
current file
completed / total files
ETA
semantic parent progress
activity (ช่วง 1/2 lexical หรือ 2/2 semantic, ความคืบหน้า และไฟล์ปัจจุบัน)
job state persist ข้าม MCP process restart/stdio sessions ได้
view="health" เหมาะกับ:
- เช็คก่อน search หลังเพิ่ง sync
- diagnosis เมื่อ search ไม่มี semantic results
- ตรวจว่า source/index paths ตรงกับ instance ที่ตั้งใจใช้หรือไม่
- ดู document/chunk/vector readiness แบบ bounded
ตัวอย่าง workflow ของ agent
rag_status() # health
↓
ถ้า source เปลี่ยน → rag_manage(action="sync")
↓
rag_status(view="job", job_id=...)
↓
terminal state
↓
rag_search(query)
↓
caller อ่าน source path/page เพิ่มเมื่อจำเป็น
ขอบเขตความรับผิดชอบ
MCP-RagDoc รับผิดชอบ:
- source discovery ภายใน configured root
- extraction/OCR
- lexical/semantic indexing
- retrieval + provenance
- sync lifecycle
ส่วน consuming agent รับผิดชอบ:
- ตัดสินใจว่าจะค้นเมื่อไร
- rephrase query/retry policy
- เปิด/อ่าน source ต่อ
- สังเคราะห์คำตอบให้ผู้ใช้
การแยกสองชั้นนี้ทำให้ MCP-RagDoc ใช้กับ Agent Lite, Codex, ChatGPT-connected local host หรือ agent อื่นได้โดยไม่ต้องเปลี่ยน backend ให้รู้จัก host นั้น
ความคิดเห็น
กำลังโหลดความคิดเห็น...