Framework · Mastra
Tổng quan về Mastra
Framework TypeScript tích hợp agent, workflow có thể tạm dừng và tiếp tục, memory, evals và giao diện Studio trong một package. Framework có thể tích hợp vào ứng dụng Next.js, Express hoặc Hono; phần lõi dùng giấy phép Apache-2.0, còn các thư mục ee/ dùng giấy phép enterprise.
Phù hợp nhất với: Các đội ngũ TypeScript muốn dùng một stack duy nhất cho agent, workflow, memory và evals.
Thông tin chính
- Đơn vị duy trì
- Mastra
- Ngôn ngữ
- TypeScript
- Giấy phép
- Apache-2.0 (core)
- Phiên bản mới nhất
@mastra/core 1.73.0· 1 tháng 10, 2026- Repository
- mastra-ai/mastra
- Tùy chọn chạy trên nền tảng lưu trữ
- Mastra Cloud / Mastra Platform
Bắt đầu nhanh
Cài package, thiết lập thông tin xác thực, rồi chạy agent đơn giản nhất theo tài liệu chính thức. ID model sử dụng trong tài liệu có thể chưa được bật cho tài khoản của bạn.
npm install @mastra/core@latest zod@latest typescript@latest @types/node@latest mastra@latest (or scaffold: npm create mastra@latest)// src/mastra/agents/weather-agent.ts
import { Agent } from '@mastra/core/agent'
import { weatherTool } from '../tools/weather-tool.ts'
export const weatherAgent = new Agent({
id: 'weather-agent',
name: 'Weather Agent',
instructions: `
You are a helpful weather assistant that provides accurate weather information.
Your primary function is to help users get weather details for specific locations. When responding:
- Include relevant details like humidity, wind conditions, and precipitation
- Keep responses concise but informative
Use the weatherTool to fetch current weather data.
`,
// Use a string in provider/model format, not provider:model or a provider object.
model: 'openai/gpt-5.6-sol',
tools: { weatherTool },
})
// run.mjs (after registering the agent in src/mastra/index.ts)
import { mastra } from './src/mastra/index.ts'
const agent = mastra.getAgentById('weather-agent')
const response = await agent.generate('Weather in SF')
console.log(response.text)Tính năng
| Mọi model | Có | Chuỗi định tuyến model theo định dạng provider/model |
|---|---|---|
| MCP client | Có | |
| MCP server | Có | MCPServer cung cấp agent, tool, workflow, prompt và resource |
| Đa agent | Có | Agent có thể hoạt động như tool cho các agent khác |
| Lượt chạy bền vững | Có | Tạm dừng và tiếp tục với snapshot lưu trong libSQL, Postgres và các hệ quản trị khác |
| Phê duyệt của con người | Có | suspend() và resume() thu thập thông tin đầu vào từ con người |
| Tracing | Có | Các OTel exporter gửi dữ liệu đến Langfuse, Braintrust, Datadog và LangSmith |
| Evals | Có | Scorer chạy trực tiếp với sampling hoặc chạy ngoại tuyến trong CI |
Các thay đổi gần đây
- npm create mastra hiện khởi tạo harness đa dụng với workspace, shell tool, memory và lịch chạy.
- Mastra Factory hướng đến các software factory được xây dựng bằng coding agent.