AgentStack is a production-grade multi-agent framework built on Mastra, delivering 50+ enterprise tools, 25+ specialized agents, and A2A/MCP orchestration for scalable AI systems. Focuses on financial intelligence, RAG pipelines, observability, and secure governance.
| Feature | AgentStack | LangChain | CrewAI | AutoGen |
|---|---|---|---|---|
| Production Observability | β Full Arize/Phoenix tracing + custom scorers | β Basic | β Limited | |
| Financial Tools | β Polygon/Finnhub/AlphaVantage (20+ endpoints) | β None | β None | β None |
| RAG Pipeline | β PgVector HNSW + rerank + graphRAG | β Basic | β None | |
| Multi-Agent | β A2A MCP + parallel orchestration | β Sequential | β Custom | |
| Governance | β JWT/RBAC + path traversal + HTML sanitization | β Custom | β None | β None |
| TypeScript | β Zod schemas everywhere | β Python | ||
| Tests | β 97% Vitest coverage | β Sparse |
Built for production: Secure, observable, testable agents with zero-config PgVector RAG + enterprise financial APIs.
- π° Financial Intelligence: 20+ tools (Polygon quotes/aggs/fundamentals, Finnhub analysis, AlphaVantage indicators)
- π Semantic RAG: PgVector (3072D embeddings) + MDocument chunking + rerank + graph traversal
- π€ 25+ Agents: Research β Learn β Report β Edit β Analyze (stock/crypto/copywriter/evaluator)
- π A2A Orchestration: MCP server coordinates parallel agents (research+stockβreport)
- π Full Observability: Arize/Phoenix traces + 10+ custom scorers (diversity/quality/completeness)
- π‘οΈ Enterprise Security: JWT auth, RBAC, path validation, HTML sanitization, secrets masking
- β‘ Extensible: Model registry (Gemini/OpenAI/Anthropic), workflows, 50+ tools
graph TB
subgraph "π MCP/A2A Client"
Client[Cursor/Claude/External Agents] --> Coord[A2A Coordinator MCP]
end
subgraph "π― AgentStack Runtime"
Coord --> Agents[25+ Agents<br/>β’ ResearchAgent<br/>β’ StockAnalysis<br/>β’ Copywriter<br/>β’ ReportAgent]
Agents --> Tools[50+ Tools<br/>β’ Polygon/Finnhub<br/>β’ SerpAPI 10+<br/>β’ PgVector RAG<br/>β’ PDFβMD]
Agents --> Workflows[ResearchβReport<br/>WeatherβActivities]
end
subgraph "ποΈ PgVector Storage"
Tools --> Embeddings[3072D Gemini<br/>HNSW/Flat Indexes]
Tools --> Postgres[Traces/Evals<br/>Memory/Threads]
end
subgraph "π Observability"
Agents --> Arize[Arize/Phoenix<br/>β’ 97% Traced<br/>β’ 10+ Scorers]
Postgres --> Arize
end
style Client fill:#e1f5fe
style Arize fill:#f3e5f5
flowchart TD
A[Docs/PDF/Web] --> B[MDocument Chunker<br/>β’ 10 Strategies<br/>β’ Metadata Extract]
B --> C[Gemini Embeddings<br/>β’ 3072D Vectors]
C --> D[PgVector Upsert<br/>β’ HNSW/Flat<br/>β’ Metadata Filter]
E[Query] --> F[Query Embed]
F --> G[Vector Search<br/>β’ Top-K + Rerank]
G --> H[Graph Traversal<br/>β’ Relations/Context]
H --> I[Answer Agent<br/>β’ Cite/Verify]
I --> J[Response + Sources]
sequenceDiagram
participant Client as MCP Client
participant Coord as A2A Coordinator
participant Research as Research Agent
participant Stock as Stock Agent
participant Report as Report Agent
Client->>Coord: coordinate_a2a_task("AAPL analysis")
Note over Coord: Parallel Orchestration
Coord->>+Research: research("AAPL fundamentals")
Coord->>+Stock: analyze("AAPL technicals")
Research->>Research: SerpAPI + PgVector RAG
Stock->>Stock: Polygon + Finnhub APIs
Research-->>-Coord: Insights + Learnings
Stock-->>-Coord: Metrics + Targets
Coord->>+Report: generate_report(rawData)
Report-->>-Coord: Markdown Report
Coord->>Client: Final Synthesized Report
- Node.js β₯20.9.0
- PostgreSQL + pgvector (for RAG/Memory)
- API Keys:
.env(Gemini/SerpAPI/Polygon/etc.)
git clone https://github.com/ssdeanx/AgentStack.git
cd AgentStack
npm cicp .env.example .env
# Add your keys (Gemini, SerpAPI, Polygon, etc.)npm run devnpm run mcp-server # http://localhost:6969/mcpnpm run build
npm run startsrc/mastra/
βββ index.ts # π― Mastra bootstrap (agents/tools/workflows/MCP)
βββ agents/ # π€ 25+ agents (research/stock/copywriter/report...)
βββ tools/ # π§ 50+ tools (financial/RAG/scrape/PDF/SerpAPI...)
βββ workflows/ # π Multi-step (researchβreport, weatherβactivities)
βββ config/ # βοΈ Models/PgVector/Logging/Auth
βββ scorers/ # π 10+ evals (diversity/quality/completeness...)
βββ mcp/ # π A2A Coordinator MCP server- New Tool:
src/mastra/tools/my-tool.tsβcreateTool({zodSchema, execute}) - New Agent:
src/mastra/agents/my-agent.tsβ Compose tools + Zod instructions - Test:
npm test(97% coverage) ornpx vitest src/mastra/tools/tests/my-tool.test.ts - Lint:
npm run lint
| Env Var | Purpose | Required |
|---|---|---|
PG_CONNECTION |
Postgres + PgVector RAG | β |
GOOGLE_GENERATIVE_AI_API_KEY |
Gemini LLM/Embeddings | β |
SERPAPI_API_KEY |
Search/News/Shopping (10+ tools) | β |
POLYGON_API_KEY |
Stock/Crypto quotes/aggs/fundamentals | β |
PHOENIX_ENDPOINT |
Arize/Phoenix tracing | Observability |
Full: .env.example + src/mastra/config/AGENTS.md
npm test # All tests
npm run coverage # LCOV report
npx vitest -t "polygon" # Filter (e.g., financial tools)- Vitest + Zod: Schema validation + mocks
- API Mocks: Financial/search tools fully mocked
- JWT Auth:
jwt-auth.tool.ts+ RBAC - Path Traversal:
validateDataPath()everywhere - HTML Sanitization: JSDOM + Cheerio (script/strip events)
- Secrets Masking:
maskSensitiveMessageData() - Rate Limiting: Built into financial APIs
Arize/Phoenix Exporters:
βββ Traces: 100% (spans/tools/agents)
βββ Scorers: 10+ (diversity/quality/task-completion)
βββ Metrics: Latency/errors/tool-calls
βββ Sampling: Always-on + ratio (30-80%)Custom Scorers: Source diversity, completeness, creativity, response quality.
| Category | Tools | Agents |
|---|---|---|
| π Search | SerpAPI (News/Trends/Shopping/Scholar/Local/Yelp) | ResearchAgent |
| π° Financial | Polygon (10+), Finnhub (6+), AlphaVantage (indicators) | StockAnalysis, CryptoAnalysis |
| π RAG | PgVector chunk/rerank/query/graph | Retrieve/Rerank/Answerer |
| π Content | PDFβMD, Web Scraper, Copywriter/Editor | CopywriterAgent, EditorAgent, ReportAgent |
| π¨ Visual | CSVβExcalidraw, SVG/XML process | csvToExcalidrawAgent, imageToCsvAgent |
| π Orchestration | A2A MCP Server | a2aCoordinatorAgent |
// src/mastra/agents/my-agent.ts
import { Agent } from '@mastra/core/agent'
export const myAgent = new Agent({
id: 'my-agent',
tools: { polygonStockQuotesTool, pgQueryTool },
instructions: 'Analyze stocks with Polygon + RAG...',
model: googleAI, // From model registry
memory: pgMemory,
})
// Auto-registers in index.ts# Start server
npm run mcp-server
# Use in Cursor/Claude
# coordinate_a2a_task({task: "AAPL analysis", agents: ["research", "stock"]})- Fork:
https://github.com/ssdeanx/AgentStack - Setup:
npm ci && npm test - Add: Tool/Agent + Zod schema + Vitest
- PR:
npm test+ coverage >95%
Guidelines:
- Zod Everywhere: Input/output schemas
- Stateless Tools: Agents orchestrate
- Mock APIs: 100% test coverage
- Trace Everything: Arize spans
- Agents Catalog: 25+ agents
- Tools Matrix: 50+ tools
- Config Guide: Setup + env vars
- MCP/A2A: Multi-agent federation
- Scorers: 10+ eval metrics
- Financial Suite: Polygon/Finnhub/AlphaVantage (β Live)
- RAG Pipeline: PgVector + rerank/graph (β Live)
- A2A MCP: Parallel orchestration (β Live)
- LangSmith/Phoenix: Eval dashboards
- Docker/Helm: K8s deploy
- OpenAI/Anthropic: Model parity
β Star ssdeanx/AgentStack π¦ Follow @ssdeanx π Docs (Coming Q1 2026)
Last updated: 2025-11-25 | v3.0.0