Skip to content

Configurable RAG Knowledge Stores with Custom Tools - #319

Merged
butschster merged 4 commits into
mainfrom
issue/318
Jan 22, 2026
Merged

butschster merged 4 commits into
mainfrom
issue/318

Conversation

@butschster

Copy link
Copy Markdown
Collaborator

This PR refactors the RAG module to support multiple named storage configurations (servers + collections) and enables defining custom RAG tools via context.yaml. This significantly improves AI understanding of tool purpose and allows project-specific knowledge stores with meaningful names and descriptions.

Motivation

The existing RAG implementation had several limitations:

  • Generic Tool Names: Tools like rag-search and rag-store don't convey purpose to AI assistants
  • Single Storage: Only one Qdrant endpoint/collection per project was supported
  • No Customization: Tool descriptions were hardcoded, not project-specific
  • Limited CLI: Commands didn't support multi-collection operations

Changes

New Configuration Format

The RAG configuration now supports multiple servers and collections:

rag:
  servers:
    default:
      driver: qdrant
      endpoint_url: ${RAG_QDRANT_ENDPOINT:-http://localhost:6333}
      api_key: ${RAG_QDRANT_API_KEY:-}

    cloud:
      driver: qdrant
      endpoint_url: https://my-cluster.qdrant.io
      api_key: ${QDRANT_CLOUD_API_KEY}

  collections:
    project-docs:
      server: default
      collection: myproject_docs
      description: "Project documentation and guides"

    architecture:
      server: default
      collection: myproject_architecture
      description: "Architecture decisions and patterns"
      transformer:
        chunk_size: 2000
        overlap: 400

  vectorizer:
    platform: openai
    model: text-embedding-3-small
    api_key: ${OPENAI_API_KEY}

  transformer:
    chunk_size: 1000
    overlap: 200

Custom RAG Tools

Define AI-friendly tools with meaningful names and descriptions:

tools:
  - id: find-documentation
    type: rag
    description: |
      Search project documentation for guides, tutorials, and how-to articles.
      Use this when you need to understand how to use project features.
    collection: project-docs
    operations: [search]

  - id: understand-architecture
    type: rag
    description: |
      Search architecture decisions, patterns, and design rationale.
      Use when understanding why code is structured a certain way.
    collection: architecture
    operations: [search]

  - id: save-knowledge
    type: rag
    description: "Store insights and documentation for future retrieval."
    collection: project-docs
    operations: [store]

CLI Commands with Collection Support

All RAG commands now support the --collection option:

# Index into specific collection
ctx rag:index docs --collection=project-docs

# Index into all collections (default behavior)
ctx rag:index docs

# Status for specific collection
ctx rag:status --collection=architecture

# Clear specific collection
ctx rag:clear --collection=project-docs

# Initialize specific collection
ctx rag:init --collection=shared-knowledge

Refactor RAG module to support multiple named storage configurations
and custom tool definitions via context.yaml.
@butschster butschster added this to the 1.34 milestone Jan 22, 2026
@butschster butschster self-assigned this Jan 22, 2026
@butschster butschster added the mcp MCP server components label Jan 22, 2026
@butschster butschster added the mcp:tools MCP server tools label Jan 22, 2026
@butschster butschster linked an issue Jan 22, 2026 that may be closed by this pull request
@codecov

codecov Bot commented Jan 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 6.45161% with 29 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/McpServer/ActionsBootloader.php 6.89% 27 Missing ⚠️
src/Console/Renderer/GenerateCommandRenderer.php 0.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@butschster
butschster merged commit 920fdbc into main Jan 22, 2026
8 of 9 checks passed
@butschster
butschster deleted the issue/318 branch January 22, 2026 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mcp:tools MCP server tools mcp MCP server components

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Configurable RAG Knowledge Stores with Custom Tools

1 participant