{"record":{"id":"fc8feb1507e70137","repo":"microsoft/autogen","slug":"failed-to-get-mcp-prompt","errorCode":null,"errorMessage":"Failed to get MCP prompt","messagePattern":"Failed to get MCP prompt","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"python/packages/autogen-studio/frontend/src/components/views/mcp/api.ts","lineNumber":177,"sourceCode":"\n  async getPrompt(\n    serverParams: McpServerParams,\n    name: string,\n    promptArgs?: Record<string, any>\n  ) {\n    const response = await fetch(`${this.getBaseUrl()}/mcp/prompts/get`, {\n      method: \"POST\",\n      headers: this.getHeaders(),\n      body: JSON.stringify({\n        server_params: serverParams,\n        name: name,\n        arguments: promptArgs || {},\n      }),\n    });\n\n    const data = await response.json();\n    if (!response.ok) {\n      throw new Error(data.message || \"Failed to get MCP prompt\");\n    }\n\n    return data;\n  }\n\n  async getCapabilities(\n    serverParams: McpServerParams\n  ): Promise<GetCapabilitiesResponse> {\n    const response = await fetch(`${this.getBaseUrl()}/mcp/capabilities/get`, {\n      method: \"POST\",\n      headers: this.getHeaders(),\n      body: JSON.stringify({ server_params: serverParams }),\n    });\n\n    const data = await response.json();\n    if (!response.ok) {\n      throw new Error(data.message || \"Failed to get MCP capabilities\");\n    }","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-studio/frontend/src/components/views/mcp/api.ts#L159-L195","documentation":"Input-validation error from run() when args is not one of the three accepted shapes: a str, a dict containing a 'query' key, or a SearchQuery instance. Any other type (int, list, dict without 'query', None) is rejected immediately.","triggerScenarios":"Calling tool.run({'text': 'hotels'}) (wrong key), tool.run(['hotels']), tool.run(None), or tool.run(42). Common with hand-written tool-call plumbing that forwards raw JSON of the wrong schema.","commonSituations":"LLM function-call arguments that don't match the SearchQuery schema (e.g. key named 'search' or 'q'); passing args unpacked from a tuple; deserializers returning something other than the documented shapes.","solutions":["Pass a str (query text), {'query': '...'}, or a SearchQuery instance — matching the key name exactly.","If forwarding LLM arguments, validate/normalize them to {'query': ...} first.","For schema drift, consider parsing with SearchQuery.model_validate_json(args_json) to get pydantic's clearer error."],"exampleFix":"# before\nawait tool.run({\"search\": \"hotels in seattle\"})  # wrong key -> ValueError\n\n# after\nawait tool.run({\"query\": \"hotels in seattle\"})\n# or\nawait tool.run(SearchQuery(query=\"hotels in seattle\"))","handlingStrategy":"type-guard","validationCode":"from autogen_ext.tools.azure._ai_search import SearchQuery\n\ndef coerce_query(args):\n    if isinstance(args, SearchQuery):\n        return args\n    if isinstance(args, str):\n        return SearchQuery(query=args)\n    if isinstance(args, dict) and isinstance(args.get(\"query\"), str):\n        return SearchQuery(query=args[\"query\"])\n    return None  # caller returns an error message to the agent","typeGuard":"from typing import Any, Union\n\ndef is_valid_search_args(args: Any) -> bool:\n    if isinstance(args, str):\n        return True\n    if isinstance(args, dict):\n        return \"query\" in args\n    return type(args).__name__ == \"SearchQuery\"","tryCatchPattern":"try:\n    results = await tool.run(raw_args)\nexcept ValueError as e:\n    if \"Invalid search query format\" in str(e):\n        return {\"error\": \"expected str, {'query': ...}, or SearchQuery\"}\n    raise","preventionTips":["Normalize agent function-call payloads to {'query': ...} before forwarding.","Parse raw JSON with SearchQuery.model_validate for clearer pydantic error messages."],"tags":["python","validation","input-validation","schema"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}