{"record":{"id":"e62f9e5af9ac4583","repo":"microsoft/autogen","slug":"failed-to-list-mcp-prompts","errorCode":null,"errorMessage":"Failed to list MCP prompts","messagePattern":"Failed to list MCP prompts","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"python/packages/autogen-studio/frontend/src/components/views/mcp/api.ts","lineNumber":154,"sourceCode":"\n    const data = await response.json();\n    if (!response.ok) {\n      throw new Error(data.message || \"Failed to get MCP resource\");\n    }\n\n    return data;\n  }\n\n  async listPrompts(serverParams: McpServerParams) {\n    const response = await fetch(`${this.getBaseUrl()}/mcp/prompts/list`, {\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 list MCP prompts\");\n    }\n\n    return data;\n  }\n\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      }),","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-studio/frontend/src/components/views/mcp/api.ts#L136-L172","documentation":"Input-validation error from run() when the tool is invoked with a bare string consisting only of whitespace. Because LLM agents frequently pass query text as a plain string, the tool rejects empty/whitespace-only strings before building the SearchQuery.","triggerScenarios":"Calling `await tool.run(\"   \")` or tool.run(\"\") — often an LLM producing an empty function-call argument, or template code that interpolates an undefined variable into the query string.","commonSituations":"Agent function-calling with empty query arguments; upstream text extraction returning whitespace; guard prompts that allow empty user input through to the search tool.","solutions":["Trim and check the query before invoking the tool; skip the call when empty.","Fix the upstream prompt/template so the LLM always supplies a non-empty query.","If it slips through, catch ValueError and return a 'no query provided' message to the agent."],"exampleFix":"# before\nresults = await tool.run(query_text)  # query_text may be \"   \"\n\n# after\nif not query_text or not query_text.strip():\n    return SearchResults(results=[], metadata={\"error\": \"empty query\"})\nresults = await tool.run(query_text)","handlingStrategy":"validation","validationCode":"def query_ok(q: str) -> bool:\n    return isinstance(q, str) and bool(q.strip())","typeGuard":null,"tryCatchPattern":"try:\n    results = await tool.run(agent_query)\nexcept ValueError as e:\n    if str(e) == \"Search query cannot be empty\":\n        return SearchResults(results=[], metadata={\"reason\": \"empty query\"})\n    raise","preventionTips":["Validate LLM-provided arguments before invoking tools.","Skip the search step entirely for empty inputs instead of relying on the tool to reject them."],"tags":["python","validation","input-validation","azure-ai-search"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}