Skip to main content
Glama
r3-yamauchi

Amazon Bedrock Knowledge Base MCP Server

by r3-yamauchi

update_knowledge_base

Modify an Amazon Bedrock Knowledge Base by updating its name, description, or IAM role. Empty parameters preserve existing values.

Instructions

Amazon Bedrock Knowledge Baseを更新します。

Knowledge Baseの名前、説明、IAMロールを更新できます。 空文字列のパラメータは更新されません(既存の値が保持されます)。

Args: knowledge_base_id: 更新対象のKnowledge BaseのID name: 新しい名前(オプション、空文字列の場合は更新されない) description: 新しい説明(オプション、空文字列の場合は更新されない) role_arn: 新しいIAMロールARN(オプション、空文字列の場合は更新されない)

Returns: KnowledgeBaseResponseDict: 更新されたKnowledge Baseのステータス - knowledge_base_id: Knowledge BaseのID - status: Knowledge Baseのステータス - arn: Knowledge BaseのARN(オプション)

Raises: ValueError: knowledge_base_idが空の場合

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
knowledge_base_idYes
nameNo
descriptionNo
role_arnNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
arnYes
statusYes
knowledge_base_idYes

Implementation Reference

  • The MCP tool handler for "update_knowledge_base", which performs input validation and calls the Bedrock client.
    @mcp.tool()  # MCPツールとして公開
    @handle_errors  # エラーハンドリングデコレータを適用
    def update_knowledge_base(
        knowledge_base_id: str,
        name: str = "",
        description: str = "",
        role_arn: str = "",
    ) -> KnowledgeBaseResponseDict:
        """
        Amazon Bedrock Knowledge Baseを更新します。
        
        Knowledge Baseの名前、説明、IAMロールを更新できます。
        空文字列のパラメータは更新されません(既存の値が保持されます)。
    
        Args:
            knowledge_base_id: 更新対象のKnowledge BaseのID
            name: 新しい名前(オプション、空文字列の場合は更新されない)
            description: 新しい説明(オプション、空文字列の場合は更新されない)
            role_arn: 新しいIAMロールARN(オプション、空文字列の場合は更新されない)
    
        Returns:
            KnowledgeBaseResponseDict: 更新されたKnowledge Baseのステータス
                - knowledge_base_id: Knowledge BaseのID
                - status: Knowledge Baseのステータス
                - arn: Knowledge BaseのARN(オプション)
        
        Raises:
            ValueError: knowledge_base_idが空の場合
        """
        # 入力値のバリデーション(共通関数を使用)
        knowledge_base_id = validate_required_string(knowledge_base_id, "knowledge_base_id")
        
        # Bedrockクライアントを使用してKnowledge Baseを更新
        # 空文字列の場合はNoneに変換して、既存の値を保持する
        result = bedrock_client.update_knowledge_base(
            knowledge_base_id=knowledge_base_id,
            name=name.strip() if name else None,
            description=description.strip() if description else None,
            role_arn=role_arn.strip() if role_arn else None,
        )
        return result
  • The helper method in BedrockKBClient that interacts with the AWS Bedrock Agent API to perform the update.
    def update_knowledge_base(
        self,
        knowledge_base_id: str,
        name: Optional[str] = None,
        description: Optional[str] = None,
        role_arn: Optional[str] = None,
    ) -> KnowledgeBaseResponseDict:
        """
        Knowledge Baseの情報を更新します。
        
        Knowledge Baseの名前、説明、IAMロールを更新できます。
        Noneが指定されたパラメータは更新されません(既存の値が保持されます)。
    
        Args:
            knowledge_base_id: 更新対象のKnowledge BaseのID
            name: 新しい名前(オプション、Noneの場合は更新されない)
            description: 新しい説明(オプション、Noneの場合は更新されない)
            role_arn: 新しいIAMロールARN(オプション、Noneの場合は更新されない)
    
        Returns:
            KnowledgeBaseResponseDict: 更新されたKnowledge Baseのステータス
                - knowledge_base_id: Knowledge BaseのID
                - status: Knowledge Baseのステータス
                - arn: Knowledge BaseのARN(オプション、更新時は含まれない場合がある)
        
        Raises:
            ClientError: AWS API呼び出しが失敗した場合
        
        Note:
            少なくとも1つのパラメータ(name、description、role_arn)を
            指定する必要があります。
        """
        try:
            # 更新パラメータを構築(指定されたパラメータのみを含める)
            update_params = {"knowledgeBaseId": knowledge_base_id}
            
            # 指定されたパラメータを追加
            if name:
                update_params["name"] = name
            if description:
                update_params["description"] = description
            if role_arn:
                update_params["roleArn"] = role_arn
    
            # AWS Bedrock APIを呼び出してKnowledge Baseを更新
            response = self.bedrock_agent.update_knowledge_base(**update_params)
            
            # 更新成功をログに記録
            logger.info(f"Updated knowledge base: {knowledge_base_id}")
            
            # 更新結果を整形して返す
            # 更新APIのレスポンスにはarnが含まれない場合があるため、Optionalとして扱います
            return {
                "knowledge_base_id": response["knowledgeBase"]["id"],
                "status": response["knowledgeBase"]["status"],
                "arn": response["knowledgeBase"].get("knowledgeBaseArn"),  # オプション
            }
        except ClientError as e:
            logger.error(f"Error updating knowledge base {knowledge_base_id}: {e}")
            raise
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses key behavioral traits: it's a mutation tool (implied by '更新します'), handles partial updates (empty strings don't change existing values), and raises a ValueError for empty knowledge_base_id. However, it lacks details on permissions, rate limits, side effects, or error handling beyond the one exception mentioned.

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

Conciseness4/5

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

The description is well-structured with clear sections (purpose, updatable fields, parameter details, returns, raises). It's appropriately sized, but the 'Args' and 'Returns' sections could be more integrated into natural language. Every sentence adds value, though minor redundancy exists (e.g., repeating '空文字列の場合は更新されない').

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

Completeness4/5

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

Given no annotations, 0% schema coverage, but an output schema exists, the description is fairly complete. It covers purpose, parameters, return values (though output schema handles details), and one error case. However, for a mutation tool, it could better address behavioral aspects like idempotency, concurrency, or authentication needs.

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

Parameters5/5

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

Schema description coverage is 0%, so the description must compensate fully. It does so by explaining all 4 parameters: 'knowledge_base_id' (ID of the target), 'name' (new name, optional, empty string preserves existing), 'description' (new description, optional, empty preserves), and 'role_arn' (new IAM role ARN, optional, empty preserves). It adds crucial semantics like optionality and update behavior not in the schema.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Amazon Bedrock Knowledge Baseを更新します' (updates an Amazon Bedrock Knowledge Base). It specifies the resource (Knowledge Base) and action (update), and lists updatable fields (name, description, IAM role). However, it doesn't explicitly differentiate from sibling tools like 'create_knowledge_base' or 'get_knowledge_base' beyond the verb 'update'.

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

Usage Guidelines3/5

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

The description implies usage context through the parameter explanations (e.g., empty strings preserve existing values) and the required 'knowledge_base_id', suggesting this is for modifying existing knowledge bases. However, it doesn't explicitly state when to use this tool versus alternatives like 'create_knowledge_base' or provide prerequisites (e.g., needing an existing knowledge base ID).

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/r3-yamauchi/bedrock-kb-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server