Connect to Vectara for RAG and Hallucination Correction
A Vectara MCP server for RAG queries, semantic search, and hallucination correction, secured by default over HTTP.
Why it matters
Integrate agent applications with Vectara's Trusted RAG platform for fast, reliable retrieval-augmented generation and reduced hallucinations. Access advanced features like semantic search, hallucination detection, and factual consistency evaluation.
Outcomes
What it gets done
Provide RAG capabilities with reduced hallucinations via Vectara's Trusted RAG platform.
Execute semantic search queries without text generation.
Detect and correct hallucinations in generated text.
Evaluate the factual consistency of generated text against source documents.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/vb-vectara | bash Capabilities
Tools your agent gets
Set up and validate your Vectara API key for the session
Clear the saved API key from server memory
Execute a RAG query through Vectara, returns search results with generated answer
Execute a semantic search query through Vectara without generation
Detect and correct hallucinations in generated text using Vectara's VHC
Evaluate the factual consistency of generated text against source documents
Overview
Vectara MCP Server
A Vectara MCP server with RAG query, semantic search, and hallucination/factual-consistency correction tools, secured by default over HTTP with bearer-token authentication. Use for RAG queries or hallucination/factual-consistency checking against a Vectara corpus; never disable authentication or expose STDIO transport in production.
What it does
This MCP server wraps Vectara's RAG platform in six tools across three categories. API key management covers setup_vectara_api_key (validates and stores a Vectara API key for the session) and clear_vectara_api_key (clears it from server memory). Query tools include ask_vectara, which runs a full RAG query against one or more corpus keys and returns a generated answer plus search results, configurable with sentence-context windows before/after the answer, lexical interpolation weight, max search results used, a generation preset (default vectara-summary-table-md-query-ext-jan-2025-gpt-4o), and response language; and search_vectara, the same semantic search without generation, returning matching passages only. Analysis tools include correct_hallucinations, which uses Vectara's VHC (Vectara Hallucination Correction) API to identify and correct hallucinated claims in generated text against a set of source documents, and eval_factual_consistency, which scores generated text's factual consistency against those same source documents using Vectara's dedicated evaluation API - both return JSON-formatted results, and both require an API key configured first via setup_vectara_api_key or the VECTARA_API_KEY environment variable.
When to use - and when NOT to
Use this for RAG queries or semantic search against a Vectara corpus, or for checking and correcting generated text against source documents for hallucinations and factual consistency.
The server is secure by default: it starts on HTTP transport with authentication enabled, requiring a bearer token or X-API-Key header for every request. STDIO transport (used for Claude Desktop or local development) is explicitly less secure and should only be used locally, never exposed to a network. Authentication can be disabled with --no-auth, but this is flagged as dangerous and for development only - never use it in production. Six security best practices are stated: always use HTTP transport in production (never expose STDIO to the network), keep authentication enabled, deploy behind a reverse proxy with TLS/HTTPS termination, restrict CORS via VECTARA_ALLOWED_ORIGINS, rotate VECTARA_API_KEY/VECTARA_AUTHORIZED_TOKENS regularly, and monitor the default rate limit of 100 requests/minute.
Inputs and outputs
Inputs are a Vectara API key, one or more corpus keys, and a query or a generated-text/source-documents pair to analyze. Output is a generated RAG answer with citations, raw semantic search results, or a JSON report of corrected hallucinations or factual-consistency scoring. Required configuration is VECTARA_API_KEY; optional configuration covers host/port, transport mode, CORS origins, and authorized bearer tokens.
How to install
Install from PyPI with pip install vectara-mcp. Start it with python -m vectara_mcp, which runs on secure HTTP transport by default at http://127.0.0.1:8000 with authentication enabled; STDIO and SSE transport modes are also available via configuration flags for local development. See SECURITY.md for detailed security guidelines. The project is licensed, per its PyPI package metadata; check the repository for exact terms.
Who it's for
Teams running Vectara-backed RAG who want an MCP interface for querying and hallucination/factual-consistency checking, with production-appropriate authentication and transport security by default.
pip install vectara-mcp
Source README
Vectara MCP Server
🔌 Compatible with Claude Desktop, and any other MCP Client!
Vectara MCP is also compatible with any MCP client
The Model Context Protocol (MCP) is an open standard that enables AI systems to interact seamlessly with various data sources and tools, facilitating secure, two-way connections.
Vectara-MCP provides any agentic application with access to fast, reliable RAG with reduced hallucination, powered by Vectara's Trusted RAG platform, through the MCP protocol.
Installation
You can install the package directly from PyPI:
pip install vectara-mcp
Quick Start
Secure by Default (HTTP/SSE with Authentication)
# Start server with secure HTTP transport (DEFAULT)
python -m vectara_mcp
# Server running at http://127.0.0.1:8000 with authentication enabled
Local Development Mode (STDIO)
# For Claude Desktop or local development (less secure)
python -m vectara_mcp --stdio
# ⚠️ Warning: STDIO transport is less secure. Use only for local development.
Configuration Options
# Custom host and port
python -m vectara_mcp --host 0.0.0.0 --port 8080
# SSE transport mode
python -m vectara_mcp --transport sse --path /sse
# Disable authentication (DANGEROUS - dev only)
python -m vectara_mcp --no-auth
Transport Modes
HTTP Transport (Default - Recommended)
- Security: Built-in authentication via bearer tokens
- Encryption: HTTPS ready
- Rate Limiting: 100 requests/minute by default
- CORS Protection: Configurable origin validation
- Use Case: Production deployments, cloud environments
SSE Transport
- Streaming: Server-Sent Events for real-time updates
- Authentication: Bearer token support
- Compatibility: Works with legacy MCP clients
- Use Case: Real-time streaming applications
STDIO Transport
- ⚠️ Security Warning: No transport-layer security
- Performance: Low latency for local communication
- Use Case: Local development, Claude Desktop
- Requirement: Must be explicitly enabled with
--stdioflag
Environment Variables
# Required
export VECTARA_API_KEY="your-api-key"
# Optional
export VECTARA_AUTHORIZED_TOKENS="token1,token2" # Additional auth tokens
export VECTARA_ALLOWED_ORIGINS="http://localhost:*,https://app.example.com"
export VECTARA_TRANSPORT="http" # Default transport mode
export VECTARA_AUTH_REQUIRED="true" # Enforce authentication
Authentication
HTTP/SSE Transport
When using HTTP or SSE transport, authentication is required by default:
# Using curl with bearer token
curl -H "Authorization: Bearer $VECTARA_API_KEY" \
-H "Content-Type: application/json" \
-X POST http://localhost:8000/call/ask_vectara \
-d '{"query": "What is Vectara?", "corpus_keys": ["my-corpus"]}'
# Using X-API-Key header (alternative)
curl -H "X-API-Key: $VECTARA_API_KEY" \
http://localhost:8000/sse
Disabling Authentication (Development Only)
# ⚠️ NEVER use in production
python -m vectara_mcp --no-auth
Available Tools
API Key Management
setup_vectara_api_key:
Configure and validate your Vectara API key for the session (one-time setup).Args:
- api_key: str, Your Vectara API key - required.
Returns:
- Success confirmation with masked API key or validation error.
clear_vectara_api_key:
Clear the stored API key from server memory.Returns:
- Confirmation message.
Query Tools
ask_vectara:
Run a RAG query using Vectara, returning search results with a generated response.Args:
- query: str, The user query to run - required.
- corpus_keys: list[str], List of Vectara corpus keys to use for the search - required.
- n_sentences_before: int, Number of sentences before the answer to include in the context - optional, default is 2.
- n_sentences_after: int, Number of sentences after the answer to include in the context - optional, default is 2.
- lexical_interpolation: float, The amount of lexical interpolation to use - optional, default is 0.005.
- max_used_search_results: int, The maximum number of search results to use - optional, default is 10.
- generation_preset_name: str, The name of the generation preset to use - optional, default is "vectara-summary-table-md-query-ext-jan-2025-gpt-4o".
- response_language: str, The language of the response - optional, default is "eng".
Returns:
- The response from Vectara, including the generated answer and the search results.
search_vectara:
Run a semantic search query using Vectara, without generation.Args:
- query: str, The user query to run - required.
- corpus_keys: list[str], List of Vectara corpus keys to use for the search - required.
- n_sentences_before: int, Number of sentences before the answer to include in the context - optional, default is 2.
- n_sentences_after: int, Number of sentences after the answer to include in the context - optional, default is 2.
- lexical_interpolation: float, The amount of lexical interpolation to use - optional, default is 0.005.
Returns:
- The response from Vectara, including the matching search results.
Analysis Tools
correct_hallucinations:
Identify and correct hallucinations in generated text using Vectara's VHC (Vectara Hallucination Correction) API.Args:
- generated_text: str, The generated text to analyze for hallucinations - required.
- documents: list[str], List of source documents to compare against - required.
- query: str, The original user query that led to the generated text - optional.
Returns:
- JSON-formatted string containing corrected text and detailed correction information.
eval_factual_consistency:
Evaluate the factual consistency of generated text against source documents using Vectara's dedicated factual consistency evaluation API.Args:
- generated_text: str, The generated text to evaluate for factual consistency - required.
- documents: list[str], List of source documents to compare against - required.
- query: str, The original user query that led to the generated text - optional.
Returns:
- JSON-formatted string containing factual consistency evaluation results and scoring.
Note: API key must be configured first using setup_vectara_api_key tool or VECTARA_API_KEY environment variable.
Configuration with Claude Desktop
To use with Claude Desktop, update your configuration to use STDIO transport:
{
"mcpServers": {
"Vectara": {
"command": "python",
"args": ["-m", "vectara_mcp", "--stdio"],
"env": {
"VECTARA_API_KEY": "your-api-key"
}
}
}
}
Or using uv:
{
"mcpServers": {
"Vectara": {
"command": "uv",
"args": ["tool", "run", "vectara-mcp", "--stdio"]
}
}
}
Note: Claude Desktop requires STDIO transport. While less secure than HTTP, it's acceptable for local desktop use.
Usage in Claude Desktop App
Once the installation is complete, and the Claude desktop app is configured, you must completely close and re-open the Claude desktop app to see the Vectara-mcp server. You should see a hammer icon in the bottom left of the app, indicating available MCP tools, you can click on the hammer icon to see more detail on the Vectara-search and Vectara-extract tools.
Now claude will have complete access to the Vectara-mcp server, including all six Vectara tools.
Secure Setup Workflow
First-time setup (one-time per session):
- Configure your API key securely:
setup-vectara-api-key
API key: [your-vectara-api-key]
After setup, use any tools without exposing your API key:
Vectara Tool Examples
- RAG Query with Generation:
ask-vectara
Query: Who is Amr Awadallah?
Corpus keys: ["your-corpus-key"]
- Semantic Search Only:
search-vectara
Query: events in NYC?
Corpus keys: ["your-corpus-key"]
- Hallucination Detection & Correction:
correct-hallucinations
Generated text: [text to check]
Documents: ["source1", "source2"]
- Factual Consistency Evaluation:
eval-factual-consistency
Generated text: [text to evaluate]
Documents: ["reference1", "reference2"]
Security Best Practices
- Always use HTTP transport for production - Never expose STDIO transport to the network
- Keep authentication enabled - Only disable with
--no-authfor local testing - Use HTTPS in production - Deploy behind a reverse proxy with TLS termination
- Configure CORS properly - Set
VECTARA_ALLOWED_ORIGINSto restrict access - Rotate API keys regularly - Update
VECTARA_API_KEYandVECTARA_AUTHORIZED_TOKENS - Monitor rate limits - Default 100 req/min, adjust based on your needs
See SECURITY.md for detailed security guidelines.
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.