agentrag
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
agentRAG
Intelligent Memory System for AI Agents - Hybrid text+code RAG that helps agents reason over codebases with structured retrieval instead of naive grep-and-guess.
๐ฏ Overview
agentRAG adalah sistem memory cerdas yang dirancang khusus untuk AI agents. Sistem ini membantu agent bekerja di atas codebase dan dokumentasi dengan retrieval yang lebih terstruktur, sehingga agent tidak hanya membuka file secara acak atau menebak arsitektur dari potongan teks yang kebetulan cocok.
โจ Key Features
๐ง Automatic Query Planning - Sistem otomatis mengklasifikasikan query Anda:
Deteksi intent (explain function, bug hunt, refactor, dll)
Klasifikasi tipe konten (code vs documentation)
Ekstraksi bahasa pemrograman
Identifikasi nama function/class yang dicari
๐ Smart Fallback Strategy - Jika pencarian strict tidak menemukan hasil, sistem secara bertahap melonggarkan filter untuk memberikan hasil terbaik yang tersedia
๐ฆ Hybrid Chunking - Strategi chunking yang berbeda untuk setiap tipe konten:
Code: AST-based chunking (per function/class) menggunakan Tree-sitter
Text: Delimiter-based chunking (per section/topic) untuk menjaga konteks
๐ MCP Server Integration - Native support untuk Model Context Protocol:
3 tools siap pakai:
query_memory,ingest_documents,health_checkCompatible dengan Claude, Kiro CLI, dan MCP clients lainnya
Natural language query support
โก Delta Sync - Re-ingest yang efisien:
Hanya update chunks yang berubah
Hapus chunks yang sudah tidak ada
Stable chunk identity dengan content hashing
๐ Watch Mode - Pantau folder dan ingest perubahan secara batch:
Command:
agentrag watch <folder>Menghormati
.gitignoreDebounce, batching, dan extension filter
๐ URL Ingest - Ingest langsung dari web:
Support PDF, DOCX, Markdown, HTML
Auto-sanitization untuk menghilangkan noise (header/footer/menu)
Via Jina Reader API
๐จ Multi-Language Support - Python, JavaScript, TypeScript, Go, Java, Rust, C/C++
๐๏ธ Architecture
User Query โ Query Planner โ Retrieval โ Ranking โ Results
โ
Auto-detect:
- Intent
- Node Type
- Language
- Symbol Name๐ Use Cases
AI Agent Memory - Berikan AI agent akses ke codebase dan dokumentasi Anda
Code Search - Cari function, class, atau pattern tertentu dalam codebase
Documentation Search - Temukan guide, tutorial, atau API docs dengan cepat
Bug Investigation - Cari error patterns atau exception handling
Refactoring Assistant - Temukan code yang perlu di-refactor
Related MCP server: rag-mcp
๐ฆ Installation
Prerequisites
Python 3.10+
Qdrant Cloud account (atau local Qdrant instance)
Understanding of vector dimensions (recommended)
Install
Copy
.env.exampleto.envand fillQDRANT_URL+QDRANT_API_KEY.Install dependencies with
uv sync(recommended) or:
pip install -r requirements.txt
pip install -e .If you want to use EMBEDDING_PROVIDER=llama_cpp_python on Windows/Python 3.12, do not rely on a plain pip install llama-cpp-python. Use the verified wheel install:
pip install llama-cpp-python --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu --only-binary=:all:
python -c "from llama_cpp import Llama; print('Success: llama-cpp-python is working!')"For a repeatable Windows setup, you can also run:
powershell -ExecutionPolicy Bypass -File .\scripts\install_windows.ps1For development/testing:
pip install -r requirements-dev.txtQuick Start
Run ingest (local file/dir):
agentrag ingest docs/PRD.mdIngest from web URL (via Jina Reader public API):
agentrag ingest "https://example.com/guide.pdf"Ingest multiple URLs:
agentrag ingest \
"https://example.com/a.pdf" \
"https://example.com/b.md" \
"https://example.com/c.docx"Mixed local + URL targets:
agentrag ingest ./docs "https://example.com/spec"Watch a folder and auto-ingest changes:
agentrag watch ./docs
agentrag watch ./my-project --extensions .py,.md --batch-size 3 --debounce-seconds 2
agentrag watch ./my-project --dry-runRun query:
agentrag query "qdrant cloud url" --node-type text --top-k 3Query result is returned as JSON (MCP-friendly), including detected plan and hits.
Check Qdrant connectivity:
agentrag health๐ MCP Server Integration
agentRAG menyediakan MCP (Model Context Protocol) server untuk integrasi dengan AI agents.
Available Tools
query_memory - Search dengan automatic query planning
ingest_documents - Tambah dokumen ke memory
health_check - Cek status sistem
Configuration
Add to your MCP client config (e.g., Kiro CLI ~/.kiro/mcp.json):
{
"mcpServers": {
"agentrag": {
"command": "python",
"args": ["-m", "agentrag.mcp_server"],
"cwd": "/path/to/agentRAG",
"env": {
"PYTHONPATH": "/path/to/agentRAG"
}
}
}
}Usage Example
AI Agent: "Use agentrag to find python function for calculate ROI"
agentRAG automatically:
- Detects: intent=explain_function, node_type=code, language=python
- Searches with filters
- Returns ranked resultsDocumentation:
MCP_SERVER_README.md - Complete MCP server guide
MCP_QUICK_REF.md - Quick reference
MCP_TESTING.md - Testing guide
MCP_INSPECTOR_GUIDE.md - Visual testing with MCP Inspector
๐ Features Deep Dive
Automatic Query Planning
Query Anda otomatis dianalisis untuk mendeteksi:
Intent Detection:
explain_function- "python function calculate_roi"bug_hunt- "bug in authentication error"refactor_guidance- "refactor user service"find_snippet- "show code example"general_query- Query umum
Node Type Classification:
code- Jika menyebut "function", "class", "method"text- Jika menyebut "docs", "documentation", "guide"
Language Detection:
Auto-detect dari keyword: "python", "javascript", "golang", dll
Symbol Extraction:
"function calculate_roi" โ
symbol_name: calculate_roi"class UserService" โ
symbol_name: UserService
Smart Fallback Strategy
Jika strict search tidak menemukan hasil:
Strict Search (all filters)
โ No results?
Fallback 1: Remove symbol_name
โ No results?
Fallback 2: Remove language
โ No results?
Fallback 3: Remove node_type
โ
Return best available resultsHybrid Chunking Strategy
Source Type | Strategy | Description |
Code | AST-Based | Per function/class menggunakan Tree-sitter atau Python AST |
Text | Delimiter-Based | Per section/topic berdasarkan Markdown headers |
Supported Languages:
Python (built-in AST)
JavaScript/TypeScript (Tree-sitter)
Go, Java, Rust, C/C++ (Tree-sitter)
Learn More:
Vector Dimensions Explained - Memahami dimensi vektor dan embedding models
๐ง Advanced Usage
Ingest Behavior
Re-ingest uses delta sync per
source_id.Chunk identity is stable:
hash(source_id + content_hash).Only changed/new chunks are upserted.
Stale chunks (no longer present in source) are deleted.
ingestaccepts local files/directories andhttp(s)URLs in the same command.URL ingest fetches content through
https://r.jina.ai/and sanitizes common web noise (header/footer/menu separators/emojis) before chunking.For URL sources,
source_idis the URL itself. Re-running ingest on the same URL performs delta sync against that URL.Dry-run is available to inspect changes without writing:
watchmonitors file changes and triggers batchedingestcalls.watchuses Git-aware ignore handling when the target folder is inside a Git repo.watchsupports--dry-run,--extensions,--batch-size,--debounce-seconds, and--non-recursive.
agentrag ingest ../PYRAG/test_data --dry-runDry-run with multiple URLs:
agentrag ingest \
"https://example.com/a.pdf" \
"https://example.com/b" \
--dry-run.gitignore Support
When ingesting directories, agentRAG automatically respects .gitignore patterns:
Reads
.gitignorefrom the target directoryExcludes files matching patterns (wildcards, directories)
Always excludes
.git/directory by defaultWorks with nested directories and complex patterns
Example:
# .gitignore in your project
*.pyc
__pycache__/
node_modules/
dist/
# Ingest will automatically skip these files
agentrag ingest ./my-projectCode Graph (Definitions / Callers / Callees)
agentRAG sekarang mendukung navigasi graph sederhana berbasis payload index di Qdrant (tanpa penyimpanan lain):
Definitions: temukan chunk definisi simbol (function/class/method) via
code_metadata.symbol_name.Callers: temukan chunk yang memanggil sebuah simbol via
code_metadata.calls.Callees: ambil daftar pemanggilan dari payload definisi (field
code_metadata.calls).
CLI commands:
# Watch local changes and auto-ingest
agentrag watch ./my-project --extensions .py,.md
# Definisi simbol
agentrag defs calculate_roi --language python --limit 10
# Siapa yang memanggil simbol ini?
agentrag callers calculate_roi --language python --limit 25
# Simbol ini memanggil apa saja?
agentrag callees calculate_roi --language pythonMCP tool (opsional): code_graph dengan action salah satu dari: definitions, callers, callees.
URL Ingest Details
Fetch path:
JINA_READER_BASE_URL + target_url(defaulthttps://r.jina.ai/).Intended web document targets:
md,txt,rst,pdf,docx,doc,html,htm, and generic web pages.Sanitization removes common navigation/header/footer fragments, separator lines, and emoji-heavy noise before chunking.
If fetch fails or sanitized content is empty, target is counted as
skipped.
URL Ingest Config
Set in .env:
JINA_READER_BASE_URL=https://r.jina.ai/
WEB_FETCH_TIMEOUT_SECONDS=45JINA_READER_BASE_URL: Base endpoint for web-to-text extraction.WEB_FETCH_TIMEOUT_SECONDS: Request timeout per URL fetch.
๐ Chunking Strategy
Source Type | Strategy | Description |
Kode Pemrograman | AST-Based Chunking | Menggunakan parser (seperti Tree-sitter) untuk memotong kode berdasarkan struktur logika (Abstract Syntax Tree), seperti per class atau per fungsi. Tujuannya agar sintaks tetap utuh dan tidak terpotong di tengah blok logika. |
Teks / Narasi | Safeword / Delimiter | Memotong teks berdasarkan penanda batas (misalnya |
Python uses built-in
astextraction.JavaScript/TypeScript/Go/Java use
tree-sitterfor structural chunk extraction.If
tree-sitterruntime is unavailable at execution time, the chunker falls back to a regex-based structural parser for those languages.
๐งช Testing
Install dev dependencies:
pip install -r requirements-dev.txtQuick Test
Run all tests:
./scripts/run_all_tests.shOr run individual test suites:
# Unit tests (pytest)
pytest -q
# Integration tests
python scripts/test_mcp_integration.py
# Scenario tests
python scripts/test_scenarios.pyTest Coverage
Current Status: โ 54/56 tests passing (96.4% success rate)
Unit Tests: 36 passed, 2 skipped
Integration Tests: 3 passed
Scenario Tests: 15 passed
See TEST_REPORT.md for detailed test results and coverage analysis.
MCP Server Testing
Test the MCP server integration:
# Unit tests
pytest tests/test_mcp_server.py -v
# Integration test
python scripts/test_mcp_integration.py
# Visual testing with MCP Inspector
npx @modelcontextprotocol/inspector python -m agentrag.mcp_serverSee MCP_TESTING.md for comprehensive testing guide and MCP_QUICK_REF.md for quick reference.
๐ Documentation
Vector Dimensions Explained - Memahami dimensi vektor dan embedding models
MCP Server Guide - Complete MCP server documentation
MCP Quick Reference - Quick reference for MCP tools
MCP Testing Guide - Comprehensive testing guide
MCP Inspector Guide - Visual testing with MCP Inspector
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
๐ License
This project is licensed under the MIT License.
๐ Acknowledgments
Qdrant - Vector database
FastEmbed - Fast embedding models
Tree-sitter - Code parsing
Model Context Protocol - AI agent integration
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogโฆ
Related MCP Connectors
Cloud or self-hosted knowledge for AI agents: hybrid search, reranking, GraphRAG, scoped MCP tools.
Persistent memory, knowledge graph, task management and more for AI agents via MCP.
Your company's tools, memory and Automations for ChatGPT, Claude or any MCP agent. Open source.
A second brain for your AI agent. Shared memory for your team's AI agents, plus public and private knowledge bases โ works with ChatGPT, Claude, Cursor and any MCP client.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceProvides a local-first, source-cited memory layer for AI agents, with MCP tools to search, read, explain sources, and propose/apply memory updates.60 npm14Apache 2.0
- AlicenseNot gradedqualityCmaintenanceEnables any MCP-capable LLM client to search self-hosted long-term memory over markdown and PDF documents, combining dense semantic vectors with BM25 keyword retrieval and optional cross-encoder reranking. Exposes a read-only tool surface for querying incidents, runbooks, and other knowledge-base content, while writes happen out-of-band through ingestion jobs or a token-gated internal API.2MIT
- FlicenseNot gradedqualityAmaintenanceEnables AI agents to query a local, hybrid-searchable second brain over scattered notes, documents, and chat logs with section-level citations. It exposes retrieval tools, resources, and prompts through MCP so hosts like Claude Desktop, Cursor, and Cline can use the indexed knowledge.-
- FlicenseNot gradedqualityAmaintenanceEnables AI agents and MCP hosts to search and ask questions across a local hybrid-retrieval index of scattered notes, documents, PDFs, and chat logs, returning section-level citations and agent-usable tools, resources, and prompts.-