# Vectara MCP

> Vectara connects your agent to secure, internal data sources for Retrieval-Augmented Generation (RAG). It lets you query private documents using natural language, run interactive chats against specific knowledge bases (corpora), and manage the document indexes themselves. This is how you turn a pile of PDFs into an active, searchable database.

## Overview
- **Category:** ai-frontier
- **Price:** Free
- **Tags:** rag, semantic-search, enterprise-search, grounded-generation, nlp, data-indexing

## Description

You gotta connect your agent to the good stuff—the private data locked up in internal wikis and runbooks. This server does that, giving your AI client Retrieval-Augmented Generation (RAG) right where you need it. It turns a messy pile of PDFs into an active, searchable database.

When you're querying private documents semantically, the agent uses `perform_semantic_search`. You pass in one or more corpus keys and your query; it executes a search across all specified datasets, pulling back highly relevant document snippets. It doesn't just look for keywords—it finds the context that matters.

Want an actual conversation? Use `execute_rag_chat`. This runs a full, chat-style session on specific corpora. Your AI client gives you detailed answers and cites exactly which source documents it pulled from to back up every single claim. You'll also get a list of IDs for previous RAG chat sessions using `list_chat_sessions`, so you can keep track of what was talked about.

Managing your knowledge base is just as important. To see everything available, run `list_corpora`; it spits out every searchable dataset (corpus) configured in your whole Vectara account. If you need to drill down into a specific data source, `get_corpus_details` pulls all the metadata and configuration info for that single corpus key.

Need to know what's actually inside? You can use `list_corpus_documents`, which returns a full list of every individual document indexed within one specified corpus key. And if you find stale or obsolete files, don't sweat it—`delete_corpus_document` lets you permanently remove specific documents from a corpus using their key. Just remember, that action is irreversible.

This server handles the whole cycle: running deep semantic searches, having cited chats, listing all available knowledge sources, and maintaining the integrity of your document indexes.

## Tools

### delete_corpus_document
Permanently removes an indexed document from a specific knowledge corpus. This action cannot be undone.

### execute_rag_chat
Runs an interactive, chat-style session that provides AI answers and cites the sources based on provided corpora keys.

### get_corpus_details
Retrieves all metadata and configuration information for a single specified corpus key.

### list_chat_sessions
Returns a list of IDs for previous RAG chat sessions that have been completed.

### list_corpora
Lists every searchable dataset (corpus) configured within your entire Vectara account.

### list_corpus_documents
Retrieves a list of all individual indexed documents contained inside one specific corpus key.

### perform_semantic_search
Executes a semantic search query across multiple specified corpora, finding the most relevant document snippets based on your input text.

## Prompt Examples

**Prompt:** 
```
List all configured knowledge corpora I have in Vectara.
```

**Response:** 
```
We retrieved 3 existing corpora within your active Customer ID cluster: 
- 'HR Manuals' (Key: `cor-29x`)
- 'DevOps Runbooks' (Key: `cor-81a`)
- 'Helpcenter FAQs' (Key: `cor-03f`)
Would you like me to pull the total document count indexing actively inside 'DevOps Runbooks'?
```

**Prompt:** 
```
Query corpus `cor-81a` for instructions on 'rolling back kubernetes pods' and show only the top 3 best matching results.
```

**Response:** 
```
I've searched corpus `cor-81a`. Here are the top 3 semantic matches:

1. From 'infra-deploy.pdf' (Score 0.94): "To safely rollback a deployed k8s pod replica containing faulty image configs, use `kubectl rollout undo deployment/api-server`."
2. From 'incident-231.md' (Score 0.88): "During yesterday's P1, we reversed the pods deployment to stabilization tag v2.1.0 using standard rollback patterns..."
3. From 'onboarding.txt' (Score 0.76): "New engineers must verify staging before any manual pod cluster rollbacks occur in production environments..."
```

**Prompt:** 
```
List all active chat context session IDs for the last week.
```

**Response:** 
```
I've retrieved historical chat sessions. You have 2 sessions retained matching your request: `chat-89bf` (Initiated: Mon 14th) covering Corpus HR, and `chat-21zx` (Initiated: Wed 16th) heavily focused on developer queries. Do you want to see the sequence of turns for the DevOps troubleshooting session?
```

## Capabilities

### Search private documents semantically
You pass the agent one or more corpus keys and a query; it then executes a semantic search across all specified datasets, returning highly relevant document snippets.

### Execute cited chat completions
The agent runs an interactive, RAG-powered chat session on specific corpora, providing detailed answers with direct citations to the source documents.

### List all available knowledge sources
It retrieves a list of every searchable dataset (corpora) configured in your Vectara account so you know what data is available for querying.

### Manage document indexes and metadata
The agent pulls configuration details, unique keys, or full lists of documents within any given corpus to help you audit the data structure.

### Remove stale or obsolete files
You permanently delete specific documents from a corpus using their key. This action is irreversible and keeps your search results clean.

## Use Cases

### Debugging an unknown Kubernetes failure
A DevOps engineer hits a critical bug in production. Instead of digging through Slack threads and old tickets, they ask their agent: 'What was the rollback procedure for v2.1.0?' The agent runs `execute_rag_chat` across the 'DevOps Runbooks' corpus and immediately returns the citation from the correct incident report.

### Drafting a technical product guide
A Technical Writer needs to write a section on user permissions. They use their agent to run `perform_semantic_search` against three different corpora: 'HR Manuals', 'Security Policies', and 'Product Spec V3'. The agent gathers all required details, ensuring the new document is accurate across all departments.

### Cleaning up obsolete internal data
A Data Engineer knows a project was decommissioned last month. They use `list_corpus_documents` to find every file related to that project and then run `delete_corpus_document` on each one, keeping the knowledge base clean.

### Finding niche answers across departments
A Product Lead asks: 'What are the requirements for integrating a third-party API?' The agent runs a semantic search across all relevant corpora—'Product Specs', 'Legal Docs', and 'Integration Guides'—and synthesizes one answer with citations from three different sources.

## Benefits

- **Precision over Keywords:** Instead of relying on exact keyword matches, `perform_semantic_search` finds documents that *mean* what you're asking. You query 'how do I reset the API key,' and it pulls the right section even if those words aren't in the document title.
- **Contextual Chat Flow:** With `execute_rag_chat`, your AI agent maintains conversation context across multiple turns. It doesn't forget what you asked three prompts ago, giving you a true back-and-forth dialogue with your documentation.
- **Auditing and Cleanup:** The admin tools are critical. Use `list_corpus_documents` to see exactly which files make up a corpus, and use `delete_corpus_document` when stale info pollutes the search results.
- **Cross-Corpus Discovery:** You don't have to manually check every manual. By listing multiple corpora with `perform_semantic_search`, your agent can draw knowledge from HR guides *and* DevOps runbooks in one go.
- **History Tracking:** Need to reference a past conversation? `list_chat_sessions` gives you the IDs for old RAG chats, letting you pick up exactly where you left off without starting over.

## How It Works

The bottom line is that your AI client gets direct access to your internal knowledge graphs, making it act like a specialized data librarian for your company.

1. First, subscribe to the server and enter your Vectara API Key and Customer ID.
2. Next, point your AI agent at a specific corpus key or ask it to list all available corpora using `list_corpora`.
3. Finally, use the agent to either run a targeted semantic query (`perform_semantic_search`) or start an interactive chat session (`execute_rag_chat`).

## Frequently Asked Questions

**How do I find out which documents are available for search using list_corpora?**
Run `list_corpora` first. This command shows you every dataset (corpus) currently indexed in your account. It's the necessary starting step to know what knowledge is even available.

**Is perform_semantic_search better than execute_rag_chat for finding data?**
It depends on the goal. Use `perform_semantic_search` when you just need a quick dump of the top 3 matching documents (the evidence). Use `execute_rag_chat` when you want a synthesized, narrative answer built from those sources.

**What if I find bad data in my corpus? Can I remove it using delete_corpus_document?**
Yes. If you locate an obsolete or incorrect file, use `delete_corpus_document` with the specific document key. Remember this action is irreversible.

**Can I see what corpora are available for my team to search?**
Run `list_corpora`. This command gives you a full, structured list of all your company’s knowledge bases and their unique keys.

**What critical configuration data can I check using the `get_corpus_details` tool?**
The tool provides metadata and current settings for a specific corpus. You'll see details like the corpus creation date, its owner ID, and whether it has any active indexing limits applied. This confirms your dataset is properly set up before running queries.

**If I use `list_corpus_documents`, what information do I get about each indexed file?**
It lists every document inside a corpus, giving you the unique internal key and the file's last modified date. This helps inventory control and ensures you know exactly which files are contributing to search results.

**When I run `perform_semantic_search` with an invalid or non-existent corpus key, what error should I expect?**
The agent will return a specific API error indicating that the provided corpus keys do not resolve to any active dataset. This means you need to verify your input keys against the output of `list_corpora`.

**How can I use `list_chat_sessions` to audit my previous RAG conversations?**
This tool retrieves a list of past chat sessions, providing the unique session ID and when it was initiated. It's perfect for quickly finding context histories you need to review or reference later.

**Can I query my internal documents directly using just conversational chat?**
Yes. If your data is indexed in a Vectara corpus, simply ask your agent: `search the 'employee-handbook' corpus for remote work policies`. The agent uses the `queryTool` to pass your question to Vectara's semantic engine, effortlessly bringing back precisely matching paragraph citations instantly.

**How do I remove outdated context files destroying the accuracy of my RAG model?**
You don't need to rebuild APIs or use cURL. Tell your AI: `delete document ID 'doc-992a' from my Sales corpus`. It automatically formats the mutation and wipes the poisoned embedding from Vectara's nodes permanently, restoring high accuracy.

**Will the RAG Chat tool provide accurate source citations?**
Yes. When you instruct the agent to run `execute_rag_chat`, Vectara processes the query against its internal LLM and index, returning a synthesized natural language answer appended solidly with exact document citations, proving the AI isn't hallucinating facts.