Skip to main content

An AWS Labs Model Context Protocol (MCP) server for Bedrock Knowledge Base Retrieval

Project description

Amazon Bedrock Knowledge Base Retrieval MCP Server

MCP server for accessing Amazon Bedrock Knowledge Bases

Features

Discover knowledge bases and their data sources

  • Find and explore all available knowledge bases
  • Search for knowledge bases by name or tag
  • List data sources associated with each knowledge base

Query knowledge bases with natural language

  • Retrieve information using conversational queries
  • Get relevant passages from your knowledge bases
  • Access citation information for all results

Filter results by data source

  • Focus your queries on specific data sources
  • Include or exclude specific data sources
  • Prioritize results from specific data sources

Rerank results

  • Improve relevance of retrieval results
  • Use Amazon Bedrock reranking capabilities
  • Sort results by relevance to your query

Prerequisites

Installation Requirements

  1. Install uv from Astral or the GitHub README
  2. Install Python using uv python install 3.10

AWS Requirements

  1. AWS CLI Configuration: You must have the AWS CLI configured with credentials and an AWS_PROFILE that has access to Amazon Bedrock and Knowledge Bases
  2. Amazon Bedrock Knowledge Base: You must have at least one Amazon Bedrock Knowledge Base with the tag key mcp-multirag-kb with a value of true
  3. IAM Permissions: Your IAM role/user must have appropriate permissions to:
    • List and describe knowledge bases
    • Access data sources
    • Query knowledge bases

Reranking Requirements

If you intend to use reranking functionality, your Bedrock Knowledge Base needs additional permissions:

  1. Your IAM role must have permissions for both bedrock:Rerank and bedrock:InvokeModel actions
  2. The Amazon Bedrock Knowledge Bases service role must also have these permissions
  3. Reranking is only available in specific regions. Please refer to the official documentation for an up to date list of supported regions.
  4. Enable model access for the available reranking models in the specified region.

Controlling Reranking

Reranking can be globally enabled or disabled using the BEDROCK_KB_RERANKING_ENABLED environment variable:

  • Set to false (default): Disables reranking for all queries unless explicitly enabled
  • Set to true: Enables reranking for all queries unless explicitly disabled

The environment variable accepts various formats:

  • For enabling: 'true', '1', 'yes', or 'on' (case-insensitive)
  • For disabling: any other value or not set (default behavior)

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:

Installation

Kiro Cursor VS Code
Add to Kiro Install MCP Server Install on VS Code

Configure the MCP server in your MCP client configuration (e.g., for Kiro, edit ~/.kiro/settings/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": []
    }
  }
}

Windows Installation

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

Limitations

  • Results with IMAGE content type are not included in the KB query response.
  • The reranking parameter requires additional permissions, Amazon Bedrock model access, and is only available in specific regions.

Project details


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

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file awslabs_bedrock_kb_retrieval_mcp_server-1.0.15.tar.gz.

File metadata

File hashes

Hashes for awslabs_bedrock_kb_retrieval_mcp_server-1.0.15.tar.gz
Algorithm Hash digest
SHA256 7c74a5fbbc0fedf71a158c40afff210abfb5356843268b6dcdc4889b86626ff3
MD5 5f71031bdeb4cc3c863de05abb07b960
BLAKE2b-256 891401c8e370ac8ef9fdc213f5e2e47b1a3bdec395c47a373036b2693655c2b4

See more details on using hashes here.

Provenance

The following attestation bundles were made for awslabs_bedrock_kb_retrieval_mcp_server-1.0.15.tar.gz:

Publisher: release.yml on awslabs/mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file awslabs_bedrock_kb_retrieval_mcp_server-1.0.15-py3-none-any.whl.

File metadata

File hashes

Hashes for awslabs_bedrock_kb_retrieval_mcp_server-1.0.15-py3-none-any.whl
Algorithm Hash digest
SHA256 6c2c4cfeb405c7716e043fa4c462c52bb99d922007a5213f6e0e3af364383975
MD5 f830e239207ce6f62aaf23be96dd92a1
BLAKE2b-256 453d54b5ff70133d846c9108069301cdc4841ba016dd21384069faa663fefd33

See more details on using hashes here.

Provenance

The following attestation bundles were made for awslabs_bedrock_kb_retrieval_mcp_server-1.0.15-py3-none-any.whl:

Publisher: release.yml on awslabs/mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page