DEV Community

Cover image for Build a Fullstack Stock Portfolio Agent with Mastra and AG-UI

Build a Fullstack Stock Portfolio Agent with Mastra and AG-UI

Bonnie on July 30, 2025

In this guide, you will learn how to integrate a Mastra AI agent with the AG-UI protocol. Also, we will cover how to integrate the AG-UI + Mastra A...
Collapse
 
olidev profile image
Olivier • Edited

2 errors in the first curl :
thread_id -> threadId
run_id -> runId

This is the correct version

curl -X POST "http://localhost:8000/mastra-agent" \
-H "Content-Type: application/json" \
-d '{
"threadId": "test_thread_123",
"runId": "test_run_456",
"messages": [
{
"id": "msg_1",
"role": "user",
"content": "Analyze AAPL stock with a $10000 investment from 2023-01-01"
}
],
"tools": [],
"context": [],
"forwarded_props": {},
"state": {}
}'

Collapse
 
the_greatbonnie profile image
Bonnie CopilotKit

Thanks, Olivier!

Collapse
 
uliyahoo profile image
uliyahoo CopilotKit

Love seeing a Mastra + CopilotKit tutorial on Dev.to!

Collapse
 
the_greatbonnie profile image
Bonnie CopilotKit

Mastra + CopilotKit work quite well.

Collapse
 
bookercodes profile image
Alex Booker

I was looking for more examples of Mastra and CopilotKit and I don't think I'm alone either! Thank you for putting this together!

Collapse
 
the_greatbonnie profile image
Bonnie CopilotKit

You are welcome, Alex.

Hope you find this guide helpful.

Collapse
 
trent0123 profile image
Trent

Awesome. Bookmarking this for future reference.

Collapse
 
the_greatbonnie profile image
Bonnie CopilotKit

Thanks, Trent.

Collapse
 
johny0012 profile image
Johny

same

Collapse
 
nathan_tarbert profile image
Nathan Tarbert CopilotKit

Great tutorial, Bonnie. I've been building with Mastra and was pleasantly surprised by how easy it is- especially since I can stick with my primary language, TypeScript.

Collapse
 
the_greatbonnie profile image
Bonnie CopilotKit

Thanks, Nathan.

I am happy to hear that you have been building with Mastra.