Accessing the request from McpAgent

Hi, I have something like this:
export class MyMCP extends McpAgent<Env, unknown> {
constructor(ctx: DurableObjectState, env: Env) {
super(ctx, env);
}
// access the request
}

export default {
fetch(
request: Request,
env: Env,
ctx: ExecutionContext
): Response | Promise<Response> {
const { pathname } = new URL(request.url);

if (pathname.startsWith("/sse")) {
return MyMCP.serveSSE("/sse").fetch(request, env, ctx);
}

// Handle case where no path matches
return new Response("Not found", { status: 404 });
},
};
export class MyMCP extends McpAgent<Env, unknown> {
constructor(ctx: DurableObjectState, env: Env) {
super(ctx, env);
}
// access the request
}

export default {
fetch(
request: Request,
env: Env,
ctx: ExecutionContext
): Response | Promise<Response> {
const { pathname } = new URL(request.url);

if (pathname.startsWith("/sse")) {
return MyMCP.serveSSE("/sse").fetch(request, env, ctx);
}

// Handle case where no path matches
return new Response("Not found", { status: 404 });
},
};
` What I want to do is to access request from the MyMCP class to get the headers, but I am not finding the way to do it. Does anyone have any idea how to do it?
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?