Esta página se muestra en inglés. Una traducción al español está en curso.
ScriptsApr 6, 2026·2 min de lectura

Mastra — TypeScript AI Agent Framework

Production TypeScript framework for building AI agents with tool use, workflows, RAG, and memory. First-class MCP support. Deploy anywhere Node.js runs. 9,000+ GitHub stars.

Introducción

Mastra is a production-ready TypeScript framework for building AI agents with tool use, workflows, RAG pipelines, and persistent memory with 9,000+ GitHub stars. It provides first-class MCP support — connect any MCP server as a tool source — and deploys anywhere Node.js runs. Unlike Python-only agent frameworks, Mastra is built for TypeScript-first teams who want type safety, IDE autocomplete, and the npm ecosystem. Best for full-stack TypeScript developers building production AI applications. Works with: Claude, GPT-4, Gemini, any OpenAI-compatible provider. Setup time: under 3 minutes.


Core Features

Agents with Tools

import { Agent, Tool } from "@mastra/core";

const weatherTool = new Tool({
  name: "get_weather",
  description: "Get current weather for a location",
  parameters: z.object({ city: z.string() }),
  execute: async ({ city }) => {
    const res = await fetch(`https://api.weather.com/${city}`);
    return res.json();
  },
});

const agent = new Agent({
  model: "claude-sonnet-4-20250514",
  tools: [weatherTool],
});

First-Class MCP Support

import { MCPClient } from "@mastra/mcp";

const github = new MCPClient({
  command: "npx",
  args: ["-y", "@modelcontextprotocol/server-github"],
  env: { GITHUB_TOKEN: process.env.GITHUB_TOKEN },
});

const agent = new Agent({
  tools: [...github.getTools()],  // All MCP tools available
});

Workflows

Multi-step workflows with branching and error handling:

import { Workflow, Step } from "@mastra/core";

const workflow = new Workflow("deploy-pipeline")
  .step(analyzeCode)
  .step(runTests, { dependsOn: [analyzeCode] })
  .step(deploy, { dependsOn: [runTests], condition: "tests.passed" })
  .step(notify, { dependsOn: [deploy] });

await workflow.execute({ repo: "my-app" });

RAG Pipeline

import { RAG } from "@mastra/rag";

const rag = new RAG({
  embedder: "openai/text-embedding-3-small",
  vectorStore: "pinecone",
  chunker: { strategy: "recursive", size: 512 },
});

await rag.index("./docs");
const context = await rag.retrieve("How does auth work?");

Persistent Memory

const agent = new Agent({
  memory: {
    provider: "postgres",
    connectionString: process.env.DATABASE_URL,
  },
});
// Agent remembers conversations across sessions

Key Stats

  • 9,000+ GitHub stars
  • TypeScript-first (full type safety)
  • Native MCP support
  • Workflow orchestration
  • RAG + memory built-in

FAQ

Q: What is Mastra? A: Mastra is a TypeScript framework for building production AI agents with tool use, MCP integration, workflows, RAG, and persistent memory.

Q: Is Mastra free? A: Yes, fully open-source under Apache 2.0 license.

Q: How is Mastra different from LangChain.js? A: Mastra is TypeScript-native with first-class MCP support, built-in workflows, and a CLI scaffolding tool. LangChain.js is a port of the Python library.


🙏

Fuente y agradecimientos

Created by Mastra. Licensed under Apache 2.0.

mastra — ⭐ 9,000+

Thanks for giving TypeScript developers a proper AI agent framework.

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados