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

Function isReplaySafeRequest

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

Source from the content-addressed store, hash-verified

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

Callers 1

executeFunction · 0.85

Calls 1

httpMethodFromFunction · 0.85

Tested by

no test coverage detected