Skip to main content

This is an AWS Labs Model Context Protocol (MCP) server implementation that enables Independent Software Vendors (ISVs) to interact with Amazon Q Business's search capabilities. The server facilitates searching across enterprise customers' Q index using the SearchRelevantContent API.

Project description

AWS Labs amazon-qindex MCP Server

The AWS Labs amazon-qindex MCP Server is a Model Context Protocol (MCP) server designed to facilitate integration with Amazon Q Business's SearchRelevantContent API. While the server provides essential tools and functions for authentication and search capabilities using Amazon Q index, it currently serves for Independent Software Vendors (ISVs) who are AWS registered data accessors. The server enables cross-account search capabilities, allowing ISVs who are data accessors to search through enterprise customers' Q index and access relevant content across their data sources using specific authentication and authorization flows.

For Amazon Q Business application owners, direct integration support is not yet available. This MCP server represents a comprehensive solution that aims to serve ISVs.

Features

  • Boto3 client implementation for Q Business interactions
  • Support for various authentication methods (IAM credentials, profile-based)
  • MCP server implementation for handling Q index requests
  • Token-based authorization support
  • Error handling and mapping for Q Business API responses

Tools

AuthorizeQIndex

  • Generates OIDC authorization URL for Q index authentication
  • Required Parameters:
    • idc_region (str): AWS region for IAM Identity Center (e.g., us-west-2)
    • isv_redirect_url (str): Redirect URL registered during ISV registration
    • oauth_state (str): Random string for CSRF protection
    • idc_application_arn (str): Amazon Q Business application ID
  • Returns: Authorization URL for user authentication

CreateTokenWithIAM

  • Creates authentication token using authorization code through IAM
  • Required Parameters:
    • idc_application_arn (str): Amazon Q Business application ID
    • redirect_uri (str): Registered redirect URL
    • code (str): Authorization code from OIDC endpoint
    • idc_region (str): AWS region for IAM Identity Center
    • role_arn (str): IAM role ARN to assume
  • Returns: Token information including access token, refresh token, and expiration

AssumeRoleWithIdentityContext

  • Assumes IAM role using identity context from token
  • Required Parameters:
    • role_arn (str): IAM role ARN to assume
    • identity_context (str): Identity context from decoded token
    • role_session_name (str): Session identifier (default: "qbusiness-session")
    • idc_region (str): AWS region for IAM Identity Center
  • Returns: Temporary AWS credentials

SearchRelevantContent

  • Searches content within Amazon Q Business application
  • Required Parameters:
    • application_id (str): Q Business application identifier
    • query_text (str): Search query text
  • Optional Parameters:
    • attribute_filter (AttributeFilter): Document attribute filters
    • content_source (ContentSource): Content source configuration
    • max_results (int): Maximum results to return (1-100)
    • next_token (str): Pagination token
    • qbuiness_region (str): AWS region (default: us-east-1)
    • aws_credentials: Temporary AWS credentials
  • Returns: Search results with relevant content matches

Setup

Pre-Requisites

  • Install uv from Astral or the GitHub README

  • Install Python using uv python install 3.10

  • Two AWS Accounts (one account as ISV running this tester application, another account acting as enterprise customer running Amazon Q Business)

  • Data accessor registered for your ISV

  • IAM Identity Center (IDC) instance setup with user added on enterprise customer AWS account

  • Amazon Q Business application setup with IAM IDC as access management on enterprise customer AWS account

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.amazon_qindex_mcp_server": {
      "command": "uvx",
      "args": ["awslabs.amazon_qindex_mcp_server"],
      "env": {
        "AWS_PROFILE": "your-aws-profile",
        "AWS_REGION": "us-east-1"
      }
    }
  }
}

Windows Installation

For Windows users, the MCP server configuration format is slightly different:

{
  "mcpServers": {
    "awslabs.amazon-qindex-mcp-server": {
      "disabled": false,
      "timeout": 60,
      "type": "stdio",
      "command": "uv",
      "args": [
        "tool",
        "run",
        "--from",
        "awslabs.amazon-qindex-mcp-server@latest",
        "awslabs.amazon-qindex-mcp-server.exe"
      ],
      "env": {
        "FASTMCP_LOG_LEVEL": "ERROR",
        "AWS_PROFILE": "your-aws-profile",
        "AWS_REGION": "us-east-1"
      }
    }
  }
}
# Clone the repository
git clone [repository-url]

# Go to root directory of this server
cd <your repo path>/mcp/src/amazon-qindex-mcp-server/

# Install dependencies
pip install -e .

Usage

  1. Enter a text prompt describing what you want to query from enterprise data
search <your query> on enterprise data
  1. You also need to provide the following details to proceed with the authentication flow in order to process SearchRelevantContent API
application id - (enterprise account's Amazon Q Business application ID)
retriever id - (enterprise account's Amazon Q Business retriever ID)
iam idc arn - (enterprise account's IdC application ARN)
idc region - (Region for the IAM Identity Center instance)
qbuiness region - (enterprise account's Amazon Q Business application region)
redirect url - (ISV's redirect url - this could be anything within allowlisted for the data accessor - ie https://localhost:8081)
iam role arn - (ISV's IAM Role ARN registered with the data accessor)
  1. After providing the data through above two steps, you will be asked to visit the authorization URL on your browser and after successfully authenticated and taken to redirect url with an authorization code in the URL parameters (it will look like ?code=ABC123...&state=xxx), copy and paste the code portion to the client to resume the process.
code is <your authorization code>
  1. This MCP server will then process CreateTokenWithIAM to create authentication token, AssumeRoleWithIdentityContext to assume the role and get temporary credentials, then finally call SearchRelevantContent to searches user queried content within Amazon Q Business application.

Testing

Run tests using pytest:

pytest --cache-clear -v

Security Considerations

This MCP server implementation is for demonstration purposes only to showcase how to access the SearchRelevantContent API through an MCP server with user-aware authentication. For production use, please consider the following security measures:

Authentication & Authorization

  • Never hardcode credentials or sensitive information in the code
  • Implement proper session management and token refresh mechanisms
  • Use strong CSRF protection mechanisms for the OAuth flow
  • Implement proper validation of all authorization codes and tokens
  • Store tokens securely and never log them
  • Implement proper token revocation when sessions end

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

awslabs_amazon_qindex_mcp_server-0.0.11.tar.gz (99.1 kB view details)

Uploaded Source

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_amazon_qindex_mcp_server-0.0.11.tar.gz.

File metadata

File hashes

Hashes for awslabs_amazon_qindex_mcp_server-0.0.11.tar.gz
Algorithm Hash digest
SHA256 f2ed9013be66a38d2d87c405a4378c80c09bab6c3ea0fc35e2a0fbc3a8dbce47
MD5 98db056bf51bcfc96dfe4cdd629aeb53
BLAKE2b-256 3413ae2dfc5b5147648d6e2d2f087ac83d6862554599b181146c4921864e3c3e

See more details on using hashes here.

Provenance

The following attestation bundles were made for awslabs_amazon_qindex_mcp_server-0.0.11.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_amazon_qindex_mcp_server-0.0.11-py3-none-any.whl.

File metadata

File hashes

Hashes for awslabs_amazon_qindex_mcp_server-0.0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 e35b55eb1e5278ae071a031f93b9d12589042e0d45b08d3c43e17986e79dcc4c
MD5 c323338915f3a88ee41bc949cbe0fa92
BLAKE2b-256 ca9c6e2dabfa5611fb770578f10863208f4b30e3b1fe54955a94fe58221d3a61

See more details on using hashes here.

Provenance

The following attestation bundles were made for awslabs_amazon_qindex_mcp_server-0.0.11-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