RAGent - RAG System Builder for Markdown Documentsのロゴ

RAGent - RAG System Builder for Markdown Documents

組織
ca-srg

CLI tool for building production RAG systems from Markdown, CSV, and PDF documents using hybrid search (BM25 + vector) with OpenSearch. Features MCP server, Slack bot, Web UI, multi-source ingestion (local/S3/GitHub), and multi-provider embeddings (Bedrock/Gemini).

公開者ca-srg
リポジトリragent
言語Go
フォーク
2
スター
13
利用可能なツール
0
通信方式stdio
カテゴリ
リンク
  • ツールをAIワークフローに接続

    RAGent - RAG System Builder for Markdown Documentsは、対応するAIクライアントやAIエージェントから利用できるMCP機能を提供します。

  • 0個の利用可能なツール

    呼び出し可能なアクションを以下で確認できます。サーバーから提供されている場合は、名前や説明も表示されます。

  • コピーして使える設定

    セットアップ用の設定例を使って、お好みのMCPクライアントにこのサーバーを設定できます。

  • オープンソースの注目度

    リンク先のリポジトリには13件のスターと2件のフォークがあります。

RAGent - RAG System Builder for Markdown Documents

日本語版 (Japanese) / 日本語 README

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

  • 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:

  • query exposes --enable-slack-search flag to opt in per request.
  • chat surfaces Slack context in addition to documents without requiring extra flags.
  • slack-bot responds with combined document + Slack answers inside Block Kit messages.
  • mcp-server adds enable_slack_search parameter to the hybrid_search tool.

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=bedrock or OCR_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.

yaml
csv:
  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_row is not specified, the default is 1 (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, query CLI, mcp-server) calls the legacy search.messages API with the user-token search:read scope. Results cover public channels, private channels the user belongs to, plus DMs / MPIMs.
  • Without SLACK_USER_TOKEN — only the slack-bot mention path can search Slack. It switches to the Real-time Search API (assistant.search.context) using the bot token together with the short-lived action_token carried by app_mention / DM message events. The bot needs the granular search:read.public scope and reaches public channels even ones the bot has not been invited to. The query CLI and mcp-server cannot obtain an action_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 whose X-Forwarded-For headers 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

  1. On startup, RAGent checks for the SECRET_MANAGER_SECRET_ID environment variable.
  2. If set, it fetches the secret from AWS Secrets Manager (the secret must be stored as a JSON key-value pair).
  3. For each key in the JSON, if the corresponding environment variable is not already set, the value is injected.
  4. 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 VariableDescriptionDefault
SECRET_MANAGER_SECRET_IDSecret ID or ARN in AWS Secrets Manager(not set — feature disabled)
SECRET_MANAGER_REGIONAWS region for Secrets Managerus-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:

  1. Open the AWS Secrets Manager Console
  2. Click Store a new secret
  3. Select Other type of secret
  4. Choose Plaintext and enter a JSON object with key-value pairs
  5. 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.

bash
aws 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: true to enable tracing and metrics (defaults to false).
  • OTEL_SERVICE_NAME: Logical service name (ragent by default).
  • OTEL_RESOURCE_ATTRIBUTES: Comma-separated key=value pairs such as service.namespace=ragent,environment=dev.
  • OTEL_EXPORTER_OTLP_ENDPOINT: OTLP endpoint URL (including scheme).
  • OTEL_EXPORTER_OTLP_PROTOCOL: http/protobuf (default) or grpc.
  • 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]
bash
otelcol --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_message
    • mcpserver.hybrid_search
    • search.hybrid
  • Metrics
    • ragent.slack.requests.total, ragent.slack.errors.total, ragent.slack.response_time
    • ragent.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.

Grafana Dashboard

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:

  1. Enable OpenTelemetry in RAGent:

    bash
    export OTEL_ENABLED=true
    export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
  2. Configure OTel Collector to export metrics to Prometheus (see example above)

  3. 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
  4. 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).

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:

bash
tar -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)

env
VECTOR_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)

env
VECTOR_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.

bash
RAGent 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-s3 is 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=bedrock or OCR_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_method set 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_error or term_query_no_results).
  • CLI --json output, Slack bot responses, and MCP tool results expose search_method, url_detected, and fallback_reason so callers can inspect how the result was produced.
bash
RAGent query --json -q "https://example.com/doc のタイトルを教えて"

Example JSON response

インストール

TypingMind
前提条件:

Node.js 18+

{
  "mcpServers": {
    "ca-srg-ragent": {
      "command": "",
      "args": []
    }
  }
}

RAGent - RAG System Builder for Markdown DocumentsのMCPを複数のAIモデルで活用

TypingMindはワークスペース単位でMCPツールに接続します。そのため、一度RAGent - RAG System Builder for Markdown Documentsに接続すれば、モデルごとに個別に設定することなく、TypingMind内のさまざまなAIモデルで利用できます。 このMCPは、デバイス上のTypingMind MCPコネクタを通じてローカルで動作します。

ローカルコネクタのセットアップガイド

MCPサーバーが、お使いのコンピューター上のローカルファイル、アプリ、非公開リソースにアクセスする必要がある場合は、この方法を使います。

1

MCP設定を開く

TypingMindで「設定」、「詳細設定」、「MCP」の順に進み、「コネクタを設定」を選択してください。

  1. ブラウザでTypingMindを開いてください。
  2. 設定アイコンをクリックしてください。
  3. 「詳細設定」に移動してください。
  4. 「MCP」セクションを開いてください。
  5. 「コネクタを設定」をクリックし、「このデバイス」を選択してください。
「このデバイス」が選択されたTypingMindのMCPコネクタ設定画面
2

コネクタのコマンドを実行

「このデバイス」を選択し、TypingMindからコマンドをコピーしてターミナルで実行してください。MCPの使用中は、プロセスを実行したままにしてください。

  1. TypingMindに表示されるセットアップコマンドをコピーしてください。
  2. macOSではターミナルを、WindowsではWindows Terminalを開いてください。
  3. コマンドを貼り付けて実行してください。
  4. ターミナルで続行の確認を求められた場合は、パッケージのインストールを承認してください。
  5. MCPツールの使用中は、ターミナルウィンドウを開いたまま、プロセスの実行を継続してください。
3

RAGent - RAG System Builder for Markdown Documentsをサーバーとして追加

コネクタのステータスが「準備完了」になったら、「サーバーを編集」をクリックし、MCPサーバーの設定を貼り付けてください。

  1. コネクタのステータスが「準備完了」になるまでお待ちください。
  2. 「サーバーを編集」をクリックしてください。
  3. RAGent - RAG System Builder for Markdown DocumentsのMCPサーバー設定を貼り付けてください。
  4. サーバー一覧を保存してください。
  5. コネクタが引き続き使用可能か確認するには、更新してください。
稼働中のサーバーと「サーバーを編集」ボタンが表示されたTypingMindのMCP設定画面
{
  "mcpServers": {
    "ca-srg-ragent": {
      "command": "npx",
      "args": [
        "-y",
        "ragent"
      ]
    }
  }
}
4

複数のモデルで同じ接続を使用

サーバー一覧を保存し、「プラグイン」を開いてRAGent - RAG System Builder for Markdown DocumentsのMCPツールを有効にしてください。その後、TypingMindで対応するAIモデルを選択し、チャットでツールを使うか、AIエージェントに割り当ててください。

  1. TypingMindの「プラグイン」ページを開いてください。
  2. RAGent - RAG System Builder for Markdown DocumentsのMCPツールを有効にしてください。
  3. チャットを開始し、使用するAIモデルを選択してください。
  4. MCPツールをチャットで使うか、AIエージェントに割り当ててください。
  5. MCPに再接続することなく、必要に応じて別のAIモデルに切り替えられます。
選択したAIモデルと有効なMCPツールを使用したTypingMindのチャット
RAGent - RAG System Builder for Markdown Documentsを使ってこのタスクを手伝ってもらえますか?
RAGent - RAG System Builder for Markdown Documents
はい、読みました。
RAGent - RAG System Builder for Markdown Documentsで調べた結果をお伝えします。

よくある質問

RAGent - RAG System Builder for Markdown Documents MCPサーバーは何に使いますか?

RAGent - RAG System Builder for Markdown Documentsは、対応するAIクライアントを外部ツールやコンテキストに接続するためのMCPサーバーです。TypingMindでは、このMCPサーバーを一度追加するだけで、AIワークスペース内でそのツールを利用できるようになります。

TypingMindでRAGent - RAG System Builder for Markdown Documents MCPを複数のAIモデルと併用できますか?

はい。TypingMindはワークスペース単位でMCPツールに接続するため、モデルごとにMCPサーバーを設定する必要はありません。Claude、ChatGPT、Geminiや、TypingMindで設定したその他のAIモデルでRAGent - RAG System Builder for Markdown Documentsを利用できます。

TypingMindでRAGent - RAG System Builder for Markdown Documents MCPを使うメリットは何ですか?

TypingMindは、複数のAIモデル、プロンプト、プラグイン、AIエージェント、APIキー、MCPツールを1つのワークスペースにまとめられる、LLMチャット向けの優れたフロントエンドです。RAGent - RAG System Builder for Markdown Documentsを接続すると、TypingMindでチャットのワークフローを整理しながら、お好みのモデルでそのMCPツールを利用できます。

RAGent - RAG System Builder for Markdown Documents MCPをTypingMindに接続するにはどうすればよいですか?

RAGent - RAG System Builder for Markdown DocumentsはTypingMindのローカルMCPコネクタ経由で動作します。MCPサーバーがコンピューター上のローカルファイル、デスクトップアプリ、コマンドラインツール、プライベートリソースにアクセスする必要がある場合に最適です。

TypingMindでRAGent - RAG System Builder for Markdown Documents MCPのどのようなツールを利用できますか?

RAGent - RAG System Builder for Markdown DocumentsはMCP機能を提供しています。TypingMindのプラグインページで有効にすると、チャットで使用したり、AIエージェントに割り当てたりできます。

RAGent - RAG System Builder for Markdown Documents MCPを使うには、APIキーをTypingMindと共有する必要がありますか?

いいえ。TypingMindはローカルファーストの設計で、モデルプロバイダー、APIキー、プロンプト、MCP設定をご自身で管理できます。RAGent - RAG System Builder for Markdown Documentsで認証が必要な場合は、接続の作成時に、そのMCPサーバーに必要なヘッダー、OAuth設定、またはローカル設定を追加してください。

関連するMCPサーバー

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇