Amazon Bedrock 知识库检索
STDIO亚马逊Bedrock知识库检索MCP服务器
亚马逊Bedrock知识库检索MCP服务器
MCP server for accessing Amazon Bedrock Knowledge Bases
uv from Astral or the GitHub READMEuv python install 3.10mcp-multirag-kb with a value of trueIf you intend to use reranking functionality, your Bedrock Knowledge Base needs additional permissions:
bedrock:Rerank and bedrock:InvokeModel actionsReranking can be globally enabled or disabled using the BEDROCK_KB_RERANKING_ENABLED environment variable:
false (default): Disables reranking for all queries unless explicitly enabledtrue: Enables reranking for all queries unless explicitly disabledThe environment variable accepts various formats:
This setting provides a global default, while individual API calls can still override it by explicitly setting the reranking parameter.
For detailed instructions on setting up knowledge bases, see:
| Cursor | VS Code | 
|---|---|
Configure the MCP server in your MCP client configuration (e.g., for Amazon Q Developer CLI, edit ~/.aws/amazonq/mcp.json):
{ "mcpServers": { "awslabs.bedrock-kb-retrieval-mcp-server": { "command": "uvx", "args": ["awslabs.bedrock-kb-retrieval-mcp-server@latest"], "env": { "AWS_PROFILE": "your-profile-name", "AWS_REGION": "us-east-1", "FASTMCP_LOG_LEVEL": "ERROR", "KB_INCLUSION_TAG_KEY": "optional-tag-key-to-filter-kbs", "BEDROCK_KB_RERANKING_ENABLED": "false" }, "disabled": false, "autoApprove": [] } } }
For Windows users, the MCP server configuration format is slightly different:
{ "mcpServers": { "awslabs.bedrock-kb-retrieval-mcp-server": { "disabled": false, "timeout": 60, "type": "stdio", "command": "uv", "args": [ "tool", "run", "--from", "awslabs.bedrock-kb-retrieval-mcp-server@latest", "awslabs.bedrock-kb-retrieval-mcp-server.exe" ], "env": { "FASTMCP_LOG_LEVEL": "ERROR", "AWS_PROFILE": "your-aws-profile", "AWS_REGION": "us-east-1" } } } }
or docker after a successful docker build -t awslabs/bedrock-kb-retrieval-mcp-server .:
# fictitious `.env` file with AWS temporary credentials AWS_ACCESS_KEY_ID=ASIAIOSFODNN7EXAMPLE AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY AWS_SESSION_TOKEN=AQoEXAMPLEH4aoAH0gNCAPy...truncated...zrkuWJOgQs8IZZaIv2BXIa2R4Olgk
{ "mcpServers": { "awslabs.bedrock-kb-retrieval-mcp-server": { "command": "docker", "args": [ "run", "--rm", "--interactive", "--env", "FASTMCP_LOG_LEVEL=ERROR", "--env", "KB_INCLUSION_TAG_KEY=optional-tag-key-to-filter-kbs", "--env", "BEDROCK_KB_RERANKING_ENABLED=false", "--env", "AWS_REGION=us-east-1", "--env-file", "/full/path/to/file/above/.env", "awslabs/bedrock-kb-retrieval-mcp-server:latest" ], "env": {}, "disabled": false, "autoApprove": [] } } }
NOTE: Your credentials will need to be kept refreshed from your host
IMAGE content type are not included in the KB query response.reranking parameter requires additional permissions, Amazon Bedrock model access, and is only available in specific regions.