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

Function isReplaySafeRequest

packages/plugins/mcp/src/sdk/connection.ts:277–293  ·  view source on GitHub ↗
(init: RequestInit | undefined)

Source from the content-addressed store, hash-verified

275 * open, which carries no JSON-RPC request and is read-only by HTTP
276 * semantics. Everything else — `tools/call` above all — fails closed. */
277const isReplaySafeRequest = (init: RequestInit | undefined): boolean => {
278 const body = init?.body;
279 if (body == null) return httpMethodFrom(init?.method) === "GET";
280 // Both remote SDK transports send JSON-RPC bodies as `JSON.stringify`
281 // strings. Any other body shape cannot be verified read-only here.
282 if (typeof body !== "string") return false;
283 return Option.match(decodeJsonRpcMethods(body), {
284 onNone: () => false,
285 onSome: (parsed) => {
286 const messages = Array.isArray(parsed) ? parsed : [parsed];
287 return (
288 messages.length > 0 &&
289 messages.every((message) => REPLAYABLE_JSONRPC_METHODS.has(message.method))
290 );
291 },
292 });
293};
294
295const fetchFromHttpClientLayer = (
296 httpClientLayer: Layer.Layer<HttpClient.HttpClient>,

Callers 1

executeFunction · 0.85

Calls 1

httpMethodFromFunction · 0.85

Tested by

no test coverage detected