docs: surface Kijiji AND-matching behavior in tool, API, and MCP responses
Kijiji zero-result queries (e.g. 'macbook air m1 apple silicon') are confusing because the failure mode is non-obvious. Surface the root cause everywhere the caller can see it: - MCP tool description warns about AND-matching and gives a concrete before/after example - API 404 body includes the actionable hint via emptySearchResponse(hint) - Core scraper logs the built URL and tip on page-1 zero results - MCP handler unwraps the API message field so the hint reaches the LLM
This commit is contained in:
@@ -138,7 +138,14 @@ export async function handleMcpRequest(req: Request): Promise<Response> {
|
||||
logger.error(
|
||||
`[MCP] Kijiji API error ${response.status}: ${errorText}`,
|
||||
);
|
||||
throw new Error(`API returned ${response.status}: ${errorText}`);
|
||||
let errorMessage = `API returned ${response.status}: ${errorText}`;
|
||||
try {
|
||||
const errorJson = JSON.parse(errorText) as { message?: string };
|
||||
if (errorJson.message) errorMessage = errorJson.message;
|
||||
} catch {
|
||||
// not JSON — use raw text
|
||||
}
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
result = await response.json();
|
||||
logger.log(
|
||||
|
||||
Reference in New Issue
Block a user