diff --git a/agent.py b/agent.py index e9bf434..fb88c09 100644 --- a/agent.py +++ b/agent.py @@ -34,20 +34,27 @@ class Agent: async def load_tools(self): try: res = await self.mcp.list_tools() - - self.tools = [ - { + + self.tools = [] + for t in res.tools: + schema = t.inputSchema + + # Bedrock-kompatibles Format erzwingen + if isinstance(schema, dict) and "json" not in schema: + bedrock_schema = {"json": schema} + else: + bedrock_schema = schema + + self.tools.append({ "toolSpec": { "name": t.name, "description": t.description, - "inputSchema": t.inputSchema + "inputSchema": bedrock_schema } - } - for t in res.tools - ] - - self.logger.info(f"{len(self.tools)} Tools erfolgreich geladen") - + }) + + self.logger.info(f"{len(self.tools)} Tools erfolgreich für Bedrock angepasst und geladen") + except Exception as e: self.logger.error(f"Tool Load Error: {e}") self.tools = []