How to define props in the MCP server?

I want to pass props from the fetch handler to the MCP agent tools. How can I do that? I tried setting props in the ctx object that gets passed onto the MyMCP.serveSSE(...).fetch() function, however that doesn't seem to get passed to the tools. this.props is an empty object in the tool handler. Truncated fetch handler code:
export default {
fetch(request: Request, env: Env, ctx: ExecutionContext) {
// ...
ctx.props.test = "test prop"
if (url.pathname === "/sse" || url.pathname === "/sse/message") {
return MyMCP.serveSSE("/sse").fetch(request, env, ctx);
}
// ...
}
}
export default {
fetch(request: Request, env: Env, ctx: ExecutionContext) {
// ...
ctx.props.test = "test prop"
if (url.pathname === "/sse" || url.pathname === "/sse/message") {
return MyMCP.serveSSE("/sse").fetch(request, env, ctx);
}
// ...
}
}
No description
2 Replies
exerra.xyz
exerra.xyzOP5mo ago
I used the authless starter And when looking at the GitHub Oauth example I noticed props can be passed so I'm wondering how Setting env.props in the fetch handler and then reading them with this.env.props in the tool handlers worked
exerra.xyz
exerra.xyzOP5mo ago
No description

Did you find this page helpful?