microsoft/autogen · warning · Error

Failed to list MCP prompts

Error message

Failed to list MCP prompts

What it means

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.

Source

Thrown at python/packages/autogen-studio/frontend/src/components/views/mcp/api.ts:154

    const data = await response.json();
    if (!response.ok) {
      throw new Error(data.message || "Failed to get MCP resource");
    }

    return data;
  }

  async listPrompts(serverParams: McpServerParams) {
    const response = await fetch(`${this.getBaseUrl()}/mcp/prompts/list`, {
      method: "POST",
      headers: this.getHeaders(),
      body: JSON.stringify({ server_params: serverParams }),
    });

    const data = await response.json();
    if (!response.ok) {
      throw new Error(data.message || "Failed to list MCP prompts");
    }

    return data;
  }

  async getPrompt(
    serverParams: McpServerParams,
    name: string,
    promptArgs?: Record<string, any>
  ) {
    const response = await fetch(`${this.getBaseUrl()}/mcp/prompts/get`, {
      method: "POST",
      headers: this.getHeaders(),
      body: JSON.stringify({
        server_params: serverParams,
        name: name,
        arguments: promptArgs || {},
      }),

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Trim and check the query before invoking the tool; skip the call when empty.
  2. Fix the upstream prompt/template so the LLM always supplies a non-empty query.
  3. If it slips through, catch ValueError and return a 'no query provided' message to the agent.

Example fix

# before
results = await tool.run(query_text)  # query_text may be "   "

# after
if not query_text or not query_text.strip():
    return SearchResults(results=[], metadata={"error": "empty query"})
results = await tool.run(query_text)
Defensive patterns

Strategy: validation

Validate before calling

def query_ok(q: str) -> bool:
    return isinstance(q, str) and bool(q.strip())

Try / catch

try:
    results = await tool.run(agent_query)
except ValueError as e:
    if str(e) == "Search query cannot be empty":
        return SearchResults(results=[], metadata={"reason": "empty query"})
    raise

Prevention

When it happens

Trigger: 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.

Common situations: Agent function-calling with empty query arguments; upstream text extraction returning whitespace; guard prompts that allow empty user input through to the search tool.

Related errors


AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15). Data as JSON: /api/errors/e62f9e5af9ac4583. Report an issue: GitHub.