RAGent - RAG System Builder for Markdown Documents
RAGent is a CLI tool for building a RAG (Retrieval-Augmented Generation) system from markdown documents using hybrid search capabilities (BM25 + vector search) with Amazon S3 Vectors and OpenSearch.
Table of Contents
- Features
- Slack Search Integration
- Embedding-Agnostic RAG
- Environment Variable Setup Guide
- Architecture Overview
- Prerequisites
- Required Environment Variables
- Installation
- Releases
- Commands
- Development
- Typical Workflow
- Troubleshooting
- AWS Secrets Manager Integration
- OpenSearch RAG Configuration
- Automated Setup (setup.sh)
- License
- MCP Server Integration
- Contributing
Features
- Vectorization: Convert source files (markdown, CSV, and PDF) from local directories, S3, or GitHub repositories to embeddings using Amazon Bedrock
- GitHub Data Source: Clone GitHub repositories and vectorize their markdown/CSV files with auto-generated metadata
- S3 Vector Integration: Store generated vectors in Amazon S3 Vectors
- Hybrid Search: Combined BM25 + vector search using OpenSearch
- Slack Search Integration: Blend document results with Slack conversations via an iterative enrichment pipeline
- Semantic Search: Semantic similarity search using S3 Vector Index
- Interactive RAG Chat: Chat interface with context-aware responses
- Vector Management: List vectors stored in S3
- Embedding-Agnostic RAG: Optional search path that answers directly from Slack without requiring pre-built vectors
- MCP Server: Model Context Protocol server for Claude Desktop integration
- OIDC Authentication: OpenID Connect authentication with multiple providers
- IP-based Security: IP address-based access control with configurable bypass ranges and audit logging
- Dual Transport: HTTP and Server-Sent Events (SSE) transport support
- AWS Secrets Manager Integration: Automatic secret injection as environment variable fallback
Slack Search Integration
Slack search extends every retrieval workflow by streaming recent conversations, threads, and channel timelines directly from Slack’s Web API. When SLACK_SEARCH_ENABLED=true, the following behavior is enabled automatically:
queryexposes--enable-slack-searchflag to opt in per request.chatsurfaces Slack context in addition to documents without requiring extra flags.slack-botresponds with combined document + Slack answers inside Block Kit messages.mcp-serveraddsenable_slack_searchparameter to thehybrid_searchtool.
Each Slack lookup performs iterative query refinement, merges timeline context from threads, and runs a sufficiency check before the final answer is generated. Results include permalinks so operators can pivot back to the original conversation instantly.
Slack URL Reference
You can include Slack message URLs directly in your queries. RAGent automatically detects and fetches the referenced messages, including thread replies, making them available as context for your question. This works across all commands (query, chat, slack-bot, mcp-server) regardless of whether SLACK_SEARCH_ENABLED is set.
bash# Fetch and analyze a specific Slack conversation RAGent query -q "Summarize this discussion: https://your-workspace.slack.com/archives/C12345678/p1234567890123456" # Reference multiple Slack messages RAGent chat > Compare these two threads: https://slack.com/.../p111 and https://slack.com/.../p222
Quick example:
bash# Search across documents and Slack in one command RAGent query -q "incident timeline" --enable-slack-search
Embedding-Agnostic RAG
Slack search is intentionally embedding-agnostic: the system fetches live messages at query time instead of relying on pre-generated vectors. This provides several benefits:
- Operational cost savings: no additional vector storage or nightly re-indexing jobs are required for Slack data.
- Real-time awareness: answers incorporate messages posted seconds ago, keeping incident timelines and release notes fresh.
- Time-series preservation: the pipeline keeps message order and thread structure so analysts can replay discussions accurately.
- Seamless fallbacks: when Slack returns no hits the document-only hybrid search continues without interruption.
Slack-only output is still fused with document references, giving operators a single consolidated view while staying within compliance rules.
Environment Variable Setup Guide
RAGent integrates many services, and the required environment variables differ depending on your choices. This section provides visual flowcharts for the two main workflows: vectorization (data ingestion) and output (search & usage).
Vectorization Flow (vectorize command)
Follow this flowchart to determine which environment variables are needed for vectorization.
Legend:
*= required (error if unset),default: xxx= has a default value. IAM credentials and Bearer Token (AWS_BEARER_TOKEN_BEDROCK) are mutually exclusive.
Output Flow (Search & Usage Commands)
The required environment variables depend on which command you use and which search mode you choose.
Architecture Overview
The diagram below highlights how document and Slack pipelines converge before the answer is generated.
Detailed Architecture Diagrams
Command Overview
RAGent provides five main commands, each serving a specific purpose in the RAG workflow:
Hybrid Search Flow
The hybrid search engine combines BM25 keyword matching with vector similarity search:
Slack Bot Processing
Slack Bot listens for mentions and responds with RAG-powered answers:
MCP Server Integration
MCP Server exposes RAGent's hybrid search to Claude Desktop and other MCP-compatible tools:
Vectorization Pipeline
The vectorize command processes source documents (Markdown, CSV, and S3 objects) and stores them in dual backends:
Prerequisites
Prepare Source Documents
Before using RAGent, you need to prepare source documents in a source/ directory. These documents should contain the content you want to make searchable through the RAG system.
Supported file types:
- Markdown (.md, .markdown): Each file becomes one document
- CSV (.csv): Each row becomes one document (header row required)
- PDF (.pdf): Each page becomes one document (requires
OCR_PROVIDER=bedrockorOCR_PROVIDER=gemini)
bash# Create source directory mkdir source # Place your files in this directory cp /path/to/your/documents/*.md source/ cp /path/to/your/data/*.csv source/
For CSV files, you can optionally provide a configuration file to specify column mappings:
bash# Copy example configuration cp csv-config.yaml.example csv-config.yaml # Run with CSV configuration RAGent vectorize --csv-config csv-config.yaml
CSV Configuration Options
The csv-config.yaml supports the following options:
header_row (Header Row Position):
Use this option when your CSV file has metadata or summary rows before the actual header row.
When header_row is specified, that row is used as the column headers, and all preceding rows are skipped.
yamlcsv: files: - pattern: "sample.csv" header_row: 7 # Row 7 is the header (1-indexed) # Rows 1-6 are skipped, data starts from row 8 content: columns: ["task", "category"] metadata: title: "task" category: "category"
- If
header_rowis not specified, the default is1(first row is the header) - Row numbers are 1-indexed
For exporting notes from Kibela, use the separate export tool available in the export/ directory.
Required Environment Variables
Create a .env file in the project root and configure the following environment variables:
env# AWS Configuration AWS_REGION=your_aws_region AWS_ACCESS_KEY_ID=your_access_key AWS_SECRET_ACCESS_KEY=your_secret_key # S3 Vector Configuration S3_VECTOR_INDEX_NAME=your_vector_index_name S3_BUCKET_NAME=your_s3_bucket_name S3_VECTOR_REGION=us-east-1 # AWS region for S3 Vector bucket S3_SOURCE_REGION=ap-northeast-1 # AWS region for source S3 bucket (--enable-s3) # Vector DB Backend Selection VECTOR_DB_BACKEND=s3 # Backend type: "s3" (Amazon S3 Vectors) or "sqlite" (local sqlite-vec) (default: s3) SQLITE_VEC_DB_PATH=~/.ragent/vectors.db # Path to sqlite-vec DB file (used when VECTOR_DB_BACKEND=sqlite) # OpenSearch Configuration (for Hybrid RAG) OPENSEARCH_ENDPOINT=your_opensearch_endpoint OPENSEARCH_INDEX=your_opensearch_index OPENSEARCH_REGION=us-east-1 # default # GitHub Configuration (optional) GITHUB_TOKEN=ghp_your_github_token # Required for private repositories # Chat Configuration CHAT_MODEL=anthropic.claude-3-5-sonnet-20240620-v1:0 # default EXCLUDE_CATEGORIES=Personal,Daily # Categories to exclude from search # MCP Server Configuration MCP_SERVER_HOST=localhost MCP_SERVER_PORT=8080 MCP_IP_AUTH_ENABLED=true MCP_ALLOWED_IPS=127.0.0.1,::1 # Comma-separated list # MCP Bypass Configuration (optional) MCP_BYPASS_IP_RANGE=10.0.0.0/8,172.16.0.0/12 # Comma-separated CIDR ranges MCP_BYPASS_VERBOSE_LOG=false MCP_BYPASS_AUDIT_LOG=true MCP_TRUSTED_PROXIES=192.168.1.1,10.0.0.1 # Trusted proxy IPs for X-Forwarded-For # OIDC Authentication (optional) OIDC_ISSUER=https://accounts.google.com # Your OIDC provider URL OIDC_CLIENT_ID=your_client_id OIDC_CLIENT_SECRET=your_client_secret # Slack Bot Configuration SLACK_BOT_TOKEN=xoxb-your-bot-token # SLACK_USER_TOKEN is optional but covers more paths. # - When set (xoxp): all entry points (slack-bot / query CLI / mcp-server) # use the legacy `search.messages` API and can reach private channels, # DMs and MPIMs that the user has access to. # - When unset: only the slack-bot mention path can search Slack. It calls # the Real-time Search API (`assistant.search.context`) on the bot token # plus the per-event `action_token` and reaches public channels the bot # has not joined (requires the `search:read.public` bot scope). CLI/MCP # cannot obtain an `action_token` and therefore skip Slack search. SLACK_USER_TOKEN= SLACK_RESPONSE_TIMEOUT=5s SLACK_MAX_RESULTS=5 SLACK_ENABLE_THREADING=false SLACK_THREAD_CONTEXT_ENABLED=true SLACK_THREAD_CONTEXT_MAX_MESSAGES=10 # Slack Search Configuration SLACK_SEARCH_ENABLED=false # Enable Slack search pipeline (set true to activate) SLACK_SEARCH_MAX_RESULTS=20 # Max Slack messages retrieved per query (1-100) SLACK_SEARCH_MAX_RETRIES=5 # Retry count for Slack API rate limits (0-10) SLACK_SEARCH_CONTEXT_WINDOW_MINUTES=30 # Time window (minutes) of surrounding message context SLACK_SEARCH_MAX_ITERATIONS=5 # Iterative refinements performed when answers insufficient SLACK_SEARCH_MAX_CONTEXT_MESSAGES=100 # Max messages assembled into enriched context SLACK_SEARCH_TIMEOUT_SECONDS=5 # Slack API request timeout in seconds (1-60) # OpenTelemetry Configuration (optional) OTEL_ENABLED=false OTEL_SERVICE_NAME=ragent OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf OTEL_RESOURCE_ATTRIBUTES=service.namespace=ragent,environment=dev OTEL_TRACES_SAMPLER=always_on OTEL_TRACES_SAMPLER_ARG=1.0 # OCR Configuration (for PDF vectorization) OCR_PROVIDER=bedrock # OCR provider ("bedrock" or "gemini"; omit to skip PDFs) OCR_MODEL=anthropic.claude-3-5-sonnet-20241022-v2:0 # Model for OCR (Bedrock model ID or Gemini model name) OCR_TIMEOUT=120s # OCR request timeout (default: 120s) # Embedding Configuration EMBEDDING_PROVIDER=bedrock # Embedding provider ("bedrock" [default] or "gemini") EMBEDDING_MODEL= # Embedding model ID (optional; defaults to provider's default) EMBEDDING_DIMENSION= # Output vector dimension (optional; overrides model default) # Gemini Configuration (OCR_PROVIDER=gemini and/or EMBEDDING_PROVIDER=gemini) # Option 1: API key authentication GEMINI_API_KEY=your_gemini_api_key # Google AI Studio API key # Option 2: Application Default Credentials (GOOGLE_APPLICATION_CREDENTIALS) GEMINI_GCP_PROJECT=your_gcp_project_id # GCP project ID for Vertex AI GEMINI_GCP_LOCATION=us-central1 # GCP region for Vertex AI (default: us-central1) # AWS Secrets Manager Configuration (optional) SECRET_MANAGER_SECRET_ID=ragent/app # Secret ID in AWS Secrets Manager (omit to disable) SECRET_MANAGER_REGION=us-east-1 # AWS region for Secrets Manager (default: us-east-1)
Gemini Embedding Configuration
To use Gemini for embeddings instead of Amazon Bedrock, set EMBEDDING_PROVIDER=gemini. Two authentication methods are supported:
bash# Use Gemini for embeddings (with API Key) export EMBEDDING_PROVIDER=gemini export EMBEDDING_MODEL=text-embedding-004 export GEMINI_API_KEY=your-api-key # Use Gemini for embeddings (with Vertex AI) export EMBEDDING_PROVIDER=gemini export GEMINI_GCP_PROJECT=your-project export GEMINI_GCP_LOCATION=us-central1
When EMBEDDING_MODEL is omitted, Gemini defaults to text-embedding-004 (768 dimensions). Bedrock defaults to amazon.titan-embed-text-v2:0 (1024 dimensions).
Models such as gemini-embedding-2-preview support configurable output dimensions. Set EMBEDDING_DIMENSION to match your vector store index — for example EMBEDDING_DIMENSION=1024 for an OpenSearch index created with 1024 dimensions. When omitted, the model's default dimension is used.
Slack search requires SLACK_SEARCH_ENABLED=true and a valid SLACK_BOT_TOKEN. SLACK_USER_TOKEN (xoxp-) is optional but determines which entry points can search Slack:
- With
SLACK_USER_TOKEN— every entry point (slack-bot,queryCLI,mcp-server) calls the legacysearch.messagesAPI with the user-tokensearch:readscope. Results cover public channels, private channels the user belongs to, plus DMs / MPIMs. - Without
SLACK_USER_TOKEN— only theslack-botmention path can search Slack. It switches to the Real-time Search API (assistant.search.context) using the bot token together with the short-livedaction_tokencarried byapp_mention/ DMmessageevents. The bot needs the granularsearch:read.publicscope and reaches public channels even ones the bot has not been invited to. ThequeryCLI andmcp-servercannot obtain anaction_token, so they refuse to run Slack search in this mode (other RAGent features continue to work).
The search-specific knobs let you tune throughput and cost per workspace without touching the core document pipeline. See docs/slack-user-token.md for the full rationale of when a user token is required.
MCP Bypass Configuration (Optional)
MCP_BYPASS_IP_RANGE: Comma-separated CIDR ranges that skip authentication for trusted networks.MCP_BYPASS_VERBOSE_LOG: Enables detailed logging for bypass decisions to aid troubleshooting.MCP_BYPASS_AUDIT_LOG: Emits JSON audit entries for bypassed requests (enabled by default for compliance).MCP_TRUSTED_PROXIES: Comma-separated list of proxy IPs whoseX-Forwarded-Forheaders are trusted during bypass checks.
AWS Secrets Manager Integration
RAGent supports AWS Secrets Manager as a fallback for environment variables. When configured, secrets stored in Secrets Manager are automatically injected as environment variables at startup — but only for keys that are not already set. This means existing environment variables always take priority and are never overwritten.
How It Works
- On startup, RAGent checks for the
SECRET_MANAGER_SECRET_IDenvironment variable. - If set, it fetches the secret from AWS Secrets Manager (the secret must be stored as a JSON key-value pair).
- For each key in the JSON, if the corresponding environment variable is not already set, the value is injected.
- If the environment variable is already set (via
.env, shell export, etc.), the Secrets Manager value is ignored.
This design allows you to:
- Store sensitive credentials (API keys, tokens) centrally in Secrets Manager
- Override any secret locally by setting the environment variable directly
- Use the same secret across multiple deployment environments
Configuration
| Environment Variable | Description | Default |
|---|---|---|
SECRET_MANAGER_SECRET_ID | Secret ID or ARN in AWS Secrets Manager | (not set — feature disabled) |
SECRET_MANAGER_REGION | AWS region for Secrets Manager | us-east-1 |
Registering Secrets
Store your secrets as a JSON object in AWS Secrets Manager. Each key should match the environment variable name used by RAGent.
Using AWS CLI:
bash# Create a new secret aws secretsmanager create-secret \ --name "ragent/app" \ --description "RAGent application secrets" \ --secret-string '{ "SLACK_BOT_TOKEN": "xoxb-your-bot-token", "SLACK_USER_TOKEN": "xoxp-your-user-token", "OIDC_CLIENT_SECRET": "your-oidc-secret", "GITHUB_TOKEN": "ghp_your-github-token", "GEMINI_API_KEY": "your-gemini-api-key" }' \ --region us-east-1 # Update an existing secret aws secretsmanager put-secret-value \ --secret-id "ragent/app" \ --secret-string '{ "SLACK_BOT_TOKEN": "xoxb-new-token", "SLACK_USER_TOKEN": "xoxp-new-token", "OIDC_CLIENT_SECRET": "new-secret", "GITHUB_TOKEN": "ghp_new-token", "GEMINI_API_KEY": "new-api-key" }' \ --region us-east-1
Using AWS Console:
- Open the AWS Secrets Manager Console
- Click Store a new secret
- Select Other type of secret
- Choose Plaintext and enter a JSON object with key-value pairs
- Name the secret (e.g.,
ragent/app) and complete the wizard
IAM Permissions
The IAM role or user running RAGent needs the following permissions:
json{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "secretsmanager:GetSecretValue", "secretsmanager:DescribeSecret" ], "Resource": "arn:aws:secretsmanager:<region>:<account-id>:secret:ragent/app-*" } ] }
Usage Example
bash# Set only the Secrets Manager config — all other secrets are fetched automatically export SECRET_MANAGER_SECRET_ID=ragent/app export SECRET_MANAGER_REGION=us-east-1 # Non-secret config still set via environment / .env export OPENSEARCH_ENDPOINT=https://your-opensearch-endpoint export OPENSEARCH_INDEX=your-index # Start RAGent — SLACK_BOT_TOKEN, GITHUB_TOKEN, etc. are loaded from Secrets Manager RAGent slack-bot
bash# Override a specific secret locally (takes priority over Secrets Manager) export SECRET_MANAGER_SECRET_ID=ragent/app export SLACK_BOT_TOKEN=<REDACTED> # This value wins RAGent slack-bot # Uses the local SLACK_BOT_TOKEN, other secrets from SM
Note: Only string values in the JSON are injected. Non-string values (objects, arrays, numbers, booleans, null) are silently skipped.
MCP Client Config from Secrets Manager
--mcp-config accepts either a local JSONC file path or secretsmanager://SECRET_ID. For Secrets Manager, store the raw contents of mcp-config.jsonc as the secret string, not as the environment-variable JSON map used by SECRET_MANAGER_SECRET_ID.
bashaws secretsmanager create-secret \ --name ragent/mcp-config \ --secret-string file://mcp-config.jsonc \ --region us-east-1 RAGent query "your question" --mcp-config secretsmanager://ragent/mcp-config
This uses SECRET_MANAGER_REGION for the AWS region when set, otherwise us-east-1, and requires secretsmanager:GetSecretValue on the MCP config secret.
OpenTelemetry Observability
RAGent exposes distributed traces and usage metrics through the OpenTelemetry (OTel) Go SDK. Traces are emitted for Slack Bot message handling, MCP tool calls, and the shared hybrid search service, while counters and histograms capture request rates, error rates, and response times.
Enable OTel
Set the following environment variables (see .env.example for defaults):
OTEL_ENABLED:trueto enable tracing and metrics (defaults tofalse).OTEL_SERVICE_NAME: Logical service name (ragentby default).OTEL_RESOURCE_ATTRIBUTES: Comma-separatedkey=valuepairs such asservice.namespace=ragent,environment=dev.OTEL_EXPORTER_OTLP_ENDPOINT: OTLP endpoint URL (including scheme).OTEL_EXPORTER_OTLP_PROTOCOL:http/protobuf(default) orgrpc.OTEL_TRACES_SAMPLER,OTEL_TRACES_SAMPLER_ARG: Configure sampling strategy (always_on,traceidratio, etc.).
When OTEL_ENABLED=false, RAGent registers no-op providers and carries no runtime overhead.
Example: Jaeger (local development)
bash# 1. Start Jaeger all-in-one docker run --rm -it -p 4318:4318 -p 16686:16686 jaegertracing/all-in-one:1.58 # 2. Enable OTel before running RAGent export OTEL_ENABLED=true export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf # 3. Run the Slack bot (or any other command) go run main.go slack-bot # Visit http://localhost:16686 to explore spans
Example: Prometheus via OpenTelemetry Collector
Use the OTel Collector to convert OTLP metrics into Prometheus format:
yaml# collector.yaml receivers: otlp: protocols: http: endpoint: 0.0.0.0:4318 exporters: prometheus: endpoint: 0.0.0.0:9464 service: pipelines: metrics: receivers: [otlp] exporters: [prometheus]
bashotelcol --config collector.yaml export OTEL_ENABLED=true export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 go run main.go mcp-server # Scrape metrics at http://localhost:9464/metrics
Example: AWS X-Ray with ADOT Collector
bash# 1. Run the AWS Distro for OpenTelemetry collector docker run --rm -it -p 4317:4317 public.ecr.aws/aws-observability/aws-otel-collector:latest # 2. Configure RAGent to send spans over gRPC export OTEL_ENABLED=true export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317 export OTEL_EXPORTER_OTLP_PROTOCOL=grpc export OTEL_TRACES_SAMPLER=traceidratio export OTEL_TRACES_SAMPLER_ARG=0.2
Metrics & Span Names
- Spans
slackbot.process_messagemcpserver.hybrid_searchsearch.hybrid
- Metrics
ragent.slack.requests.total,ragent.slack.errors.total,ragent.slack.response_timeragent.mcp.requests.total,ragent.mcp.errors.total,ragent.mcp.response_time
Attach additional attributes such as channel type, authentication method, tool name, and result totals for fine-grained analysis.
Grafana Dashboard
RAGent includes a pre-configured Grafana dashboard template for visualizing OpenTelemetry metrics. The dashboard provides comprehensive monitoring of Slack Bot and MCP Server operations.

Dashboard Panels:
- Slack Metrics
- Slack Bot Requests (time series)
- Slack Response Latency (histogram)
- Slack Errors Rate (gauge)
- MCP Metrics
- MCP Requests (time series)
- MCP Response Time (histogram)
- MCP Errors Rate (gauge)
Setup Instructions:
-
Enable OpenTelemetry in RAGent:
bashexport OTEL_ENABLED=true export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 -
Configure OTel Collector to export metrics to Prometheus (see example above)
-
Import the dashboard template into Grafana:
bash# Using Grafana API curl -X POST http://localhost:3000/api/dashboards/import \ -H "Content-Type: application/json" \ -d @assets/grafana.json # Or manually import via Grafana UI # Dashboard > Import > Upload JSON file > Select assets/grafana.json -
Configure Prometheus data source in Grafana pointing to your metrics endpoint
The dashboard will automatically start displaying metrics once RAGent begins processing requests.
Installation
Prerequisites
- Go 1.25.0 or higher
- direnv (recommended)
Build
bash# Clone the repository git clone https://github.com/ca-srg/ragent.git cd RAGent # Install dependencies go mod download # Build go build -o RAGent # Add executable to PATH (optional) mv RAGent /usr/local/bin/
Releases
Prebuilt binaries are published on GitHub Releases for Linux (amd64, arm64).
- Releases page: https://github.com/ca-srg/ragent/releases
Create a Release (maintainers)
Use semantic versioning (MAJOR.MINOR.PATCH) and push a tag to trigger the pipeline:
bash# Example: v1.0.0 git tag v1.0.0 git push origin v1.0.0
This triggers the GitHub Actions workflow which builds archives via GoReleaser and publishes them to the release.
Download Binaries
From the Releases page, download the archive for your platform:
- Linux amd64:
ragent_<VERSION>_linux_amd64.tar.gz - Linux arm64:
ragent_<VERSION>_linux_arm64.tar.gz
Extract and place the binary on your PATH:
bashtar -xzf ragent_<VERSION>_linux_amd64.tar.gz sudo mv ragent /usr/local/bin/
Verify Checksums
Each release includes a SHA256 checksum file.
bash# Linux sha256sum -c checksums_<VERSION>.txt # macOS (if verifying from macOS) shasum -a 256 -c checksums_<VERSION>.txt
All entries should report OK. If a mismatch occurs, re-download the artifact.
Vector DB Backend Selection
RAGent supports two vector storage backends, selectable via the VECTOR_DB_BACKEND environment variable.
Amazon S3 Vectors (default, VECTOR_DB_BACKEND=s3)
envVECTOR_DB_BACKEND=s3 AWS_S3_VECTOR_BUCKET=your-bucket AWS_S3_VECTOR_INDEX=your-index S3_VECTOR_REGION=us-east-1
Suitable for production deployments and large-scale document sets on AWS infrastructure.
sqlite-vec (local, VECTOR_DB_BACKEND=sqlite)
envVECTOR_DB_BACKEND=sqlite SQLITE_VEC_DB_PATH=./vectors.db
Suitable for local development and small-to-medium deployments without AWS dependencies.
Limitations:
- Single writer (WAL mode is enabled automatically)
- Maximum 8,192 dimensions per embedding
- Vector similarity search always uses OpenSearch (sqlite-vec stores vectors only)
Example:
bash# Vectorize with sqlite-vec backend VECTOR_DB_BACKEND=sqlite SQLITE_VEC_DB_PATH=./vectors.db \ OPENSEARCH_ENDPOINT=https://... OPENSEARCH_INDEX=ragent \ RAGent vectorize # List stored vectors VECTOR_DB_BACKEND=sqlite SQLITE_VEC_DB_PATH=./vectors.db \ OPENSEARCH_ENDPOINT=https://... OPENSEARCH_INDEX=ragent \ RAGent list
Note: OpenSearch is required regardless of the vector backend selection.
Commands
1. vectorize - Vectorization and S3 Storage
Read source files (markdown and CSV), extract metadata, generate embeddings using Amazon Bedrock, and store them in Amazon S3 Vectors.
bashRAGent vectorize
Options:
-d, --directory: Directory containing source files to process (default:./source)--dry-run: Display processing details without making actual API calls-c, --concurrency: Number of concurrent processes (0 = use default value from config file)--csv-config: Path to CSV configuration YAML file (for column mapping)--enable-s3: Enable S3 source file fetching--s3-bucket: S3 bucket name for source files (required when--enable-s3is set)--s3-prefix: S3 prefix (directory) to scan (optional, defaults to bucket root)--s3-vector-region: AWS region for S3 Vector bucket (overrides S3_VECTOR_REGION, default: us-east-1)--s3-source-region: AWS region for source S3 bucket (overrides S3_SOURCE_REGION, default: us-east-1)--github-repos: Comma-separated list of GitHub repositories to clone and vectorize (format:owner/repo)--ocr-prompt-file: Path to custom OCR prompt file (content is appended to the base prompt, not replacing it)
S3 Source Examples:
bash# S3 only (with prefix) RAGent vectorize --enable-s3 --s3-bucket my-docs-bucket --s3-prefix source/ # S3 only (flat structure) RAGent vectorize --enable-s3 --s3-bucket my-docs-bucket # Local + S3 combined RAGent vectorize --directory ./local-docs --enable-s3 --s3-bucket my-docs-bucket --s3-prefix remote/ # Dry run with S3 source RAGent vectorize --enable-s3 --s3-bucket my-docs-bucket --dry-run
GitHub Source Examples:
bash# Clone and vectorize a single GitHub repository RAGent vectorize --github-repos "owner/repo" # Multiple repositories RAGent vectorize --github-repos "org/repo1,org/repo2" # Combined with local source RAGent vectorize --directory ./local-docs --github-repos "owner/repo" # Dry run with GitHub source RAGent vectorize --github-repos "owner/repo" --dry-run # Follow mode with GitHub repos (re-clones on each cycle) RAGent vectorize --follow --github-repos "owner/repo"
For private repositories, set the GITHUB_TOKEN environment variable.
Metadata is auto-generated from the repository structure: owner name as author, repository name as source, parent directory as category, and a GitHub URL as reference.
For detailed documentation on the GitHub data source feature, see doc/github.md.
Custom OCR Prompt:
When processing PDFs, you can provide a custom prompt file to give additional instructions to the OCR model. The custom prompt content is appended to the built-in base prompt — it does not replace it.
A template file ocr-prompt-template.md is included in the repository. Copy it to create your own prompt:
bash# Copy the template cp ocr-prompt-template.md ocr-prompt.md # Edit with your custom instructions vi ocr-prompt.md # Run vectorize with the custom OCR prompt RAGent vectorize --ocr-prompt-file ocr-prompt.md
Important: The base OCR prompt expects a JSON array as output. Do not include instructions that change the output format (e.g., adding markdown code fences or free-text explanations).
The custom prompt can also control the secret metadata field. For example, to mark 1-on-1 meeting documents as secret:
markdown## Additional Instructions If the document content is about a 1-on-1 meeting, set `secret: true`.
Features:
- Recursive scanning of markdown and CSV files
- Automatic metadata extraction
- CSV row expansion (each row becomes a document)
- Automatic column detection for CSV files (or explicit configuration)
- Embedding generation using Amazon Titan Text Embedding v2
- Safe storage to S3 Vectors
- High-speed processing through concurrency
- PDF page extraction via OCR (each page becomes a document, requires
OCR_PROVIDER=bedrockorOCR_PROVIDER=gemini)
2. query - Semantic Search
Execute semantic similarity search against S3 Vector Index.
bash# Basic search RAGent query -q "machine learning algorithms" # Search with detailed options RAGent query --query "API documentation" --top-k 5 --json # Search with metadata filter RAGent query -q "error handling" --filter '{"category":"programming"}'
Options:
-q, --query: Search query text (required)-k, --top-k: Number of similar results to return (default: 10)-j, --json: Output results in JSON format-f, --filter: JSON metadata filter (e.g.,'{"category":"docs"}')--enable-slack-search: Include Slack conversations alongside document results when Slack search is enabled
Usage Examples:
bash# Search technical documentation RAGent query -q "Docker container configuration" --top-k 3 # Search within specific category RAGent query -q "authentication" --filter '{"type":"security"}' --json # Get more results RAGent query -q "database optimization" --top-k 20 # Merge Slack context for incident reviews RAGent query -q "on-call handoff" --enable-slack-search # Reference a specific Slack message by URL (automatically fetched) RAGent query -q "What was discussed in https://your-workspace.slack.com/archives/C12345678/p1234567890123456"
URL-Aware Search
RAGent inspects each query for HTTP/HTTPS URLs. When a URL is present, it first performs an exact term query on the reference field before running the usual hybrid search pipeline.
- Successful URL matches return immediately with
search_methodset to"url_exact_match"and include the URL-only results. - If the term query fails or returns no hits, the engine falls back to the hybrid search flow and records the fallback reason (
term_query_errororterm_query_no_results). - CLI
--jsonoutput, Slack bot responses, and MCP tool results exposesearch_method,url_detected, andfallback_reasonso callers can inspect how the result was produced.
bashRAGent query --json -q "https://example.com/doc のタイトルを教えて"
Example JSON response




