Skip to main content
Glama
kawanishi0117

kk-bedrock-agent-hub-mcp

kk-bedrock-agent-hub-mcp

Amazon Bedrock Knowledge Base にクエリを送信する MCP (Model Context Protocol) サーバーです。

概要

kk-bedrock-agent-hub-mcp は、AI アシスタント(Claude Desktop、Cursor、Kiro)が Amazon Bedrock Knowledge Base から情報を取得できるようにする kb_answer ツールを提供します。

注意: このサーバーは Retrieve API を使用し、純粋な検索機能のみを提供します。回答生成(RetrieveAndGenerate)は行わず、基盤モデル ARN は不要です。

Related MCP server: Amazon Bedrock Knowledge Base MCP Server

機能

  • Bedrock Retrieve API を使用した Knowledge Base 検索

  • 環境変数ベースの設定管理

  • 検索結果(コンテンツ、ロケーション、スコア)の抽出と返却

  • 入力バリデーション

環境変数

変数名

必須

デフォルト

説明

AWS_REGION

いいえ

ap-northeast-1

AWS リージョン

BEDROCK_KB_ID

はい

-

Knowledge Base ID

AWS_PROFILE

いいえ

-

AWS 認証プロファイル

環境変数の設定例

# Linux/macOS
export AWS_REGION="ap-northeast-1"
export BEDROCK_KB_ID="your-knowledge-base-id"

# Windows (PowerShell)
$env:AWS_REGION = "ap-northeast-1"
$env:BEDROCK_KB_ID = "your-knowledge-base-id"

インストール

方法1: Git Clone(推奨)

# リポジトリをクローン
git clone https://github.com/kawanishi0117/mcp-bedrock-kb.git
cd mcp-bedrock-kb

# 依存関係をインストール
pip install -e .

方法2: pip で直接インストール

pip install git+https://github.com/kawanishi0117/mcp-bedrock-kb.git

使用方法

直接実行

python kb_mcp_server.py

コマンドラインから実行(pip インストール後)

bedrock-kb-mcp

MCP クライアント設定

クローンしたディレクトリの絶対パスを指定してください。

Claude Desktop

claude_desktop_config.json に以下を追加:

{
  "mcpServers": {
    "kk-bedrock-agent-hub-mcp": {
      "command": "python",
      "args": ["/path/to/mcp-bedrock-kb/kb_mcp_server.py"],
      "env": {
        "BEDROCK_KB_ID": "your-kb-id"
      }
    }
  }
}

Cursor

.cursor/mcp.json に以下を追加:

{
  "mcpServers": {
    "kk-bedrock-agent-hub-mcp": {
      "command": "python",
      "args": ["/path/to/mcp-bedrock-kb/kb_mcp_server.py"],
      "env": {
        "BEDROCK_KB_ID": "your-kb-id"
      }
    }
  }
}

Kiro

~/.kiro/settings/mcp.json(グローバル)または .kiro/settings/mcp.json(ワークスペース)に以下を追加:

{
  "mcpServers": {
    "kk-bedrock-agent-hub-mcp": {
      "command": "python",
      "args": ["/path/to/mcp-bedrock-kb/kb_mcp_server.py"],
      "env": {
        "BEDROCK_KB_ID": "your-kb-id"
      }
    }
  }
}

Windows の場合

パスはスラッシュ / またはダブルバックスラッシュ \\ を使用:

{
  "mcpServers": {
    "kk-bedrock-agent-hub-mcp": {
      "command": "python",
      "args": ["C:/Users/username/mcp-bedrock-kb/kb_mcp_server.py"],
      "env": {
        "BEDROCK_KB_ID": "your-kb-id"
      }
    }
  }
}

AWS_PROFILE を使用する場合

AWS 認証プロファイルを指定する場合は AWS_PROFILE 環境変数を追加:

{
  "mcpServers": {
    "kk-bedrock-agent-hub-mcp": {
      "command": "python",
      "args": ["/path/to/mcp-bedrock-kb/kb_mcp_server.py"],
      "env": {
        "BEDROCK_KB_ID": "your-kb-id",
        "AWS_PROFILE": "your-profile-name"
      }
    }
  }
}

kb_answer ツール

パラメータ

パラメータ

必須

デフォルト

説明

query

string

はい

-

Knowledge Base に送信するクエリ文字列

max_results

integer

いいえ

4

取得するソースチャンクの最大数(1-10)

使用例

kb_answer("製品の返品ポリシーについて教えてください")
kb_answer("技術仕様を詳しく説明してください", max_results=8)

レスポンス形式

検索結果は以下の形式で返されます:

{
  "content": "ドキュメントチャンクのテキスト内容",
  "location": {"s3Location": {...}, "type": "S3"},
  "score": 0.85
}

開発

テスト実行

pytest

プロジェクト構造

bedrock-kb-mcp-server/
├── src/                    # メインソースコード
│   ├── __init__.py
│   ├── bedrock_client.py   # Bedrock API クライアント
│   ├── config.py           # 環境変数からの設定読み込み
│   ├── models.py           # データクラス
│   ├── parser.py           # API レスポンスパーサー
│   ├── server.py           # MCP サーバー実装
│   └── validation.py       # 入力バリデーション
├── tests/                  # テストコード
├── kb_mcp_server.py        # メインエントリーポイント
├── pyproject.toml          # プロジェクト設定
└── README.md

ライセンス

MIT

Available Tools

1 tool
kb_answerA

Amazon Bedrock Knowledge Base を検索し、関連するドキュメントチャンクを返す。

Retrieve API を使用して Knowledge Base から関連ドキュメントを検索する。 回答生成は行わず、検索結果のみを返す。

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYesKnowledge Base に送信する検索クエリ文字列
max_resultsNo取得するソースチャンクの最大数(デフォルト: 4、範囲: 1-10)

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.3/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses that the tool uses the Retrieve API and only returns search results (no answer generation). This is clear, though it could mention that the operation is read-only and does not modify any data.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two short, front-loaded sentences that convey purpose and behavior without unnecessary detail. Every sentence adds value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (2 parameters, clear purpose) and the presence of an output schema (which covers return structure), the description is complete enough. It explains what the tool returns (relevant document chunks) and its non-generative nature.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters adequately. The description does not add additional meaning beyond what is in the schema (e.g., constraints or context for max_results range). Baseline score of 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool searches Amazon Bedrock Knowledge Base and returns relevant document chunks. It explicitly distinguishes itself from generative tools by stating it does not generate answers (回答生成は行わず、検索結果のみを返す).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies the tool is for retrieval-only queries, but it does not provide explicit guidance on when not to use or alternatives. Since there are no sibling tools, the lack of exclusion is acceptable, but it could be more explicit about prerequisites or limitations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 1 tool updatev0.1.0
    • First observedkb_answer

TDQS

A4.1/5.0

Scored across 1 tool

Disambiguation5/5

With only one tool, there is no risk of confusion or overlap. The tool's purpose is clear and distinct.

Naming Consistency5/5

A single tool cannot be inconsistent; the verb_noun pattern 'kb_answer' is clear and follows common conventions.

Tool Count2/5

The tool count of 1 is far too low for a server named 'hub', which implies a broader set of functionalities. A hub should offer multiple operations.

Completeness2/5

The server only provides a search/retrieve tool, missing essential operations like listing knowledge bases, managing chunks, or generating answers. The surface is severely incomplete.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers