Skip to main content
Glama
claude-bedrock-mcp-server

claude-bedrock-mcp-server

by Code-Ninety

Claude on AWS Bedrock MCP Server

CI License: MIT Python 3.10+

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) and bedrock-agent-runtime (retrieve) with bounded nextToken pagination (BEDROCK_MAX_PAGES), cyclic cursor detection, and exponential backoff on ThrottlingException, ServiceUnavailableException, and ModelTimeoutException.

  • Pre-Flight Decimal USD Cost Control: Computes worst-case call spend using decimal.Decimal across Claude Opus 4, Sonnet 4, 3.7/3.5 Sonnet, and 3.5/3 Haiku (including us., eu., apac., and global. inference profiles), failing closed with BedrockBudgetError before calling AWS if BEDROCK_MAX_SESSION_USD would 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 delegates INPUT and OUTPUT checks to AWS Bedrock Guardrails.

  • Bounded Zero-PII Audit Log: Stores SHA-256 parameter digests and Decimal cost totals in a collections.deque(maxlen=1000) and emits structured JSON telemetry to stderr without 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 via bedrock-rag-eval.

Exposed MCP Tools

Tool Name

Purpose

Key Controls

bedrock_retrieve_knowledge

Paginated Knowledge Base retrieval

BEDROCK_MAX_PAGES cap, cyclic cursor check, chunk PII redaction

bedrock_converse_claude

Governed Claude on Bedrock invocation

Prompt-injection block, pre-flight Decimal budget gate, output redaction

bedrock_grounded_rag

Retrieve -> cite -> Claude -> score pipeline

Inline [cite:CHUNK_ID] prompting + automatic EvalReport

bedrock_evaluate_rag_response

Standalone citation & faithfulness scorer

Flags hallucinated citations and unsupported claims

bedrock_get_budget_status

Live FinOps & audit snapshot

Returns Decimal USD totals and bounded SHA-256 audit history

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-server

For 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-server

MCP 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 \
  --json

Each 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 / RetrieveAndGenerate

Governed MCP Middleware (claude-bedrock-mcp-server)

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 Decimal session USD cap failing closed before API calls

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 FaithfulnessEvaluator + bedrock-rag-eval CLI gate for pull requests

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

Built by Code Ninety. Licensed under MIT.

Available Tools

5 tools
bedrock_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

    A3.5/5.0

    Scored across 5 tools

    Disambiguation4/5

    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.

    Naming Consistency4/5

    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.

    Tool Count5/5

    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.

    Completeness4/5

    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

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      C
      quality
      D
      maintenance
      A 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.
      3
      296
      ISC
    • A
      license
      C
      quality
      D
      maintenance
      A 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.
      28
      3
      MIT