bedrock-kb-mcp-server

bedrock-kb-mcp-server

Enables AI assistants to query documents in a Bedrock Knowledge Base through the MCP protocol, with tools for semantic search and agentic retrieval.

Category
访问服务器

README

Bedrock Managed Knowledge Base with AgentCore MCP Gateway

A CDK project that deploys a fully managed Amazon Bedrock Knowledge Base backed by S3, exposed as an MCP server via AgentCore Gateway. This allows AI assistants like Claude Code and Kiro to query your documents through the standard MCP protocol.

Architecture

┌─────────────┐     ┌───────────────────────┐     ┌──────────────────────┐
│  S3 Bucket  │────▶│  Managed Knowledge    │────▶│  AgentCore Gateway   │
│  (Documents)│     │  Base (Bedrock)        │     │  (MCP Server)        │
└─────────────┘     │  - Managed embeddings │     │  - Retrieve          │
                    │  - Managed vector store│     │  - AgenticRetrieve   │
                    │  - Managed reranker    │     │    Stream             │
                    └───────────────────────┘     └──────────┬───────────┘
                                                             │
                                                    AWS IAM (SigV4)
                                                             │
                                                 ┌───────────┴───────────┐
                                                 │   MCP Clients         │
                                                 │   (Claude Code, Kiro) │
                                                 └───────────────────────┘

Project Structure

bedrock_kb/
├── app.py                  # CDK app entry point
├── cdk.json                # CDK configuration
├── pyproject.toml          # Python project (managed by uv)
├── .mcp.json.example       # MCP server config template for Claude Code
├── bedrock_kb/
│   ├── __init__.py
│   └── stack.py            # CDK stack definition
├── tests/
│   ├── __init__.py
│   └── test_stack.py       # Infrastructure tests
└── scripts/
    └── sync_and_ingest.sh  # Upload docs & trigger ingestion

Prerequisites

  • Python 3.13+
  • uv (Python package manager)
  • AWS CDK CLI (npm install -g aws-cdk)
  • AWS credentials configured (aws configure)

Deploy

# 1. Bootstrap CDK (one-time per account/region)
cdk bootstrap aws://<ACCOUNT_ID>/us-east-1

# 2. Deploy the stack
uv run cdk deploy --context account=<ACCOUNT_ID> --context region=us-east-1

Note the outputs after deployment:

  • BucketName — where to upload your documents
  • KnowledgeBaseId — the Bedrock KB identifier
  • GatewayUrl — the MCP server endpoint
  • GatewayIdentifier — the gateway ID

Upload Documents and Trigger Ingestion

Place your documents (PDF, TXT, MD, HTML, DOCX, CSV) in a local directory, then:

./scripts/sync_and_ingest.sh ./my-docs/

This syncs files to S3 and starts a Bedrock ingestion job. Monitor progress:

aws bedrock-agent get-ingestion-job \
  --knowledge-base-id <KB_ID> \
  --data-source-id <DS_ID> \
  --ingestion-job-id <JOB_ID>

Adding metadata for filtering

You can attach metadata to any document by placing a .metadata.json companion file next to it in S3. The metadata file must be named exactly <filename>.metadata.json and sit in the same directory. This enables filtering search results by custom attributes like department, document type, or date.

Folder structure:

my-docs/
├── compliance/
│   ├── company-policy.pdf
│   └── company-policy.pdf.metadata.json
└── technical/
    ├── architecture-guide.md
    └── architecture-guide.md.metadata.json

Metadata file format (company-policy.pdf.metadata.json):

{
  "metadataAttributes": {
    "department": "HR",
    "document_type": "Policy",
    "year": "2026",
    "public": "false"
  }
}

The metadataAttributes object contains key-value pairs that Bedrock indexes alongside the document content. When querying via the Retrieve tool, you can filter results using these attributes (e.g., only return documents where department = "Engineering").

Connect Claude Code

AgentCore Gateway requires AWS SigV4-signed requests (service bedrock-agentcore). Since Claude Code doesn't natively sign MCP requests with AWS credentials, we use mcp-proxy-for-aws — an AWS-provided stdio MCP proxy that:

  1. Receives MCP requests from Claude Code over stdin/stdout
  2. Signs them with your local AWS credentials (from ~/.aws/credentials, env vars, or SSO)
  3. Forwards them to the AgentCore Gateway over HTTPS
  4. Streams responses back to Claude Code

Option A: use it from anywhere (recommended)

Your knowledge base isn't tied to this repo, so register the MCP server at user scope — it becomes available in every project, not just this one. Use uvx (not uv run) so the proxy runs standalone without needing this project's venv:

claude mcp add bedrock-kb --scope user -- uvx mcp-proxy-for-aws https://<GATEWAY_URL>/mcp --region us-east-1

Replace <GATEWAY_URL> with the GatewayUrl output from your deploy. This is stored in your global Claude config (~/.claude.json), so re-run the command (it overwrites) any time you redeploy and the Gateway URL changes.

Option B: scope it to this project only

Copy the included .mcp.json.example template to .mcp.json and fill in the GatewayUrl output:

cp .mcp.json.example .mcp.json
# then edit .mcp.json, replacing <GATEWAY_URL> with the GatewayUrl output value

.mcp.json is gitignored since it embeds an account/region-specific endpoint. With this option Claude Code only loads the server when run inside this directory, and you'll need to approve the bedrock-kb MCP server when prompted.

IAM permissions for the caller

Your IAM identity (user or role) needs permission to invoke the gateway:

{
  "Effect": "Allow",
  "Action": "bedrock-agentcore:InvokeGateway",
  "Resource": "arn:aws:bedrock-agentcore:us-east-1:<ACCOUNT>:gateway/<GATEWAY_ID>"
}

Exposed MCP Tools

Once connected, your MCP client will have access to two tools:

Tool Description
Retrieve Simple semantic search — returns relevant document chunks
AgenticRetrieveStream Advanced multi-hop reasoning with managed reranking — recursively decomposes complex queries

Run Tests

uv run pytest tests/ -v

Destroy

uv run cdk destroy --context account=<ACCOUNT_ID> --context region=us-east-1

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选