Skip to content

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.

Notifications You must be signed in to change notification settings

ssdeanx/AgentStack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

18 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ AgentStack

Runtime Dependencies Dev Dependencies Tests TypeScript License GitMCP

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.

GitHub @mastra/core @mastra/pg @mastra/rag @mastra/memory

@ai-sdk/google zod vitest

@mastra/arize @mastra/mcp cheerio serpapi

PgVector Gemini

🎯 Why AgentStack?

Feature AgentStack LangChain CrewAI AutoGen
Production Observability βœ… Full Arize/Phoenix tracing + custom scorers ⚠️ Partial ❌ Basic ❌ Limited
Financial Tools βœ… Polygon/Finnhub/AlphaVantage (20+ endpoints) ❌ None ❌ None ❌ None
RAG Pipeline βœ… PgVector HNSW + rerank + graphRAG ⚠️ External ❌ Basic ❌ None
Multi-Agent βœ… A2A MCP + parallel orchestration ⚠️ Sequential βœ… Sequential βœ… Custom
Governance βœ… JWT/RBAC + path traversal + HTML sanitization ❌ Custom ❌ None ❌ None
TypeScript βœ… Zod schemas everywhere ⚠️ JS/TS mix ⚠️ JS focus ❌ Python
Tests βœ… 97% Vitest coverage ⚠️ Partial ❌ Sparse ⚠️ Partial

Built for production: Secure, observable, testable agents with zero-config PgVector RAG + enterprise financial APIs.

✨ Core Capabilities

  • πŸ’° 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

πŸ—οΈ Architecture

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
Loading

πŸ”„ RAG Pipeline (Production-Grade)

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]
Loading

🀝 A2A Multi-Agent Flow

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
Loading

πŸš€ Quick Start

Prerequisites

  • Node.js β‰₯20.9.0
  • PostgreSQL + pgvector (for RAG/Memory)
  • API Keys: .env (Gemini/SerpAPI/Polygon/etc.)

Clone & Install

git clone https://github.com/ssdeanx/AgentStack.git
cd AgentStack
npm ci

Setup .env

cp .env.example .env
# Add your keys (Gemini, SerpAPI, Polygon, etc.)

Run Dev Server

npm run dev

MCP Server (A2A)

npm run mcp-server  # http://localhost:6969/mcp

Production

npm run build
npm run start

πŸ“ Structure

src/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

πŸ› οΈ Development

  1. New Tool: src/mastra/tools/my-tool.ts β†’ createTool({zodSchema, execute})
  2. New Agent: src/mastra/agents/my-agent.ts β†’ Compose tools + Zod instructions
  3. Test: npm test (97% coverage) or npx vitest src/mastra/tools/tests/my-tool.test.ts
  4. Lint: npm run lint

πŸ”§ Configuration

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

πŸ§ͺ Testing (97% Coverage)

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

πŸ”’ Security & Governance

  • 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

πŸ“Š Observability (Production-Ready)

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.

🌐 Integrations Matrix

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

πŸš€ Advanced Usage

Custom Agent

// 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

MCP/A2A Client

# Start server
npm run mcp-server

# Use in Cursor/Claude
# coordinate_a2a_task({task: "AAPL analysis", agents: ["research", "stock"]})

🀝 Contributing

  1. Fork: https://github.com/ssdeanx/AgentStack
  2. Setup: npm ci && npm test
  3. Add: Tool/Agent + Zod schema + Vitest
  4. PR: npm test + coverage >95%

Guidelines:

  • Zod Everywhere: Input/output schemas
  • Stateless Tools: Agents orchestrate
  • Mock APIs: 100% test coverage
  • Trace Everything: Arize spans

πŸ“š Resources

πŸ† Roadmap

  • 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

About

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •