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

Function toWebRequest

packages/hosts/mcp/src/envelope.ts:139–147  ·  view source on GitHub ↗
(req: HttpServerRequest.HttpServerRequest)

Source from the content-addressed store, hash-verified

137 * recoverable error.
138 */
139const toWebRequest = (req: HttpServerRequest.HttpServerRequest): Effect.Effect<Request> =>
140 Effect.gen(function* () {
141 if (req.source instanceof Request) return req.source;
142 const headers = new Headers(req.headers as Record<string, string>);
143 const hasBody = req.method !== "GET" && req.method !== "HEAD";
144 // oxlint-disable-next-line executor/no-effect-escape-hatch -- boundary: rebuilding a web Request from a non-web source; a failed body read is an unrecoverable infra defect, not a domain error
145 const body = hasBody ? yield* req.text.pipe(Effect.orDie) : undefined;
146 return new Request(req.url, { method: req.method, headers, body });
147 });
148
149/** Serve a provider discovery document, wrapping its web `Response`. */
150const discoveryRoute = (handler: (request: Request) => Effect.Effect<Response>) =>

Callers 2

discoveryRouteFunction · 0.85
mcpDispatchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected