Skills2026年4月6日·1 分钟阅读

Mastra — TypeScript AI Agent Toolkit

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.

Agent 就绪

这个资产会安全暂存

这个资产会先安全暂存。复制的指令会要求 Agent 读取暂存文件,并在激活脚本、MCP 配置或全局配置前先确认。

Stage only · 29/100策略:需暂存
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Stage only
信任
信任等级:Community
入口
Mastra — TypeScript AI Agent Framework
安全暂存命令
npx -y tokrepo@latest install 3e118616-e727-4dc7-a561-db39e91cadcd --target codex

先暂存文件;激活前需要读取暂存 README 和安装计划。

TL;DR
Mastra provides TypeScript-native AI agent building with tool use, workflows, RAG, memory, and MCP support.
§01

What it is

Mastra is a production-ready TypeScript framework for building AI agents. It provides first-class support for tool use, workflows, retrieval-augmented generation (RAG), and agent memory. Mastra integrates natively with the Model Context Protocol (MCP), letting agents connect to external services through standardized tool interfaces.

TypeScript developers building AI-powered applications who want type safety, IDE autocompletion, and a familiar Node.js deployment model will find Mastra a natural fit.

§02

How it saves time or tokens

Mastra eliminates the need to glue together separate libraries for LLM calls, tool schemas, vector search, and workflow orchestration. Everything ships in one framework with TypeScript types. The estimated token usage per session is approximately 2,800 tokens.

§03

How to use

  1. Install Mastra via npm.
  2. Define agents with tools, instructions, and model configuration.
  3. Deploy as a standard Node.js application.
import { Agent } from '@mastra/core';
import { openai } from '@mastra/openai';

const agent = new Agent({
  name: 'researcher',
  model: openai('gpt-4o'),
  instructions: 'You are a research assistant. Search and summarize findings.',
  tools: [searchTool, summarizeTool],
});

const result = await agent.generate('Find recent papers on prompt compression');
console.log(result.text);
§04

Example

A multi-step workflow that researches a topic, drafts a summary, and sends it via email:

import { Workflow } from '@mastra/core';

const researchWorkflow = new Workflow({
  name: 'research-and-report',
  steps: [
    { id: 'research', agent: researchAgent, input: '{{topic}}' },
    { id: 'draft', agent: writerAgent, input: '{{research.output}}' },
    { id: 'send', tool: emailTool, input: { body: '{{draft.output}}' } },
  ],
});
§05

Related on TokRepo

§06

Common pitfalls

  • Mastra is TypeScript-only. Python-based teams should look at LangChain or CrewAI instead.
  • MCP server compatibility depends on the server implementation. Test integrations individually.
  • Workflow error handling requires explicit try-catch or error step definitions; there is no automatic retry by default.

常见问题

How does Mastra compare to LangChain?+

LangChain supports Python and JavaScript with a broader ecosystem of integrations. Mastra is TypeScript-native with stronger type safety and a more opinionated architecture. Choose Mastra for TypeScript-first projects; choose LangChain for multi-language or Python-heavy teams.

Does Mastra support MCP?+

Yes. Mastra has first-class MCP support, meaning agents can connect to any MCP server and use its tools natively. This includes filesystem, database, GitHub, and custom MCP servers.

Can I use Mastra with local LLMs?+

Yes. Mastra supports any OpenAI-compatible API endpoint, so you can point it at Ollama, vLLM, or any local inference server that exposes a compatible API.

What deployment options does Mastra support?+

Mastra runs anywhere Node.js runs. Deploy as a standard server application, serverless function, or containerized service. There is no vendor lock-in to a specific hosting platform.

Does Mastra support RAG?+

Yes. Mastra includes built-in RAG capabilities with document loading, chunking, embedding, and vector search. It integrates with popular vector databases like Pinecone, Weaviate, and pgvector.

引用来源 (3)
  • Mastra GitHub— Mastra is a production TypeScript framework for AI agents with MCP support
  • Mastra Documentation— First-class Model Context Protocol integration for tool use
  • MCP Specification— MCP provides standardized tool interfaces for AI agents
🙏

来源与感谢

Created by Mastra. Licensed under Apache 2.0.

mastra — ⭐ 9,000+

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产