Framework · Mastra
Mastra の概要
エージェント、一時停止・再開に対応したワークフロー、メモリ、評価機能、Studio UIを1つのパッケージにまとめたTypeScriptフレームワークです。Next.js、Express、Honoのアプリに組み込めます。コア部分はApache-2.0ライセンスですが、ee/ディレクトリはエンタープライズライセンスです。
おすすめの用途: エージェント、ワークフロー、メモリ、評価機能を単一のスタックにまとめたいTypeScriptチーム。
基本情報
- メンテナー
- Mastra
- 言語
- TypeScript
- ライセンス
- Apache-2.0 (core)
- 最新バージョン
@mastra/core 1.73.0· 2026年10月1日- リポジトリ
- mastra-ai/mastra
- ホスティング विकल्प
- Mastra Cloud / Mastra Platform
クイックスタート
パッケージをインストールして認証情報を設定し、公式ドキュメントにある最小構成のエージェントを実行します。モデル ID はドキュメントで使われているものです。アカウントで有効になっていない場合があります。
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)機能
| 任意のモデル | はい | provider/model形式のモデルルーター文字列に対応 |
|---|---|---|
| MCPクライアント | はい | |
| MCPサーバー | はい | MCPServerでエージェント、ツール、ワークフロー、プロンプト、リソースを公開 |
| マルチエージェント | はい | エージェントを別のエージェントのツールとして利用可能 |
| 耐久性のある実行 | はい | libSQL、Postgresなどにスナップショットを保存して一時停止・再開 |
| 人による承認 | はい | suspend()とresume()で人間からの入力を受け付け |
| トレーシング | はい | Langfuse、Braintrust、Datadog、LangSmith向けのOTelエクスポーター |
| Evals | はい | サンプリングを使った実行時評価と、CIでのオフライン評価に対応 |
最近の変更
- npm create mastraで、ワークスペース、シェルツール、メモリ、スケジュールを備えた汎用ハーネスを生成できるようになりました。
- Mastra Factoryは、コーディングエージェントで構成するソフトウェアファクトリーを対象としています。