Overview
Mindset AI enables customers to host their own RAG (Retrieval-Augmented Generation) systems as MCP servers. This is particularly important for cases where clients have requirements not to let their intellectual property reside in external systems like Mindset AI’s infrastructure. RAG MCP servers are registered like other client MCP servers in the Mindset AI system, with a special server type designation indicating they provide RAG capabilities. The Model Context Protocol (MCP) is a standardized way to make tools and capabilities available to AI agents and systems. By implementing your RAG system as an MCP server, you’re creating a standard interface that Mindset AI’s agents can seamlessly interact with, just as they would with any other tool or service.Benefits of Implementing Your Own RAG MCP Server
- Control over storage: Your complete document corpus remains in your infrastructure; only relevant segments are shared per query
- Custom embedding models: Use your preferred embedding models and similarity algorithms optimized for your domain
- Existing infrastructure: Leverage your current vector databases, search systems, and document processing pipelines
- Access control: Apply your own security policies and user permissions at the source
- Performance optimization: Tune retrieval and reranking specifically for your use cases and data
rag_search
tool. Any other tools exposed by your RAG MCP server will be ignored at this time.
Required Tool Implementation
RAG MCP servers must expose at least the following tools: Tool Name:rag_search
(mandatory - exact name required)
Tool Description: Searches the knowledge base for relevant information using semantic search
Tool Parameters:
Request Format
The Mindset AI agent will send requests to the RAG MCP server using the standard MCP protocol:Key Points
Search Phrases: The Mindset AI agent generates 1-5 diverse search phrases:search_phrases[0]
always contains the user’s exact original input, unmodified- Additional phrases (if present) contain interpreted versions of the user’s query, incorporating conversational context at various levels of detail
- The client’s RAG system should embed all phrases using their own embedding algorithm and perform retrieval/reranking
- x-user-id: Contains the exact user identifier (externalUserId) provided during session registration via AgentSessions API
- x-session-tags: Contains the exact JSON array of tags provided when creating the agent session via the AgentSessions API. These are arbitrary strings that clients define for their own filtering/segmentation needs (e.g., “department:sales”, “SALES”, “region:north”, “Q4-2024”). Your RAG server can parse this JSON array and use these tags to filter search results according to your business logic.
- authorization: Your API key (provided during registration) will be included as:
Bearer YOUR_API_KEY
Implementing Access Control
Your RAG server should use thex-user-id
and x-session-tags
headers to filter search results according to your business logic. For example, you might:
- Restrict results based on user’s department or role (from session tags)
- Apply document-level permissions tied to the user ID
- Filter by time periods or access levels indicated in tags
- Combine multiple criteria for fine-grained access control
- Use tags for A/B testing or feature flags to control which document sets are searchable
Using Search Phrases
You’ll receive 1-5 phrases with specific structure:search_phrases[0]
: The user’s exact original query (unmodified)- Additional phrases (if present): Context-aware interpretations with varying specificity
- Embed all phrases using your embedding model (in parallel)
- Search with each phrase independently (in parallel)
- Combine and deduplicate results
- Apply your reranking strategy to the combined set
- Return the top-N most relevant segments
Response Format
The RAG MCP server must return results in the following format:Required Fields for Each Segment
- segment_uid: Unique identifier for the segment (required)
- source_file_name: Name of the source document (required)
- source_file_type: File type/extension (required)
- raw_text: The actual text content to be used by the LLM (required)
Optional Fields
- headline: A brief (up to 10 words) summary of the segment text. Used for citations and source card titles. Fallback behavior: If omitted, Mindset AI will attempt to extract the first sentence from raw_text using basic punctuation rules. For best results with technical content, structured data, or multi-language text, we recommend providing this field.
- segment_summary: A longer description of the segment content (1-3 sentences). Used in source card previews and citation pop-ups to give users more context. Fallback behavior: If omitted, Mindset AI will attempt to extract the second and third sentences from raw_text using basic punctuation rules. For best results with technical content, structured data, or multi-language text, we recommend providing this field.
- source_url: URL to access the source document. This is the sole mechanism for users to view original sources when they click on citations or source cards in the agent output. While optional, providing this field enables users to verify and explore the full context of cited information. For audio/video content, consider deep-linking to the specific timestamp where the segment begins. Assuming that the user is already logged in to the host site, this URL can be a link to a suitable host page for the content - allowing the host site to seamlessly identify and validate the user’s access to the content and use all the existing content player or viewer UI (with all the associated functionality that comes with that). If that is not possible then more restricted URLs containing their own keys or time limited signed access could be used.
Error Handling
For errors, return standard JSON-RPC error format with appropriate error codes:- -32700: Parse error (invalid JSON) - like HTTP 400
- -32600: Invalid request - like HTTP 400
- -32601: Method not found - like HTTP 404 but for methods
- -32602: Invalid params - like HTTP 400
- -32603: Internal error - like HTTP 500
- -32000 to -32099: Server-defined errors (your custom business logic)
Testing Your RAG MCP Server
You can test your RAG MCP server implementation using curl or any HTTP client. Here’s an example request that mimics how Mindset AI will call your server:Upcoming Optional Tool: verify_document_access
Overview
This optional tool will address a key limitation with source document access: URLs to source documents may become stale over time due to expired authentication tokens, changed permissions, or document reorganization.The Problem
When users click on source cards or citations in conversation threads (both current and historical), the external URLs may fail due to:- Expired tokens: URLs with embedded authentication tokens (e.g., ?token=abc123&expires=…) will fail when tokens expire
- Permission changes: If access to a document is revoked, URLs will return 403 Forbidden errors
- Document moves: If documents are reorganized, URLs pointing to old paths will return 404 Not Found errors
- Session-based access: URLs that rely on active user sessions may fail when reopened later
The Solution
Theverify_document_access
tool will allow Mindset AI to verify that a user still has access to a document and optionally receive a refreshed URL for the document.
When Called: This tool will be invoked every time a user clicks on a source card or citation in any conversation (current or historical). Mindset AI takes no chances when it comes to verifying access permissions - all clicks will trigger real-time verification.
Tool Purpose:
- Primary: Verify that the user currently has permission to access the document
- Secondary: Optionally provide a refreshed URL with new authentication tokens/credentials
Tool Specification
Tool Name:verify_document_access
Tool Description: Will verify user access to a document and optionally provide a refreshed URL with current credentials
- x-user-id: Current user identifier (may differ from original query if shared)
- x-session-tags: Current session tags (may differ from original session)
- x-human-uid: Mindset AI internal user identifier
- authorization: Your API key as Bearer YOUR_API_KEY
- has_access (boolean, required): Whether the current user can access this document
- refreshed_url (string, optional): New URL with fresh credentials. If omitted, the original URL will be reused.
- access_level (string, optional): User’s permission level (e.g., “view”, “edit”, “admin”)
- error (string, optional): Human-readable error message if access is denied
Benefits of Implementation
For Users:- ✅ Source links will continue to work indefinitely across all conversations
- ✅ Real-time permission checks will prevent access to documents they no longer have rights to
- ✅ Seamless experience when clicking on sources or citations at any time
- ✅ Full control over access verification logic
- ✅ Generate fresh tokens on-demand rather than storing long-lived credentials
- ✅ Audit trail of all document access attempts from Mindset AI conversations
- ✅ Opportunity to handle document moves/renames gracefully
Implementation Considerations
- Performance: This tool will be called every time users click on sources or citations, so response time will be critical
- Caching: Consider caching verification results briefly (e.g., 5 minutes) to reduce load from repeated clicks
- Graceful Degradation: If this tool is not implemented, Mindset AI will use the original URL (which may be stale)
- Security: Use the current user context from headers to validate access, not cached permissions