1"""2Knowledge Base shim Lambda — AgentCore Gateway target.34WHY: the native Gateway KB connector only takes a MANAGED Bedrock KB and a fixed5retrieval contract. For VECTOR / KENDRA / SQL KBs, or to preserve a managed KB's6non-default retrieval config (reranker, metadata filter, hybrid override, top-k),7expose retrieval as this Lambda: it presents one MCP tool, calls8`bedrock-agent-runtime:Retrieve` against the source KB, and returns MCP-shaped9passages.1011Gateway invokes a Lambda target with the tool arguments flat in `event` and the12tool name in context.client_context.custom['bedrockAgentCoreToolName']13("<target>___<tool>"). The handler also tolerates a direct {"query": ...} for local14testing.15"""16# <<< RENDER: delete this whole block after substituting the tokens below.17# {{KB_ID}} - the source knowledge base id