Repository navigation
Closed
Labels
mcpIssues related to MCP functionality
Description
(via @deloreyj)
Hey Sunil, I've been debugging an issue we're having with the McpAgent where you have to set the active account ID twice for it to take effect. It looks like the issue ends up in the internals of PartyServer, so I wanted to get your take.
Here's the flow:
- Define an McpAgent with an initialState property like so
- Call the setActiveAccountId tool
- Spread this.state into the setState call
- this.state calls the getter which passes through to this.#agent.state getter
- Since we overrode the state, the getter drops through to this.setState in the Agent class
- Then we end up in this.broadcast
- Now we're in PartyServer at this method
/** Send a message to all connected clients, except connection ids listed in `without` */
broadcast(
msg: string | ArrayBuffer | ArrayBufferView,
without?: string[] | undefined
): void {
for (const connection of this.#connectionManager.getConnections()) {
if (!without || !without.includes(connection.id)) {
this.#sendMessageToConnection(connection, msg);
}
}
}The connection.id getter fails with this error
Uncaught TypeError TypeError: Cannot read properties of null (reading '__pk')
at get (/Users/delorey/code/mcp-server-cloudflare/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/partyserver/src/connection.ts:100:34)
at eval (repl:1:12)
Removing the initialState property from the McpAgent solves the problem because we return before the this.setState here.
We're unblocked on the MCP Servers, but seems like an issue worth looking into at some point?
Metadata
Metadata
Assignees
Labels
mcpIssues related to MCP functionality
Activity
[-]McpAgent accountid throws error[/-][+]McpAgent throws error[/+]whoiskatrin commentedon Sep 11, 2025
shouldn't be the case anymore, merged updated McpAgent