Standalone Model Context Protocol (MCP) server for Amazon Bedrock Knowledge Base Retrieval
Project description
Amazon Bedrock Knowledge Base MCP Server
A powerful MCP server for querying Amazon Bedrock Knowledge Bases. Retrieve semantically relevant passages with metadata filtering, reranking, and multi-transport support.
Features
- Dual Transport - STDIO for Claude Desktop, Streamable HTTP for ChatGPT
- Smart Filtering - Schema-driven
whereconstraints + raw Bedrock filters + implicit filtering - Reranking - Optional AMAZON or COHERE reranking for improved relevance
- Auto Schema Discovery - Automatically infer metadata schemas from retrieval results
- OAuth Support - Auth0 integration for secure ChatGPT connections
- Read-Only - Safe by design; no write operations to your knowledge bases
Architecture
Quick Start
Claude Desktop (STDIO)
Add to your Claude Desktop config:
| Platform | Config Location |
|---|---|
| macOS | ~/Library/Application Support/Claude/claude_desktop_config.json |
| Windows | %APPDATA%/Claude/claude_desktop_config.json |
{
"mcpServers": {
"bedrock-kb": {
"command": "uvx",
"args": ["amazon-bedrock-knowledge-base-mcp"],
"env": {
"AWS_PROFILE": "your-profile",
"AWS_REGION": "us-west-2"
}
}
}
}
ChatGPT (Streamable HTTP)
AWS_PROFILE=your-profile \
AWS_REGION=us-west-2 \
MCP_TRANSPORT=streamable-http \
uvx amazon-bedrock-knowledge-base-mcp
Then configure ChatGPT to connect to https://your-domain.example.com/mcp.
Note: ChatGPT requires HTTPS. Use a tunnel (ngrok, Cloudflare Tunnel) for local testing.
Available Tools
Discovery Tools
| Tool | Description |
|---|---|
ListKnowledgeBases |
List available knowledge bases and their data sources. Filters by tag. |
DescribeMetadataSchema |
Show the resolved metadata schema for filtering (static or auto-discovered). |
Query Tools
| Tool | Description |
|---|---|
QueryKnowledgeBases |
Retrieve relevant passages. Content-focused, minimal output. |
QueryKnowledgeBasesWithMetadata |
Retrieve passages + full metadata. Ideal for exploration and filter tuning. |
Recommended Workflow
- List - Call
ListKnowledgeBasesto find available knowledge bases - Explore - Use
QueryKnowledgeBasesWithMetadatato discover metadata keys/values - Schema - Call
DescribeMetadataSchemato see available filter fields - Query - Use
QueryKnowledgeBaseswithwherefilters for precise retrieval
Environment Variables
AWS Configuration
| Variable | Required | Default | Description |
|---|---|---|---|
AWS_PROFILE |
Yes* | - | AWS profile name (recommended) |
AWS_REGION |
Yes* | - | AWS region (e.g., us-west-2) |
*Either AWS_PROFILE or IAM role credentials are required.
Knowledge Base Discovery
| Variable | Default | Description |
|---|---|---|
KB_INCLUSION_TAG_KEY |
mcp-multirag-kb |
Only include KBs tagged with <key>=true |
Retrieval Defaults
| Variable | Default | Description |
|---|---|---|
BEDROCK_KB_RERANKING_ENABLED |
false |
Enable reranking by default |
BEDROCK_KB_SEARCH_TYPE |
DEFAULT |
DEFAULT, HYBRID, or SEMANTIC |
Filtering
| Variable | Default | Description |
|---|---|---|
BEDROCK_KB_FILTER_MODE |
explicit_then_implicit |
How to combine explicit and implicit filters |
BEDROCK_KB_ALLOW_RAW_FILTER |
false |
Allow raw Bedrock RetrievalFilter passthrough |
BEDROCK_KB_SCHEMA_MAP_JSON |
- | Path to KB ID → schema-path mapping (JSON) |
BEDROCK_KB_SCHEMA_DEFAULT_PATH |
- | Default schema file path (JSON) |
BEDROCK_KB_IMPLICIT_FILTER_MODEL_ARN |
- | Model ARN for implicit filtering |
HTTP Server (Streamable HTTP only)
| Variable | Default | Description |
|---|---|---|
MCP_TRANSPORT |
stdio |
Transport mode: stdio, sse, or streamable-http |
MCP_HOST |
127.0.0.1 |
HTTP server bind address |
PORT |
8000 |
HTTP server port |
MCP_STATELESS |
true |
Stateless mode (recommended for production) |
MCP_ALLOWED_ORIGINS |
- | Comma-separated allowed CORS origins (* for any) |
MCP_ALLOWED_HOSTS |
- | Comma-separated allowed Host headers |
OAuth (Auth0)
| Variable | Required | Description |
|---|---|---|
MCP_AUTH_MODE |
No | Set to oauth to enable Auth0 authentication |
AUTH0_DOMAIN |
Yes* | Auth0 tenant domain (e.g., tenant.us.auth0.com) |
AUTH0_AUDIENCE |
Yes* | Auth0 API identifier / audience |
MCP_RESOURCE_URL |
Yes* | Public URL clients connect to |
*Required when MCP_AUTH_MODE=oauth
Logging
| Variable | Default | Description |
|---|---|---|
FASTMCP_LOG_LEVEL |
INFO |
Log level (DEBUG, INFO, WARNING, ERROR) |
Documentation
| Guide | Description |
|---|---|
| STDIO Setup | Claude Desktop and local development |
| Streamable HTTP | HTTP server setup and configuration |
| Server Setup | Deploy to production with nginx and SSL |
| ChatGPT Setup | Complete Auth0 OAuth setup for ChatGPT |
Docker
# Build the image
docker build -t amazon-bedrock-knowledge-base-mcp:local .
# Run with AWS credentials
docker run --rm \
-v "$HOME/.aws:/home/app/.aws:ro" \
-e AWS_PROFILE=your-profile \
-e AWS_REGION=us-west-2 \
amazon-bedrock-knowledge-base-mcp:local
# Run as HTTP server
docker run --rm \
-p 8000:8000 \
-v "$HOME/.aws:/home/app/.aws:ro" \
-e AWS_PROFILE=your-profile \
-e AWS_REGION=us-west-2 \
-e MCP_TRANSPORT=streamable-http \
-e MCP_HOST=0.0.0.0 \
amazon-bedrock-knowledge-base-mcp:local
Health Endpoints
| Endpoint | Description |
|---|---|
GET /health |
Basic health check (always returns 200 if running) |
GET /health/ready |
Readiness check (validates AWS credentials via STS) |
Development
# Clone and install
git clone https://github.com/Zlash65/amazon-bedrock-knowledge-base-mcp.git
cd amazon-bedrock-knowledge-base-mcp
uv sync --group dev
# Run tests
uv run pytest -q
# Type check
uv run pyright
# Lint
uv run ruff check .
# Format
uv run ruff format .
Metadata Schema
Schema files define available metadata fields for filtering. See schemas/README.md for examples.
Example schema:
{
"fields": [
{
"key": "x-amz-bedrock-kb-source-uri",
"type": "string",
"description": "Source document URI",
"alias": "source"
},
{
"key": "category",
"type": "string",
"description": "Document category",
"filterable": true
}
]
}
Use in queries:
# Using alias
{"where": {"source": "s3://bucket/doc.pdf"}}
# Using direct key
{"where": {"category": ["finance", "legal"]}}
Limitations
- Results with
IMAGEcontent type are not included in query responses - Reranking requires additional IAM permissions and is only available in specific regions
- Knowledge bases must be tagged with
KB_INCLUSION_TAG_KEY=trueto be discoverable
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file amazon_bedrock_knowledge_base_mcp-0.1.0.tar.gz.
File metadata
- Download URL: amazon_bedrock_knowledge_base_mcp-0.1.0.tar.gz
- Upload date:
- Size: 8.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8d11e91f9a751a18625b20e63922a1e344ec9bd2860da9994a7c1a0c43f5cdc
|
|
| MD5 |
89148020cd13d58a2075f52079ba2524
|
|
| BLAKE2b-256 |
42873eaec159dddd94d60b896e7f67e391610b87a033c0886732246d67e672fd
|
Provenance
The following attestation bundles were made for amazon_bedrock_knowledge_base_mcp-0.1.0.tar.gz:
Publisher:
release.yml on Zlash65/amazon-bedrock-knowledge-base-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
amazon_bedrock_knowledge_base_mcp-0.1.0.tar.gz -
Subject digest:
a8d11e91f9a751a18625b20e63922a1e344ec9bd2860da9994a7c1a0c43f5cdc - Sigstore transparency entry: 813275846
- Sigstore integration time:
-
Permalink:
Zlash65/amazon-bedrock-knowledge-base-mcp@428e229a4c3105727927b8a14a35808ff9bf69bf -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Zlash65
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@428e229a4c3105727927b8a14a35808ff9bf69bf -
Trigger Event:
push
-
Statement type:
File details
Details for the file amazon_bedrock_knowledge_base_mcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: amazon_bedrock_knowledge_base_mcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 37.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e8e9303033d7538ae8d87827d6765cd2a02bb3ba8c8f0ba71a7d0591d2e39b3
|
|
| MD5 |
64dbe3c2332dc9490651a88ccca4c3f2
|
|
| BLAKE2b-256 |
ba033f1b95402a9eeb989d5e86e483a7d61f47b9370e6a70c0f0ca36f586f2f8
|
Provenance
The following attestation bundles were made for amazon_bedrock_knowledge_base_mcp-0.1.0-py3-none-any.whl:
Publisher:
release.yml on Zlash65/amazon-bedrock-knowledge-base-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
amazon_bedrock_knowledge_base_mcp-0.1.0-py3-none-any.whl -
Subject digest:
1e8e9303033d7538ae8d87827d6765cd2a02bb3ba8c8f0ba71a7d0591d2e39b3 - Sigstore transparency entry: 813275847
- Sigstore integration time:
-
Permalink:
Zlash65/amazon-bedrock-knowledge-base-mcp@428e229a4c3105727927b8a14a35808ff9bf69bf -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Zlash65
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@428e229a4c3105727927b8a14a35808ff9bf69bf -
Trigger Event:
push
-
Statement type: