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

Function jsonRpcErrorBody

packages/hosts/mcp/src/envelope.ts:86–107  ·  view source on GitHub ↗
(
  status: number,
  code: number,
  message: string,
  opts?: { readonly cors?: boolean; readonly challenge?: string },
)

Source from the content-addressed store, hash-verified

84 * local — the four hand-rolled copies are deleted in favor of this.
85 */
86export const jsonRpcErrorBody = (
87 status: number,
88 code: number,
89 message: string,
90 opts?: { readonly cors?: boolean; readonly challenge?: string },
91): Response => {
92 const cors = opts?.cors ?? true;
93 const challenge = opts?.challenge;
94 return new Response(JSON.stringify({ jsonrpc: "2.0", error: { code, message }, id: null }), {
95 status,
96 headers: {
97 "content-type": "application/json",
98 ...(cors ? { "access-control-allow-origin": "*" } : {}),
99 ...(challenge
100 ? {
101 "www-authenticate": challenge,
102 "access-control-expose-headers": "WWW-Authenticate",
103 }
104 : {}),
105 },
106 });
107};
108
109/** The envelope's own CORS-on JSON-RPC error `Response`, optionally carrying a challenge. */
110const jsonRpcResponse = (

Callers 6

jsonRpcErrorFunction · 0.90
jsonRpcResponseFunction · 0.85
jsonRpcResponseFunction · 0.85
jsonRpcWebResponseFunction · 0.85
jsonRpcResponseFunction · 0.85
jsonErrorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected