-
Notifications
You must be signed in to change notification settings - Fork 752
Description
I have a mastra agent that is configured with an MCP server. This setup works great in the mastra playground. I have modified the setup to use CopilotKit and AGUI, using Next. I used the examples here:
https://mastra.ai/en/docs/frameworks/copilotkit#basic-setup
https://docs.copilotkit.ai/mastra/quickstart
When I load the url for the ui (localhost:3000), it brings up my chat interface for my agent. When I type "hello" it returns a contextual response. However when I enter a prompt that results in the agent using MCP to provide the answer, I am getting the following error:
[14:30:40.860] ERROR: Error in event stream
component: "CopilotResolver.generateCopilotResponse"
err: {
"type": "AGUIError",
"message": "Cannot send 'TEXT_MESSAGE_CONTENT' event: No active text message found. Start a text message with 'TEXT_MESSAGE_START' first.",
"stack":
Error: Cannot send 'TEXT_MESSAGE_CONTENT' event: No active text message found. Start a text message with 'TEXT_MESSAGE_START' first.
at eval (webpack-internal:///(rsc)/./node_modules/@ag-ui/client/dist/index.mjs:70:3773)
at Observable.init [as _subscribe] (webpack-internal:///(rsc)/./node_modules/rxjs/dist/esm5/internal/observable/throwError.js:14:33)
at Observable._trySubscribe (webpack-internal:///(rsc)/./node_modules/rxjs/dist/esm5/internal/Observable.js:42:25)
at eval (webpack-internal:///(rsc)/./node_modules/rxjs/dist/esm5/internal/Observable.js:36:121)
at errorContext (webpack-internal:///(rsc)/./node_modules/rxjs/dist/esm5/internal/util/errorContext.js:27:9)
at Observable.subscribe (webpack-internal:///(rsc)/./node_modules/rxjs/dist/esm5/internal/Observable.js:34:73)
at Observable.eval [as _subscribe] (webpack-internal:///(rsc)/./node_modules/rxjs/dist/cjs/internal/observable/innerFrom.js:206:24)
at Observable._trySubscribe (webpack-internal:///(rsc)/./node_modules/rxjs/dist/cjs/internal/Observable.js:36:25)
at eval (webpack-internal:///(rsc)/./node_modules/rxjs/dist/cjs/internal/Observable.js:30:121)
at Object.errorContext (webpack-internal:///(rsc)/./node_modules/rxjs/dist/cjs/internal/util/errorContext.js:26:9)
at Observable.subscribe (webpack-internal:///(rsc)/./node_modules/rxjs/dist/cjs/internal/Observable.js:28:24)
at doInnerSub (webpack-internal:///(rsc)/./node_modules/rxjs/dist/cjs/internal/operators/mergeInternals.js:26:56)
at outerNext (webpack-internal:///(rsc)/./node_modules/rxjs/dist/cjs/internal/operators/mergeInternals.js:20:38)
at OperatorSubscriber._this._next (webpack-internal:///(rsc)/./node_modules/rxjs/dist/cjs/internal/operators/OperatorSubscriber.js:39:17)
at Subscriber.next (webpack-internal:///(rsc)/./node_modules/rxjs/dist/cjs/internal/Subscriber.js:56:18)
at onTextPart (webpack-internal:///(rsc)/./node_modules/@mastra/client-js/dist/index.js:67:36)
at processDataStream (webpack-internal:///(rsc)/./node_modules/@ai-sdk/ui-utils/dist/index.mjs:833:48)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async response.processDataStream (webpack-internal:///(rsc)/./node_modules/@mastra/client-js/dist/index.js:358:13)
}
I cannot find any examples on a CopilotKit setup with a Mastra agent that uses MCP, but I believe it should work regardless. It's possible I am missing something, but would welcome any insight as to whether this should work. Thanks in advance