Skip to content

Delegate RAG and query enrichment to vtk-mcp#33

Draft
vicentebolea wants to merge 11 commits intomasterfrom
use-vtk-mcp
Draft

Delegate RAG and query enrichment to vtk-mcp#33
vicentebolea wants to merge 11 commits intomasterfrom
use-vtk-mcp

Conversation

@vicentebolea
Copy link
Copy Markdown
Member

@vicentebolea vicentebolea commented Mar 20, 2026

Summary

  • Removes all local RAG infrastructure (ChromaDB, llama_index, sentence_transformers, tree_sitter, rag-components submodule, data/examples, db/)
  • Delegates vector search and query enrichment to vtk-mcp via a new vtk_mcp_client.py HTTP client
  • --rag now requires --mcp-url pointing to a running vtk-mcp server
  • Import validation and auto-fixing of generated code via vtk-mcp (always active when --mcp-url is set)

How it works

When --mcp-url is set, a single VTKMCPClient instance is created per query and used for:

  1. Context enrichment (when --rag): hybrid vector search over VTK examples + Python API docs for relevant VTK classes
  2. Import fixing (always): validates and auto-corrects VTK import statements in the generated code

Changes

  • vtk_mcp_client.py: new HTTP JSON-RPC client wrapping vtk-mcp tools
  • client.py: removed ChromaDB code paths; added mcp_url field
  • cli.py: replaced --collection/--database with --mcp-url
  • pyproject.toml: removed all RAG deps; added requests; removed rag-chat, vtk-build-rag, vtk-test-rag entry points
  • Deleted: rag_chat_wrapper.py, build_rag_db.py, test_rag.py, rag-components/ submodule, data/, db/

Usage

# RAG-enhanced generation
vtk-prompt "create a red sphere" --rag --mcp-url http://localhost:8000 -t $API_KEY

# Import fixing only (no RAG context)
vtk-prompt "create a cube" --mcp-url http://localhost:8000 -t $API_KEY

# No MCP (baseline)
vtk-prompt "create a cone" -t $API_KEY

Test plan

  • All existing tests pass (45 passed, 14 skipped)
  • RAG-enhanced generation works with a running vtk-mcp server
  • Import statements in generated code are validated and fixed
  • Baseline generation without --mcp-url still works

Replace local ChromaDB-based RAG with vtk-mcp HTTP client that provides
richer context via hybrid vector search, VTK class API documentation
lookup, and post-generation import validation.

- Add vtk_mcp_client.py: HTTP JSON-RPC client for vtk-mcp server
  - vector_search: hybrid search over VTK code examples
  - search_classes + get_class_info: query enrichment with VTK API docs
  - fix_imports: validate and auto-correct VTK import statements
- client.py: replace ChromaDB paths with vtk-mcp; single VTKMCPClient
  instance per query reused for both context enrichment and import fixing
- cli.py: replace --collection/--database with --mcp-url
- state/initializer.py: pass mcp_url state to VTKPromptClient
- pyproject.toml: drop heavy RAG deps from core; add requests; keep old
  deps in optional [rag] extra for legacy rag-chat/build-rag-db tools
- Fix client.py query(): remove duplicate content re-assignment after
  tool loop, guard regex extraction with empty-match handling, use
  getattr for optional usage attribute
- generation.py: execute_with_renderer now returns (success, error);
  on execution failure retry once via prompt_client.query(execution_error=)
  when vtk-mcp is configured so the LLM can use tools to fix the code
- Wrap long return tuple onto multiple lines (E501)
- Add type: ignore[call-overload] on create() with unpacked tools dict
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant