| 89 | * shape. Non-MCP services don't — GraphQL APIs return `{errors:[...]}`, |
| 90 | * REST APIs return their own envelope, marketing pages return HTML. */ |
| 91 | const isJsonRpcEnvelope = (body: string): boolean => { |
| 92 | const obj = asObject(body); |
| 93 | if (!obj) return false; |
| 94 | if (obj.jsonrpc !== "2.0") return false; |
| 95 | return "result" in obj || "error" in obj || "method" in obj; |
| 96 | }; |
| 97 | |
| 98 | /** Quick check that a body parses as an RFC 6750 OAuth Bearer error |
| 99 | * envelope (`{error: "invalid_token", error_description?: ..., ...}`). |