astra-knowledge-base-mcp
It provides an MCP server for managing multi-tenant knowledge bases with hybrid full-text/vector search and SAG relational reasoning, backed by PostgreSQL/pgvector.
Knowledge base management: create, delete, list, and enable/disable KBs for search visibility.
Content ingestion: add text with automatic chunking (recursive/heading/semantic) and embedding via any OpenAI-compatible endpoint; import PDF/DOCX/PPTX/TXT/MD files; import/export JSONL chunks.
Search: run hybrid (default), FTS, vector, sag_fast, or sag_precise searches, optionally restricted to specific KBs.
Chunk operations: list chunks with pagination, update (replace/append), and delete individual chunks.
SAG indexing: extract events and entities from unprocessed chunks for relational retrieval.
Insights & ops: view KB statistics, track chunk changes over time, and query mgmt tables (services, health_log, api_keys).
Provides a persistent, searchable knowledge base using PostgreSQL with tsvector full-text search and optional pgvector for embeddings.
Provides a persistent, searchable knowledge base using SQLite with FTS5 for full-text search and automatic content chunking.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@astra-knowledge-base-mcp search my knowledge bases for 'API authentication'"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
astra-knowledge-base-mcp
MCP (Model Context Protocol) server for managing and searching multi-tenant knowledge bases.
Part of Astra AI Agent Infrastructure
Overview
Astra Knowledge Base MCP provides AI agents with persistent, searchable knowledge bases backed by PostgreSQL 16+ with pgvector — hybrid full-text and vector search, plus SAG (SQL-Retrieval Augmented Generation) for relational reasoning across chunks.
Each knowledge base is an isolated namespace. Content is auto-chunked on ingestion (recursive, heading-anchor, or semantic splitting), embedded via any OpenAI-compatible endpoint, and indexed for three complimentary retrieval paths.
Related MCP server: server-memory
Prerequisites
Python 3.11+
uv — Python package manager (
pip install uv)PostgreSQL 16+ with pgvector — installation guide: pgvector.org
Setup
1. Configure PostgreSQL
Create the database and enable pgvector:
CREATE DATABASE astra_kb;
\c astra_kb
CREATE EXTENSION IF NOT EXISTS vector;2. Install dependencies
uv sync3. Configure environment
# Embedding endpoint (any OpenAI-compatible API; a local AI Gate works too)
export ASTRA_EMBED_BASE_URL=https://api.siliconflow.cn/v1
export ASTRA_EMBED_API_KEY=sk-...
export ASTRA_EMBED_MODEL=embedding
export ASTRA_EMBED_DIM=1024
# Optional: LLM endpoint for SAG extraction
export ASTRA_LLM_BASE_URL=https://api.siliconflow.cn/v1
export ASTRA_LLM_API_KEY=sk-...
export ASTRA_LLM_MODEL=auto/best-free
# PostgreSQL connection
export ASTRA_KB_PG_DSN=dbname=astra_kb user=postgres host=/run/postgresql4. Start
uv run server.pyConfiguration
Variable | Default | Description |
|
| Backend — PostgreSQL only |
|
| PostgreSQL connection string |
| — (required) | OpenAI-compatible embedding endpoint |
| — | Embedding API key (optional for local models) |
|
| Embedding model ID or combo name (resolve to the member model server-side) |
|
| Embedding vector dimension |
| — (required for SAG) | LLM endpoint for event/entity extraction |
| — | LLM API key |
|
| LLM model for extraction |
Provider-agnostic by default. Both
ASTRA_EMBED_BASE_URLandASTRA_LLM_BASE_URLaccept any OpenAI-compatible endpoint — a local AI Gate or a hosted provider. When a base URL is set, an API key is only needed for non-local endpoints. If both are empty the server starts in a degraded mode (keyword-only retrieval, no embedding).
No hardcoded provider defaults.
ASTRA_EMBED_BASE_URLandASTRA_LLM_BASE_URLmust be set explicitly. The oldSILICONFLOW_API_KEYfallback has been removed — useASTRA_EMBED_API_KEYorASTRA_LLM_API_KEYinstead.
Usage
MCP Tools
Tool | Description |
| List all knowledge bases with enable/disable status |
| Create a new empty knowledge base |
| Permanently delete a knowledge base and all its content |
| Toggle KB visibility in search |
| Add text content (auto-chunked + embedded) |
| Update a chunk (replace or append mode) |
| Delete a single chunk by ID |
| List chunks in a knowledge base (paginated) |
| Search across KBs — modes: |
| Extract events and entities from unprocessed chunks (SAG indexing) |
| Import a file (PDF, DOCX, PPTX, TXT, MD) via MarkItDown |
| Import chunks from a JSONL file |
| Export all chunks to JSONL |
| Knowledge base statistics and overview |
| Track chunk changes over time |
| List mgmt schema tables (services, health_log, api_keys) |
| Query operational data from mgmt tables |
Registering in Hermes Agent
Add to your Hermes config.yaml:
mcp_servers:
astra-knowledge-base:
command: /path/to/astra-knowledge-base-mcp/scripts/run.sh
enabled: trueThen restart Hermes Agent. The tools become available automatically.
Architecture
AI Agent (Hermes)
│ MCP stdio protocol
▼
astra-knowledge-base-mcp (Python, uv run)
│
├── PostgreSQL (psycopg2 + pgvector) → astra_kb
│ ├── kb_registry ← KB metadata & status
│ ├── kb_*.chunks ← Per-KB schema (tsvector FTS + vector(1024))
│ ├── kb_*.events ← SAG event index (vector(1024))
│ ├── kb_*.entities ← SAG entity index (vector(1024))
│ └── mgmt ← Operational data (services, health_log, api_keys)
│
└── Embedding cache (PostgreSQL) → embed_cache tableThree complimentary retrieval paths:
FTS — keyword search via PostgreSQL
tsvector/ts_rankVector — semantic search via cosine similarity on
pgvectorindexesSAG — SQL-Retrieval Augmented Generation: event-entity extraction + query-time hyperedge expansion for multi-hop reasoning across chunks
Agent Guide
See AGENTS.md for AI-agent-oriented documentation (entry points, workflows, Hermes integration).
Related
astra-aiagent-infra — ecosystem portal
Hermes Agent — AI agent framework
MCP — Model Context Protocol
Dependencies
PostgreSQL 16+ with pgvector — primary data store
psycopg2-binary — PostgreSQL driver
MarkItDown — file import (PDF, DOCX, PPTX)
Retrieval Strategy
We implement SAG (SQL-Retrieval Augmented Generation) — an original retrieval architecture that replaces both traditional RAG and GraphRAG. SAG uses event-entity indexing and query-time dynamic hyperedges to deliver both semantic retrieval and relational reasoning in a single pipeline.
Reference:
SAG paper: arxiv 2606.15971 — Yuchao Wu et al., Zleap AI (MIT)
Reference implementation: github.com/Zleap-AI/SAG — MIT License
Our implementation follows the SAG algorithm directly on our PostgreSQL/pgvector infrastructure, without wrapping the reference package.
License
MIT — see LICENSE.
中文版
概述
Astra Knowledge Base MCP 为 AI Agent 提供基于 PostgreSQL 16+ + pgvector 的持久化、可搜索知识库——支持混合全文/向量检索和 SAG(SQL 检索增强生成)关联推理。
每个知识库是隔离的命名空间,内容引入时自动分块(递归、heading-anchor 或语义切分),通过任意 OpenAI 兼容的端点进行向量化,并建立三种互补的检索路径。
Minimal setup:
export ASTRA_EMBED_BASE_URL=https://api.siliconflow.cn/v1
export ASTRA_EMBED_API_KEY=sk-...
uv run server.pyAvailable Tools
13 toolskb_addC
Add text content to a knowledge base (auto-chunked)
Inputs: kb (required), content (required), tags, title, +1 more.
kb_createC
Create a new empty knowledge base
Inputs: name (required), description.
kb_deleteA
Permanently delete a knowledge base and all its content
Inputs: name (required).
kb_delete_chunkB
Delete a single chunk by ID
Inputs: kb (required), chunk_id (required).
kb_disableA
Disable a knowledge base so it is excluded from search
Inputs: name (required).
kb_enableB
Enable a knowledge base so it appears in search results
Inputs: name (required).
kb_extractC
Extract events and entities from unprocessed chunks (SAG indexing). Reference: arXiv 2606.15971
Inputs: kb (required).
kb_listA
List all knowledge bases with their enable/disable status
Inputs: no named parameters.
kb_list_chunksB
List chunks in a knowledge base (paginated)
Inputs: kb (required), limit, offset.
kb_searchA
Search across enabled (or specified) knowledge bases. Default: hybrid (FTS + vector)
Inputs: query (required), limit, kb_names, search_mode.
kb_updateA
Update a chunk. Unset fields keep current value. mode='append' appends to content.
Inputs: kb (required), chunk_id (required), mode, tags, +5 more.
mgmt_list_tablesA
List available operational tables (services, health_log, api_keys, ...)
Inputs: no named parameters.
mgmt_queryC
Query operational data from mgmt schema tables
Inputs: table (required), limit, filter_col, filter_val.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 13 tools
All tools have distinct purposes: KB management (list, create, delete, enable, disable), content operations (add, search, extract, list_chunks, update, delete_chunk), and admin queries (mgmt_list_tables, mgmt_query). No overlapping functionality.
All tool names follow a consistent 'prefix_verb_noun' pattern using snake_case. Prefixes 'kb_' and 'mgmt_' clearly separate knowledge base and management operations. Verbs are descriptive and uniformly styled.
13 tools is well-scoped for a knowledge base MCP server. It provides comprehensive operations without being excessive, covering CRUD for KBs and chunks, search, extraction, and administrative functions.
The tool surface covers most essential operations: KB lifecycle (create, delete, list, enable/disable), chunk management (add, list, update, delete), search, and extraction. Minor gaps include lack of a single-KB retrieval tool and no update for KB metadata, but core workflows are supported.
Maintenance
Related MCP Connectors
Personal knowledge base MCP server with semantic search, auto-categorization, metadata extraction
Knowledge base MCP for AI agents on iknow.dev. Search, read, and maintain via OAuth.
Self-hosted AI workspace: semantic RAG document search, long-term memory, and AI chat via MCP.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceMCP server providing persistent memory management for AI agents using SQLite and FTS5, enabling storage, full-text search, and recall of memories with namespace isolation.1MIT
- AlicenseAqualityCmaintenanceA local-first MCP server for durable agent memory using SQLite and FTS5, enabling knowledge graph storage, search, and recall for AI agents.201MIT
- AlicenseAqualityDmaintenanceA SQLite-backed MCP memory server providing persistent memory storage with full-text search and knowledge graph capabilities for AI assistants.1247 npmMIT
- AlicenseAqualityBmaintenanceMCP server for local knowledge management with Markdown and PDF indexing using SQLite FTS5.59 npm2MIT