Open
Description
When using a MCPAgent locally, the POST /message handler fetches the Durable Object using idFromName("sse:${sessionId}") but does not re-initialize or update the props context via _init() or similar.
// Get the Durable Object
const id = namespace.idFromName(`sse:${sessionId}`);
const doStub = namespace.get(id);
// Forward the request to the Durable Object
const error = await doStub.onSSEMcpMessage(sessionId, request);
In practical terms, this leads to stale or missing values inside this.props. For instance, in the Auth0 integration example, this.props.tokenSet.accessToken
from tokenExchangeCallback
never updates after the first token exchange. Even though the refresh token flow is correctly triggered, the updated access token never reaches the Durable Object instance, breaking authenticated API requests.
I guess a solution can be:
// Get the Durable Object
const id = namespace.idFromName(`sse:${sessionId}`);
const doStub = namespace.get(id);
await doStub._init(ctx.props) // refresh props
// Forward the request to the Durable Object
const error = await doStub.onSSEMcpMessage(sessionId, request);
If you agree with the fix, I’d be happy to open a PR.
Metadata
Metadata
Assignees
Labels
No labels