ranger-rag-mcp
Provides integration with Apache Ranger to enforce authorization policies on RAG knowledge base queries, checking user permissions before forwarding requests to the RAG system.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@ranger-rag-mcpAs user 'alice', query the 'Finance KB' knowledge base: What was Q3 revenue?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Ranger RAG MCP Server
MCP server that integrates Apache Ranger authorization with RAG (Retrieval Augmented Generation). When a user queries a knowledge base, the server first checks Ranger policies to verify the user has permission — if denied, the query is rejected before reaching the RAG system.
Architecture
User (AI Agent) ──→ MCP Server ──→ Ranger Policy Check ──→ RAG Studio
│
DENY → "Access Denied"
ALLOW → Forward query, return resultsRelated MCP server: ToolBridge
Features
Per-knowledge-base authorization — Ranger policies control which users can access which knowledge bases
Transparent enforcement — denied queries never reach the RAG system
Policy-based access control — uses existing Ranger infrastructure (policies, users, groups)
Automatic retries — exponential backoff on transient errors
Fallback evaluation — if Ranger's evaluateOnce API isn't available, evaluates policies locally
MCP Tools
Tool | Description |
| Query a KB with Ranger auth check |
| List KBs the user can access |
| Pre-flight permission check |
| Show all RAG Ranger policies (admin) |
Setup
1. Create a Ranger Service for RAG
In Ranger Admin, create a new service (or use an existing custom service type) with:
Service Name:
ragResource:
knowledge_base(string, supports wildcards)Access Types:
read,write
2. Create Ranger Policies
Example policies:
Policy Name | Resource | Users | Access |
Finance KB - Analysts |
| alice, bob | read |
HR KB - HR Team |
| charlie | read |
All KBs - Admin |
| admin | read, write |
3. Install and Configure
git clone <repo-url>
cd ranger-rag-mcp
python3 -m venv .venv
source .venv/bin/activate
pip install -e .Copy .env.example to .env and fill in your values:
cp .env.example .env
# Edit .env with your Ranger and RAG Studio credentials4. Configure MCP Client
Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"ranger-rag-mcp-server": {
"command": "/FULL/PATH/TO/ranger-rag-mcp/.venv/bin/python",
"args": ["-m", "ranger_rag_mcp_server.server"],
"env": {
"RANGER_GATEWAY_URL": "https://<gateway>/<topology>/cdp-proxy-api/ranger/",
"RANGER_USER": "<workload_username>",
"RANGER_PASS": "<workload_password>",
"RANGER_SERVICE_NAME": "rag",
"RAG_STUDIO_URL": "https://<rag-studio-url>",
"RAG_STUDIO_API_KEY": "<api_key>"
}
}
}
}Agent Studio / Kiro:
{
"mcpServers": {
"ranger-rag-mcp-server": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/<your-org>/ranger-rag-mcp@main",
"run-server"
],
"env": {
"RANGER_GATEWAY_URL": "https://<gateway>/<topology>/cdp-proxy-api/ranger/",
"RANGER_USER": "<workload_username>",
"RANGER_PASS": "<workload_password>",
"RANGER_SERVICE_NAME": "rag",
"RAG_STUDIO_URL": "https://<rag-studio-url>",
"RAG_STUDIO_API_KEY": "<api_key>"
}
}
}
}Configuration
Ranger
Variable | Required | Description |
| Yes | Ranger Admin REST API URL via Knox |
| Yes | Workload username for Ranger API auth |
| Yes | Workload password for Ranger API auth |
| No | Ranger service name (default: |
RAG Studio
Variable | Required | Description |
| Yes | RAG Studio base URL |
| Yes | RAG Studio API key |
| No | Project ID (default: 1) |
| No | Number of chunks to retrieve (default: 5) |
| No | LLM model for response generation |
TLS/HTTP
Variable | Default | Description |
|
| Set |
| — | Path to CA certificate bundle |
|
| Request timeout in seconds |
Example Usage
Once configured, ask the AI:
# User with access → gets results
"As user 'alice', query the 'Finance KB' knowledge base: What was Q3 revenue?"
# User without access → gets denied
"As user 'bob', query the 'HR Policies' knowledge base: What is the PTO policy?"
# Check what a user can access
"List all knowledge bases that user 'alice' can access"
# Admin: see all policies
"Show me all the RAG access policies"How It Works
User calls
query_knowledge_base(user="alice", knowledge_base="Finance KB", query="...")MCP server calls Ranger:
POST /service/plugins/policies/evaluateOnce— "Can alice read Finance KB?"Ranger evaluates policies:
Checks all enabled policies for the
ragserviceLooks for policies where resource
knowledge_basematches "Finance KB"Checks if user "alice" or any of her groups appear in
policyItemswithreadaccess
If ALLOWED: Forward query to RAG Studio, return answer
If DENIED: Return
ACCESS_DENIEDwith reason — RAG Studio is never contacted
Ranger Policy Structure
The server expects Ranger policies with this structure:
{
"service": "rag",
"name": "Finance KB Access",
"isEnabled": true,
"resources": {
"knowledge_base": {
"values": ["Finance KB"],
"isRecursive": false
}
},
"policyItems": [
{
"users": ["alice", "bob"],
"groups": ["finance-team"],
"accesses": [
{"type": "read", "isAllowed": true}
]
}
]
}License
Apache License 2.0
Available Tools
4 toolscheck_accessA
Check if a user has access to a specific knowledge base without querying it.
Useful for pre-flight permission checks before attempting a query.
Args: user: Username to check permissions for. knowledge_base: Name of the knowledge base. access_type: Type of access to check ('read' or 'write'). Default: 'read'.
Returns: Access decision with policy details.
| Name | Required | Description | Default |
|---|---|---|---|
| user | Yes | ||
| access_type | No | read | |
| knowledge_base | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description must carry full behavioral disclosure. It discloses that the tool does not query the knowledge base, which is a key behavioral trait. However, it does not state whether it modifies anything, requires special permissions, or how policy decisions are derived. It only says 'Returns: Access decision with policy details,' which is minimal.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a compact docstring with a purpose sentence, a usage note, and structured Args/Returns sections. Each part adds necessary information and nothing is redundant. It is front-loaded with the core purpose before diving into details.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple access check tool, the description covers what, when, parameters, and return value. It does not mention edge cases like unknown users, unconfigured policies, or differences between the check and actual query behavior. However, the output schema exists to formalize return structure, so the description is adequate.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has zero description coverage, but the description includes an Args section explaining each parameter in plain language. It specifies that access_type accepts 'read' or 'write' and defaults to 'read', which is not discernible from the schema alone. This fully compensates for the schema gap.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description opens with 'Check if a user has access to a specific knowledge base without querying it,' using a specific verb and resource. The phrase 'without querying it' clearly distinguishes it from sibling query_knowledge_base. This is a strong, specific purpose statement.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
It explicitly states 'Useful for pre-flight permission checks before attempting a query,' which provides clear usage context. It doesn't name alternatives or exclusions, but the scenario is clearly defined. Sibling tools are listed but not explicitly compared.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_knowledge_basesA
List all knowledge bases the user has access to.
Checks Ranger authorization for each knowledge base and returns only those the user is permitted to query.
Args: user: Username to check permissions for.
Returns: List of accessible knowledge bases with their details.
| Name | Required | Description | Default |
|---|---|---|---|
| user | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description must carry the burden. It explicitly discloses that it checks Ranger authorization and returns only permitted KBs, which is a key behavioral trait. It does not detail failure modes or pagination, but for a read-only list operation this is adequate.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is compact and well-structured, with a clear purpose statement, a brief authorization note, and Args/Returns sections. Every sentence adds value, and there is no unnecessary repetition.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given that the tool has one parameter, a clear purpose, and an output schema (per context signals), the description fully enables an agent to select and invoke it correctly. It does not need to elaborate further on return values or error handling.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has zero description coverage for the 'user' parameter. The description compensates by specifying 'user: Username to check permissions for,' clarifying its purpose and type. This is sufficient for a single simple parameter.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states 'List all knowledge bases the user has access to,' which is a specific verb (list) plus resource (knowledge bases) with a scope (user access). This distinguishes it from siblings like query_knowledge_base and list_policies by focusing on the set of accessible KBs rather than querying content or listing policies.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies the tool is for discovering KBs a user can query, and the mention of Ranger authorization gives clear context. However, it does not explicitly name alternative tools or state when not to use it, so it falls short of a full 5.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_policiesA
List all Ranger policies for the RAG service.
Shows which users/groups have access to which knowledge bases. Useful for administrators to understand the current access control setup.
Returns: List of policies with their resource definitions and access rules.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden for behavioral disclosure. It clearly describes the output (list of policies with resource definitions and access rules) but does not mention any access requirements, side effects, or limitations beyond the return value. It is a read-only operation by implication but not explicitly stated.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is concise and front-loaded, with the main action stated in the first line. The 'Returns:' section adds useful detail without redundancy or unnecessary length. Every sentence contributes value.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool has no parameters and an output schema exists, the description provides sufficient context for a simple list operation. It describes the return format and the intended audience, though it could have explicitly stated its relationship to sibling tools for more complete context.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool has zero parameters, and the description correctly adds no parameter-specific information. Per the rubric, a baseline score of 4 is appropriate for 0 parameters, as there is nothing to describe beyond the schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states 'List all Ranger policies for the RAG service' with a specific verb and resource. It further explains the purpose as showing access mappings, which distinguishes it from sibling tools like list_knowledge_bases and check_access.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description says 'Useful for administrators to understand the current access control setup,' which provides clear context for when to use the tool. However, it does not explicitly exclude alternatives or state when not to use it, so it lacks explicit comparisons to sibling tools.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
query_knowledge_baseA
Query a RAG knowledge base with Ranger authorization check.
First checks Apache Ranger to verify the user has 'read' access to the specified knowledge base. If allowed, forwards the query to RAG Studio and returns the answer. If denied, returns an access denied message.
Args: user: Username to check permissions for (e.g., 'alice', 'bob'). knowledge_base: Name of the knowledge base to query (e.g., 'Finance KB', 'HR Policies'). query: The question to ask the knowledge base.
Returns: If authorized: The RAG response with answer and sources. If denied: An access denied message with the reason.
| Name | Required | Description | Default |
|---|---|---|---|
| user | Yes | ||
| query | Yes | ||
| knowledge_base | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description fully discloses behavior: it checks Ranger read access, conditionally forwards to RAG Studio, returns an access denied message on failure, and describes the return values for both paths. This is rich and transparent.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured with an intro, a flow explanation, and clearly labeled Args and Returns sections. Each sentence adds valuable information, and the length is appropriate for the tool's complexity.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The description fully covers the tool's purpose, authorization flow, parameters, and return values. Given the absence of annotations and the complexity involving RAG and Ranger, this description is complete and self-sufficient.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The description includes an Args section that explains each parameter with examples (user, knowledge_base, query), adding meaningful semantics beyond the bare input schema. It even outlines the return behavior based on authorization, which ties to parameters.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific verb ('Query') and resource ('RAG knowledge base'), and distinguishes itself from siblings by explicitly mentioning the Ranger authorization check. It clearly communicates the core action and scope.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description clearly explains the tool's context: it performs an authorization check before querying, and describes authorization flow. It does not explicitly mention when to use this tool instead of siblings like check_access, but it provides sufficient context for an agent to decide.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
4 tool updates
v0.1.0- First observed
check_access - First observed
list_knowledge_bases - First observed
list_policies - First observed
query_knowledge_base
TDQS
Scored across 4 tools
Each tool has a clearly distinct purpose: querying a KB, listing accessible KBs, checking access pre-flight, and listing all policies. There is no meaningful overlap that would cause confusion, as even the access check in query is incidental to its primary function.
All tool names follow a consistent verb_noun snake_case pattern (query_knowledge_base, list_knowledge_bases, check_access, list_policies). The two 'list' verbs are used consistently with different objects, and there are no mixed conventions.
Four tools is a well-scoped count for a RAG query service with authorization checks. Each tool covers a necessary function without redundancy, fitting the typical 3-15 range comfortably.
The core workflows of querying, listing accessible bases, pre-flight access checks, and viewing policies are covered. Minor gaps exist such as no policy management or write operations, but these are likely out of scope for a read-oriented query server.
Maintenance
Related MCP Connectors
MCP server unifying ERPs, CRMs, APIs and knowledge base for Claude, ChatGPT and Gemini.
- gatewayOAuthai.sealgate
MCP gateway with runtime security policy, tool-call-level control, and audit of agent actions.
AI governance MCP server for EU AI Act compliance and jurisdiction verification
The CustomGPT.ai MCP server is a fully managed, RAG-powered endpoint that connects large language models with private knowledge bases and external data sources. It provides tools for retrieval-augmented generation queries (send_message), data ingestion (upload_file), and source listing, enabling AI agents to query private documents like PDFs with high accuracy and real-time citations.
Related MCP Servers
- AlicenseBqualityAmaintenanceA production-grade MCP server for integrating RAG into AI agents, supporting multiple vector databases with enterprise security and dynamic tool selection.215MIT
- FlicenseNot gradedqualityDmaintenanceA governed MCP server for integrating AI agents with customer data, featuring role-based access control, field redaction, and human-in-the-loop approval for secure support operations.1-
- AlicenseNot gradedqualityCmaintenanceAn MCP server that enforces runtime governance on AI agent actions — file access, command execution, delegation chains, and permission escalation.MIT
- FlicenseNot gradedqualityBmaintenanceMCP server for a modular RAG system that enables natural language question answering over enterprise documents with intent-aware routing, adaptive retrieval, and citation-backed responses.-