MCP Server (RAG)
The RAG server exposes an MCP (Model Context Protocol) endpoint for AI agents to search knowledge bases programmatically.
Endpoint
Supports both Accept: application/json and Accept: text/event-stream. Stateless — no session management required.
Authentication
Two token types are accepted via Authorization: Bearer:
Token Type | Format | Description |
|---|---|---|
JWT | Standard JWT | User session token (from login) |
Personal API Key |
| Long-lived API key (Settings → API Keys) |
The server distinguishes them by prefix — tokens starting with ragty- go through the API key resolution path, others are decoded as JWT.
Available Tools
list_datasets
Returns all datasets accessible to the authenticated user/tenant. Call this first to discover available knowledge bases and get dataset IDs for scoped search.
Parameters: None
Response:
search_datasets
Searches document chunks using hybrid retrieval (dense embeddings + sparse BM25). Returns ranked text chunks with metadata — not whole documents.
Parameters:
Name | Type | Required | Description |
|---|---|---|---|
| string | Yes | The search query text |
| string[] | No | Dataset IDs (NOT document IDs) from |
| integer | No | Max results to return (default: 20, max: 100) |
| boolean | No | Apply cross-encoder reranking for better relevance (default: false, slower) |
Response:
Client Configuration
Codex / Generic MCP Client
Create or edit ~/.codex/config.json:
Claude Desktop
Edit ~/Library/Application Support/Claude/claude_desktop_config.json:
VS Code (Copilot MCP)
Add to .vscode/mcp.json:
Obtaining an API Key
Log in to the frontend at http://localhost:3000
Navigate to Settings → API Keys
Click Create Key → choose "Personal" or "Dataset-scoped"
Copy the
ragty-...token (shown once only)
Or via CLI: