microsoft/autogen · warning · Error
Failed to get MCP prompt
Error message
Failed to get MCP prompt
What it means
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.
Source
Thrown at python/packages/autogen-studio/frontend/src/components/views/mcp/api.ts:177
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 || {},
}),
});
const data = await response.json();
if (!response.ok) {
throw new Error(data.message || "Failed to get MCP prompt");
}
return data;
}
async getCapabilities(
serverParams: McpServerParams
): Promise<GetCapabilitiesResponse> {
const response = await fetch(`${this.getBaseUrl()}/mcp/capabilities/get`, {
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 get MCP capabilities");
}View on GitHub (pinned to 027ecf0a37)
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.
Example fix
# before
await tool.run({"search": "hotels in seattle"}) # wrong key -> ValueError
# after
await tool.run({"query": "hotels in seattle"})
# or
await tool.run(SearchQuery(query="hotels in seattle")) Defensive patterns
Strategy: type-guard
Validate before calling
from autogen_ext.tools.azure._ai_search import SearchQuery
def coerce_query(args):
if isinstance(args, SearchQuery):
return args
if isinstance(args, str):
return SearchQuery(query=args)
if isinstance(args, dict) and isinstance(args.get("query"), str):
return SearchQuery(query=args["query"])
return None # caller returns an error message to the agent Type guard
from typing import Any, Union
def is_valid_search_args(args: Any) -> bool:
if isinstance(args, str):
return True
if isinstance(args, dict):
return "query" in args
return type(args).__name__ == "SearchQuery" Try / catch
try:
results = await tool.run(raw_args)
except ValueError as e:
if "Invalid search query format" in str(e):
return {"error": "expected str, {'query': ...}, or SearchQuery"}
raise Prevention
- Normalize agent function-call payloads to {'query': ...} before forwarding.
- Parse raw JSON with SearchQuery.model_validate for clearer pydantic error messages.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Failed to list MCP prompts
- Failed to get MCP capabilities
- File {path} does not exist.
- expand_scenario expects an str or list for 'template'
- Tool names must be unique: {tool_names}
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/fc8feb1507e70137.
Report an issue: GitHub.