claude-bedrock-mcp-server
Provides governed access to Amazon Bedrock Runtime and Agent Runtime, enabling Claude converse calls, guardrail application, Knowledge Base retrieval, budget enforcement, and RAG evaluation.
Claude on AWS Bedrock MCP Server
Open-source reference architecture and Model Context Protocol (MCP) server for governing Anthropic Claude models on AWS Bedrock (converse, apply_guardrail, and Knowledge Bases retrieve), paired with a deterministic citation-grounded RAG evaluation CLI (bedrock-rag-eval).
Architecture
flowchart LR
Client["MCP Host (Claude Desktop / IDE / Agent)"] --> Server["MCPServer (stdio)"]
Server --> Guard["GuardrailEnforcer (PII Redaction + Injection Block)"]
Guard --> Budget["BudgetLedger (Pre-flight Decimal USD Cap)"]
Budget --> Gateway["BedrockGateway (Retries + Bounded Pagination)"]
Gateway -->|BEDROCK_MODE=sandbox| Sandbox["Deterministic Finance/Compliance KB Sandbox"]
Gateway -->|BEDROCK_MODE=live| AWS["AWS Bedrock Runtime & Agent Runtime"]
Gateway --> Eval["FaithfulnessEvaluator (Citation & Overlap Gate)"]
Server --> Audit["AuditLogger (Bounded Deque + SHA-256 JSON)"]Related MCP server: AWS Resources MCP Server
Capabilities
Exact AWS Bedrock Contracts: Typed protocols for
bedrock-runtime(converse,apply_guardrail) andbedrock-agent-runtime(retrieve) with boundednextTokenpagination (BEDROCK_MAX_PAGES), cyclic cursor detection, and exponential backoff onThrottlingException,ServiceUnavailableException, andModelTimeoutException.Pre-Flight
DecimalUSD Cost Control: Computes worst-case call spend usingdecimal.Decimalacross Claude Opus 4, Sonnet 4, 3.7/3.5 Sonnet, and 3.5/3 Haiku (includingus.,eu.,apac., andglobal.inference profiles), failing closed withBedrockBudgetErrorbefore calling AWS ifBEDROCK_MAX_SESSION_USDwould be exceeded.Dual-Layer Guardrails & PII Redaction: Recursively masks AWS access keys (
AKIA.../ASIA...), IBANs, SSNs, CNICs, emails, and phone numbers; blocks prompt-injection signatures locally; and optionally delegatesINPUTandOUTPUTchecks to AWS Bedrock Guardrails.Bounded Zero-PII Audit Log: Stores SHA-256 parameter digests and
Decimalcost totals in acollections.deque(maxlen=1000)and emits structured JSON telemetry tostderrwithout logging raw prompts.Citation-Grounded RAG Evaluation: Verifies
[cite:CHUNK_ID]references against retrieved chunks, rejects hallucinated citations, measures claim-level token grounding, and exposes a CI exit-code gate viabedrock-rag-eval.
Exposed MCP Tools
Tool Name | Purpose | Key Controls |
| Paginated Knowledge Base retrieval |
|
| Governed Claude on Bedrock invocation | Prompt-injection block, pre-flight |
| Retrieve -> cite -> Claude -> score pipeline | Inline |
| Standalone citation & faithfulness scorer | Flags hallucinated citations and unsupported claims |
| Live FinOps & audit snapshot | Returns |
Quickstart (30-Second Zero-Credential Sandbox)
Run the server and RAG evaluation suite locally with zero AWS credentials:
pip install claude-bedrock-mcp-server
bedrock-rag-eval --dataset examples/golden_eval_set.jsonl
claude-bedrock-mcp-serverFor live AWS Bedrock execution, install the [aws] extra and configure environment variables:
pip install "claude-bedrock-mcp-server[aws]"
export BEDROCK_MODE=live
export AWS_REGION=us-east-1
export BEDROCK_KNOWLEDGE_BASE_ID=YOUR10CHARID
export BEDROCK_MODEL_ID=us.anthropic.claude-sonnet-4-20250514-v1:0
export BEDROCK_MAX_SESSION_USD=5.00
claude-bedrock-mcp-serverMCP Client Configuration (claude_desktop_config.json)
{
"mcpServers": {
"claude-bedrock": {
"command": "claude-bedrock-mcp-server",
"env": {
"BEDROCK_MODE": "sandbox",
"BEDROCK_MAX_SESSION_USD": "5.00"
}
}
}
}CI RAG Evaluation Gate (bedrock-rag-eval)
Run the golden JSONL dataset in CI pipelines to fail builds (exit 1) on citation hallucinations or faithfulness regressions:
bedrock-rag-eval \
--dataset examples/golden_eval_set.jsonl \
--min-faithfulness 0.70 \
--min-coverage 0.80 \
--jsonEach JSONL row supports either precomputed evaluation (answer + chunks) or end-to-end RAG execution (query), with expected_pass (true/false) to keep both positive grounding cases and negative hallucination traps under regression control.
AWS Bedrock Native Agents & Knowledge Bases vs. Governed MCP Middleware
AWS provides managed Amazon Bedrock Agents and Bedrock Knowledge Bases (RetrieveAndGenerate) out of the box. Choose the right layer for your architecture:
Dimension | Native AWS Bedrock Agents / | Governed MCP Middleware ( |
Best fit | AWS-native workflows orchestrated wholly inside Bedrock console/SDKs | IDE assistants, Claude Desktop, and multi-system MCP hosts needing portable tools |
Cost governance | Account-level AWS Budgets & CloudWatch alarms (reactive) | Synchronous pre-flight |
PII & secret masking | Managed Bedrock Guardrails regex/PII filters | Deterministic local redaction (AWS keys, IBAN, CNIC, SSN) + optional AWS Guardrails |
RAG verification | Managed citations without built-in CI regression exit gates | Deterministic |
Local dev / CI | Requires live AWS IAM credentials and provisioned KB/OpenSearch resources | Zero-credential deterministic sandbox mode for 30-second local and CI verification |
If your workloads live entirely inside AWS Step Functions or Bedrock Agents and only need AWS-native IAM and Guardrails, use the managed AWS services directly. Use this middleware when MCP clients invoke Claude on Bedrock across developer workstations or regulated enterprise pipelines that require pre-flight Decimal budget caps, local secret redaction, and automated CI faithfulness gates.
Architecture Decisions & Security
ADR-001: Protocol-Typed AWS Bedrock Gateway and Lazy boto3 Loading
ADR-002: Pre-Flight Decimal FinOps Budget Caps and Bounded Audit Logging
ADR-003: Deterministic Citation-Grounded RAG Faithfulness Gate
Built by Code Ninety. Licensed under MIT.
Available Tools
5 toolsbedrock_converse_claudeB
Invoke Claude on AWS Bedrock Converse with pre-flight Decimal USD budget enforcement, PII redaction, and optional Bedrock Guardrails.
Inputs: prompt (required), model_id, max_tokens, temperature, +1 more. Returns: object
bedrock_evaluate_rag_responseA
Evaluate an answer for hallucinated citations and claim-level lexical grounding against retrieved context chunks.
Inputs: answer (required), chunks (required). Returns: object
bedrock_get_budget_statusB
Return current Decimal USD session spend, remaining budget, token totals, and recent bounded audit summary.
Inputs: audit_limit. Returns: object
bedrock_grounded_ragB
Run end-to-end governed RAG: retrieve chunks, invoke Claude with inline citations, and score response faithfulness automatically.
Inputs: query (required), top_k, model_id, knowledge_base_id. Returns: object
bedrock_retrieve_knowledgeB
Retrieve AWS Bedrock Knowledge Base chunks with bounded pagination and PII redaction.
Inputs: query (required), top_k, knowledge_base_id. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool targets a distinct layer: raw retrieval, raw model invocation, an end-to-end RAG pipeline, an offline-style evaluator, and budget introspection. The only real overlap is that bedrock_grounded_rag internally does what bedrock_retrieve_knowledge and bedrock_converse_claude do, so an agent must decide between primitive and composite paths; descriptions do clarify this but not perfectly.
All five names use a uniform bedrock_ prefix and snake_case, which makes the set immediately recognizable. Minor deviation: retrieve_knowledge/get_budget_status follow verb_noun cleanly, while grounded_rag is adjective_noun and converse_claude uses an unusual verb.
Five tools is well-scoped for a Bedrock RAG/inference server: retrieve, invoke, orchestrate, evaluate, and monitor. Each tool has a clear reason to exist and no tool feels like filler.
The core lifecycle (retrieve, generate, orchestrate with citations, evaluate grounding, inspect budget) is fully covered with no dead ends for the main workflow. Gaps are minor: no knowledge-base discovery/listing, no budget reset or configuration, and no guardrail listing, but agents can work around these.
Maintenance
Related MCP Connectors
MCP server unifying ERPs, CRMs, APIs and knowledge base for Claude, ChatGPT and Gemini.
Hosted MCP server for LLM cost estimation, model comparison, and budget-aware routing.
Hosted Amazon Seller and Vendor MCP server for Claude, ChatGPT, Cursor, Codex, Gemini, Copilot.
LLM cost optimization gateway, repo token-waste auditor & model arbitrage MCP server.
Related MCP Servers
- AlicenseCqualityDmaintenanceA Model Context Protocol (MCP) server that enables AI assistants like Claude to interact with your AWS environment. This allows for natural language querying and management of your AWS resources during conversations. Think of better Amazon Q alternative.3296ISC
- AlicenseBqualityDmaintenanceA Model Context Protocol server that enables Claude to execute Python code using boto3 to query and manage AWS resources directly from conversations.124MIT
- AlicenseCqualityDmaintenanceA Model Context Protocol (MCP) server that connects GraphDB's SPARQL endpoints and Ollama models to Claude, enabling Claude to query and manipulate ontology data while leveraging various AI models.283MIT
- AlicenseNot gradedqualityDmaintenanceEnterprise-grade MCP server integrating Claude AI capabilities, enabling AI-powered conversations, file operations, and system tools via the Model Context Protocol.1Apache 2.0