MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / isJsonRpcEnvelope

Function isJsonRpcEnvelope

packages/plugins/mcp/src/sdk/probe-shape.ts:91–96  ·  view source on GitHub ↗
(body: string)

Source from the content-addressed store, hash-verified

89 * shape. Non-MCP services don't — GraphQL APIs return `{errors:[...]}`,
90 * REST APIs return their own envelope, marketing pages return HTML. */
91const 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?: ..., ...}`).

Callers 1

classifyFunction · 0.85

Calls 1

asObjectFunction · 0.85

Tested by

no test coverage detected