配置
🌐 Configuration
以下参考资料涵盖了 Mastra 中所有受支持的选项。你可以通过实例化 Mastra 类 来初始化和配置 Mastra。
🌐 The following reference covers all supported options in Mastra. You initialize and configure Mastra by instantiating the Mastra class.
import { Mastra } from "@mastra/core";
export const mastra = new Mastra({
// Your options...
});
顶层选项Direct link to 顶层选项
🌐 Top-level options
agentsDirect link to agents
类型: Record<string, Agent>
按名称记录的代理实例。代理是能够使用人工智能模型、工具和内存进行决策和采取行动的自主系统。
🌐 A record of agent instances keyed by their names. Agents are autonomous systems that can make decisions and take actions using AI models, tools, and memory.
访问 Agents 文档 以了解更多信息。
🌐 Visit the Agents documentation to learn more.
import { Mastra } from "@mastra/core";
import { Agent } from "@mastra/core/agent";
export const mastra = new Mastra({
agents: {
weatherAgent: new Agent({
id: "weather-agent",
name: "Weather Agent",
instructions: "You help with weather information",
model: "openai/gpt-4o",
}),
},
});
deployerDirect link to deployer
类型: MastraDeployer
用于将应用发布到云平台的部署提供商。
🌐 Deployment provider for publishing applications to cloud platforms.
访问 部署文档 以了解更多信息。
🌐 Visit the Deployment documentation to learn more.
import { Mastra } from "@mastra/core";
import { NetlifyDeployer } from "@mastra/deployer-netlify";
export const mastra = new Mastra({
deployer: new NetlifyDeployer({
scope: "your-team",
siteId: "your-site-id",
}),
});
eventsDirect link to events
类型: Record<string, EventHandler | EventHandler[]>
内部发布/订阅系统的事件处理程序。将事件主题映射到处理函数,当事件发布到这些主题时,这些函数会被调用。
🌐 Event handlers for the internal pub/sub system. Maps event topics to handler functions that are called when events are published to those topics.
此功能由 Mastra 的工作流引擎内部使用。大多数用户无需配置此选项。
import { Mastra } from "@mastra/core";
export const mastra = new Mastra({
events: {
"my-topic": async (event) => {
console.log("Event received:", event);
},
},
});
gatewaysDirect link to gateways
类型: Record<string, MastraModelGateway>
用于访问大语言模型提供商的自定义模型路由网关。网关处理特定提供商的身份验证、URL 构建和模型解析。使用此功能可以添加对自定义或自托管大语言模型提供商的支持。
🌐 Custom model router gateways for accessing LLM providers. Gateways handle provider-specific authentication, URL construction, and model resolution. Use this to add support for custom or self-hosted LLM providers.
访问 自定义网关文档 以了解更多信息。
🌐 Visit the Custom Gateways documentation to learn more.
import { Mastra } from "@mastra/core";
import { MyPrivateGateway } from "./gateways";
export const mastra = new Mastra({
gateways: {
private: new MyPrivateGateway(),
},
});
idGeneratorDirect link to idGenerator
类型: () => string
默认: crypto.randomUUID()
用于创建唯一标识符的自定义 ID 生成器函数。
🌐 Custom ID generator function for creating unique identifiers.
这在 Mastra 内部用于为工作流运行、代理对话和其他资源创建 ID。大多数用户无需配置此选项。
🌐 This is used internally by Mastra for creating IDs for workflow runs, agent conversations, and other resources. Most users will not need to configure this option.
import { Mastra } from "@mastra/core";
import { nanoid } from "nanoid";
export const mastra = new Mastra({
idGenerator: () => nanoid(),
});
loggerDirect link to logger
类型: IMastraLogger | false
默认: ConsoleLogger 在开发环境中为 INFO 级别,生产环境中为 WARN
用于应用日志记录和调试的记录器实现。设置为 false 可完全禁用日志记录。
🌐 Logger implementation for application logging and debugging. Set to false to disable logging entirely.
访问 Logging 文档 以了解更多信息。
🌐 Visit the Logging documentation to learn more.
import { Mastra } from "@mastra/core";
import { PinoLogger } from "@mastra/loggers";
export const mastra = new Mastra({
logger: new PinoLogger({ name: "MyApp", level: "debug" }),
});
mcpServersDirect link to mcpServers
类型: Record<string, MCPServerBase>
MCP(模型上下文协议)服务器,它可以将 Mastra 工具、代理、工作流和资源暴露给兼容 MCP 的客户端。使用它可以创建你自己的 MCP 服务器,这些服务器可以被任何支持该协议的系统使用。
🌐 MCP (Model Context Protocol) servers that expose Mastra tools, agents, workflows, and resources to MCP-compatible clients. Use this to author your own MCP servers that can be consumed by any system that supports the protocol.
访问 MCP 概览 以了解更多信息。
🌐 Visit the MCP Overview to learn more.
import { Mastra } from "@mastra/core";
import { MCPServer } from "@mastra/mcp";
const mcpServer = new MCPServer({
id: "my-mcp-server",
name: "My MCP Server",
version: "1.0.0",
});
export const mastra = new Mastra({
mcpServers: {
myServer: mcpServer,
},
});
memoryDirect link to memory
类型: Record<string, MastraMemory>
一个可以被代理引用的内存实例注册表。内存通过保留过去对话中的相关信息,为代理在多次互动中提供连贯性。Mastra 支持三种类型的内存:用于最近消息的消息历史,存储用户特定持久信息的工作内存,以及根据相关性检索较早消息的语义回忆。
🌐 A registry of memory instances that can be referenced by agents. Memory gives agents coherence across interactions by retaining relevant information from past conversations. Mastra supports three types of memory: message history for recent messages, working memory for persistent user-specific details, and semantic recall for retrieving older messages based on relevance.
访问 Memory 文档 以了解更多信息。
🌐 Visit the Memory documentation to learn more.
大多数用户直接在代理上配置内存。此顶层配置用于定义可在多个代理之间共享的可重用内存实例。
🌐 Most users configure memory directly on agents. This top-level configuration is for defining reusable memory instances that can be shared across multiple agents.
import { Mastra } from "@mastra/core";
import { Memory } from "@mastra/memory";
import { LibSQLStore } from "@mastra/libsql";
export const mastra = new Mastra({
storage: new LibSQLStore({
id: "mastra-storage",
url: ":memory:",
}),
memory: {
chatMemory: new Memory({
options: {
lastMessages: 20,
},
}),
},
});
observabilityDirect link to observability
类型: ObservabilityEntrypoint
Mastra 为 AI 应用提供可观测性功能。监控大语言模型(LLM)操作,追踪代理决策,并使用能够理解 AI 特定模式的工具调试复杂工作流。追踪功能捕捉模型交互、代理执行路径、工具调用和工作流步骤。
🌐 Mastra provides observability features for AI applications. Monitor LLM operations, trace agent decisions, and debug complex workflows with tools that understand AI-specific patterns. Tracing captures model interactions, agent execution paths, tool calls, and workflow steps.
访问可观测性文档以了解更多信息。
🌐 Visit the Observability documentation to learn more.
import { Mastra } from "@mastra/core";
import { LibSQLStore } from "@mastra/libsql";
import { Observability, DefaultExporter } from "@mastra/observability";
export const mastra = new Mastra({
storage: new LibSQLStore({
id: "mastra-storage",
url: "file:./mastra.db",
}),
observability: new Observability({
configs: {
default: {
serviceName: "my-app",
exporters: [new DefaultExporter()],
},
},
}),
});
processorsDirect link to processors
类型: Record<string, Processor>
用于转换代理输入和输出的输入/输出处理器。处理器在代理执行管道的特定点运行,允许你在输入到达语言模型之前或输出返回之前进行修改。使用处理器可以添加安全防护、检测提示注入、审核内容或应用自定义业务逻辑。
🌐 Input/output processors for transforming agent inputs and outputs. Processors run at specific points in the agent's execution pipeline, allowing you to modify inputs before they reach the language model or outputs before they're returned. Use processors to add guardrails, detect prompt injection, moderate content, or apply custom business logic.
访问 处理器文档 以了解更多信息。
🌐 Visit the Processors documentation to learn more.
大多数用户直接在代理上配置处理器。此顶层配置用于定义可在多个代理之间共享的可重用处理器实例。
🌐 Most users configure processors directly on agents. This top-level configuration is for defining reusable processor instances that can be shared across multiple agents.
import { Mastra } from "@mastra/core";
import { ModerationProcessor } from "@mastra/core/processors";
export const mastra = new Mastra({
processors: {
moderation: new ModerationProcessor({
model: "openai/gpt-4.1-nano",
categories: ["hate", "harassment", "violence"],
}),
},
});
pubsubDirect link to pubsub
类型: PubSub
默认: EventEmitterPubSub
用于组件之间事件驱动通信的发布/订阅系统。由 Mastra 内部用于工作流事件处理和组件通信。
🌐 Pub/sub system for event-driven communication between components. Used internally by Mastra for workflow event processing and component communication.
此功能由Mastra内部使用。大多数用户无需配置此选项。
import { Mastra } from "@mastra/core";
import { CustomPubSub } from "./pubsub";
export const mastra = new Mastra({
pubsub: new CustomPubSub(),
});
scorersDirect link to scorers
类型: Record<string, Scorer>
评分员评估代理响应和工作流程输出的质量。他们使用模型评分、基于规则和统计的方法提供可量化的代理质量衡量指标。使用评分员来跟踪性能、比较不同方法,并识别改进的字段。
🌐 Scorers assess the quality of agent responses and workflow outputs. They provide quantifiable metrics for measuring agent quality using model-graded, rule-based, and statistical methods. Use scorers to track performance, compare approaches, and identify areas for improvement.
访问 Scorers 文档 以了解更多信息。
🌐 Visit the Scorers documentation to learn more.
大多数用户直接在代理上配置评分器。这个顶层配置用于定义可在多个代理之间共享的可重用评分器实例。
🌐 Most users configure scorers directly on agents. This top-level configuration is for defining reusable scorer instances that can be shared across multiple agents.
import { Mastra } from "@mastra/core";
import { createToxicityScorer } from "@mastra/evals/scorers/prebuilt";
export const mastra = new Mastra({
scorers: {
toxicity: createToxicityScorer({ model: "openai/gpt-4.1-nano" }),
},
});
storageDirect link to storage
类型: MastraCompositeStore
用于持久化应用数据的存储提供商。用于内存、工作流、跟踪以及其他需要持久化的组件。Mastra 支持多种数据库后端,包括 PostgreSQL、MongoDB、libSQL 等。
🌐 Storage provider for persisting application data. Used by memory, workflows, traces, and other components that require persistence. Mastra supports multiple database backends including PostgreSQL, MongoDB, libSQL, and more.
访问 存储文档 以了解更多信息。
🌐 Visit the Storage documentation to learn more.
import { Mastra } from "@mastra/core";
import { LibSQLStore } from "@mastra/libsql";
export const mastra = new Mastra({
storage: new LibSQLStore({
id: "mastra-storage",
url: "file:./mastra.db",
}),
});
toolsDirect link to tools
类型: Record<string, Tool>
工具是代理可以用来与外部系统交互的可重复使用的函数。每个工具定义了输入、输出和执行逻辑。
🌐 Tools are reusable functions that agents can use to interact with external systems. Each tool defines inputs, outputs, and execution logic.
访问 工具文档 以了解更多信息。
🌐 Visit the Tools documentation to learn more.
大多数用户直接在代理上配置工具。此顶层配置用于定义可在多个代理之间共享的可重用工具。
import { Mastra } from "@mastra/core";
import { createTool } from "@mastra/core/tools";
import { z } from "zod";
const weatherTool = createTool({
id: "get-weather",
description: "Fetches weather for a city",
inputSchema: z.object({
city: z.string(),
}),
execute: async () => {
return { temperature: 20, conditions: "Sunny" };
},
});
export const mastra = new Mastra({
tools: {
weather: weatherTool,
},
});
ttsDirect link to tts
类型: Record<string, MastraVoice>
用于语音合成功能的文本转语音提供商。注册语音提供商以使代理能够将文本响应转换为语音音频。
🌐 Text-to-speech providers for voice synthesis capabilities. Register voice providers to enable agents to convert text responses into spoken audio.
访问 Voice 文档 以了解更多信息。
🌐 Visit the Voice documentation to learn more.
大多数用户直接在代理上配置语音。此顶层配置用于定义可在多个代理之间共享的可重用语音提供商。
import { Mastra } from "@mastra/core";
import { OpenAIVoice } from "@mastra/voice-openai";
export const mastra = new Mastra({
tts: {
openai: new OpenAIVoice(),
},
});
vectorsDirect link to vectors
类型: Record<string, MastraVector>
用于语义搜索和嵌入的向量存储。用于RAG管道、相似性搜索以及其他基于嵌入的功能。Mastra支持多种向量数据库,包括Pinecone、带有pgvector的PostgreSQL、MongoDB等。
🌐 Vector stores for semantic search and embeddings. Used in RAG pipelines, similarity search, and other embedding-based features. Mastra supports multiple vector databases including Pinecone, PostgreSQL with pgvector, MongoDB, and more.
访问RAG 文档以了解更多信息。
🌐 Visit the RAG documentation to learn more.
大多数用户在构建 RAG 流程时会直接创建向量存储。这个顶层配置用于定义可以在整个应用中共享的可重复使用的向量存储实例。
import { Mastra } from "@mastra/core";
import { PineconeVector } from "@mastra/pinecone";
export const mastra = new Mastra({
vectors: {
pinecone: new PineconeVector({
id: 'pinecone-vector',
apiKey: process.env.PINECONE_API_KEY,
}),
},
});
workflowsDirect link to workflows
类型: Record<string, Workflow>
工作流定义了具有类型安全输入和输出的基于步骤的执行管道。对于涉及多个步骤且具有特定执行顺序的任务,可以使用工作流,让你控制数据在各个步骤之间的流动方式。
🌐 Workflows define step-based execution pipelines with type-safe inputs and outputs. Use workflows for tasks that involve multiple steps with a specific execution order, giving you control over how data flows between steps.
访问工作流程文档以了解更多信息。
🌐 Visit the Workflows documentation to learn more.
import { Mastra } from "@mastra/core";
import { testWorkflow } from "./workflows/test-workflow";
export const mastra = new Mastra({
workflows: {
testWorkflow,
},
});
打包器选项Direct link to 打包器选项
🌐 Bundler options
bundler.externalsDirect link to bundler.externals
类型: boolean | string[]
默认: true
mastra build 运行时,Mastra 会将你的项目打包到 .mastra/output 目录中。此选项用于控制哪些包会被排除在打包之外(标记为“外部”)并通过包管理器单独安装。当内部 Mastra 打包工具(Rollup)在打包某些包时遇到问题时,这非常有用。
🌐 When mastra build is run, Mastra bundles your project into the .mastra/output directory. This option controls which packages are excluded from the bundle (marked as "external") and installed separately through a package manager. This is useful when the internal Mastra bundler (Rollup) has trouble bundling certain packages.
默认情况下,mastra build 将此选项设置为 true。如果你将项目部署到 Mastra Cloud,它也会将此选项设置为 true。
🌐 By default, mastra build sets this option to true. If you deploy your project to Mastra Cloud, it also sets this option to true.
以下是不同数值含义的概述:
🌐 Here's an overview of what the different values mean:
true:你项目的package.json中列出的所有依赖都被标记为外部依赖false:没有依赖被标记为外部;所有内容都打包在一起string[]:要标记为外部的包名称数组,其余的将打包在一起
import { Mastra } from "@mastra/core";
export const mastra = new Mastra({
bundler: {
externals: ["some-package", "another-package"],
},
});
bundler.sourcemapDirect link to bundler.sourcemap
类型: boolean
默认: false
启用为打包输出生成源映射。
🌐 Enables source map generation for the bundled output.
import { Mastra } from "@mastra/core";
export const mastra = new Mastra({
bundler: {
sourcemap: true,
},
});
bundler.transpilePackagesDirect link to bundler.transpilePackages
类型: string[]
默认: []
在构建过程中,应该通过 esbuild 转译其源代码的软件包列表。对于包含 TypeScript 或其他需要在打包前编译的代码的依赖,请使用此选项。
🌐 List of packages whose source code should be transpiled through esbuild during the build process. Use this for dependencies that contain TypeScript or other code that needs compilation before bundling.
只有在你直接导入未编译的源代码时才需要这个选项。如果你的包已经编译成 CommonJS 或 ESM,则不需要在这里列出。
🌐 You only need this option if you're importing uncompiled source code directly. If your packages are already compiled to CommonJS or ESM, they don't need to be listed here.
Mastra 会自动检测多包仓库中的工作区包并将它们添加到此列表中,因此你通常只需要指定需要转译的外部包。
🌐 Mastra automatically detects workspace packages in monorepo setups and adds them to this list, so you typically only need to specify external packages that require transpilation.
import { Mastra } from "@mastra/core";
export const mastra = new Mastra({
bundler: {
transpilePackages: ["@my-org/shared-utils"],
},
});
服务器选项Direct link to 服务器选项
🌐 Server options
server.apiRoutesDirect link to server.apiRoutes
类型: ApiRoute[]
Mastra 会自动通过其服务器公开注册的代理和工作流。对于额外的功能,你可以定义自己的 HTTP 路由。
🌐 Mastra automatically exposes registered agents and workflows via its server. For additional behavior you can define your own HTTP routes.
访问 自定义 API 路由 文档以了解更多信息。
🌐 Visit the Custom API routes documentation to learn more.
import { Mastra } from "@mastra/core";
import { registerApiRoute } from "@mastra/core/server";
export const mastra = new Mastra({
server: {
apiRoutes: [
registerApiRoute("/my-custom-route", {
method: "GET",
handler: async (c) => {
return c.json({ message: "Custom route" });
},
}),
],
},
});
server.authDirect link to server.auth
类型: MastraAuthConfig | MastraAuthProvider
服务器的身份验证配置。Mastra 支持多种身份验证提供商,包括 JWT、Clerk、Supabase、Firebase、WorkOS 和 Auth0。
🌐 Authentication configuration for the server. Mastra supports multiple authentication providers including JWT, Clerk, Supabase, Firebase, WorkOS, and Auth0.
访问 身份验证文档 以了解更多信息。
🌐 Visit the Authentication documentation to learn more.
import { Mastra } from "@mastra/core";
import { MastraJwtAuth } from "@mastra/auth";
export const mastra = new Mastra({
server: {
auth: new MastraJwtAuth({
secret: process.env.MASTRA_JWT_SECRET,
}),
},
});
server.bodySizeLimitDirect link to server.bodySizeLimit
类型: number
默认: 4_718_592 (4.5 MB)
请求体的最大字节数。如果你的应用需要处理更大的数据,请增加此限制。
🌐 Maximum request body size in bytes. Increase this limit if your application needs to handle larger payloads.
import { Mastra } from "@mastra/core";
export const mastra = new Mastra({
server: {
bodySizeLimit: 10 * 1024 * 1024, // 10mb
},
});
server.buildDirect link to server.build
服务器功能的构建时配置。这些选项控制开发工具,如 Swagger UI 和请求日志记录,它们在本地开发期间启用,但在生产环境中默认禁用。
🌐 Build-time configuration for server features. These options control development tools like Swagger UI and request logging, which are enabled during local development but disabled in production by default.
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
swaggerUI | boolean | false | 在 /swagger-ui 启用 Swagger UI 以进行交互式 API 探索(需要 openAPIDocs 为 true) |
apiReqLogs | boolean | false | 启用在控制台记录 API 请求 |
openAPIDocs | boolean | false | 在 /openapi.json 启用 OpenAPI 规范 |
import { Mastra } from "@mastra/core";
export const mastra = new Mastra({
server: {
build: {
swaggerUI: true,
apiReqLogs: true,
openAPIDocs: true,
},
},
});
server.corsDirect link to server.cors
类型: CorsOptions | false
服务器的 CORS(跨来源资源共享)配置。设置为 false 可完全禁用 CORS。
🌐 CORS (Cross-Origin Resource Sharing) configuration for the server. Set to false to disable CORS entirely.
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
origin | string | string[] | '*' | CORS 请求的来源 |
allowMethods | string[] | ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'] | HTTP 方法 |
allowHeaders | string[] | ['Content-Type', 'Authorization', 'x-mastra-client-type'] | 请求头 |
exposeHeaders | string[] | ['Content-Length', 'X-Requested-With'] | 浏览器头 |
credentials | boolean | false | 凭证(Cookies,授权头) |
maxAge | number | 3600 | 预检请求缓存时间(秒) |
import { Mastra } from "@mastra/core";
export const mastra = new Mastra({
server: {
cors: {
origin: ["https://example.com"],
allowMethods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
allowHeaders: ["Content-Type", "Authorization"],
credentials: false,
},
},
});
server.hostDirect link to server.host
类型: string
默认: localhost
主机地址,Mastra 开发服务器绑定到该地址。
🌐 Host address the Mastra development server binds to.
import { Mastra } from "@mastra/core";
export const mastra = new Mastra({
server: {
host: "0.0.0.0",
},
});
server.httpsDirect link to server.https
类型: { key: Buffer; cert: Buffer }
用于通过 TLS 运行开发服务器的 HTTPS 配置。Mastra 支持通过 mastra dev --https 标志进行本地 HTTPS 开发,该标志会自动创建和管理证书。对于自定义证书管理,请提供你自己的密钥和证书文件:
🌐 HTTPS configuration for running the development server with TLS. Mastra supports local HTTPS development through the mastra dev --https flag, which automatically creates and manages certificates. For custom certificate management, provide your own key and certificate files:
import { Mastra } from "@mastra/core";
import fs from "node:fs";
export const mastra = new Mastra({
server: {
https: {
key: fs.readFileSync("path/to/key.pem"),
cert: fs.readFileSync("path/to/cert.pem"),
},
},
});
server.middlewareDirect link to server.middleware
类型: Middleware | Middleware[]
自定义中间件函数用于在路由处理程序之前或之后拦截请求。中间件可以用于身份验证、日志记录、注入特定请求的上下文或添加头信息。每个中间件都会接收 Hono 的 Context 和一个 next 函数。返回 Response 可以中断请求,或调用 next() 以继续处理。
🌐 Custom middleware functions to intercept requests before or after route handlers. Middleware can be used for authentication, logging, injecting request-specific context, or adding headers. Each middleware receives the Hono Context and a next function. Return a Response to short-circuit the request, or call next() to continue processing.
访问 中间件文档 以了解更多信息。
🌐 Visit the Middleware documentation to learn more.
import { Mastra } from "@mastra/core";
export const mastra = new Mastra({
server: {
middleware: [
{
handler: async (c, next) => {
const authHeader = c.req.header("Authorization");
if (!authHeader) {
return new Response("Unauthorized", { status: 401 });
}
await next();
},
path: "/api/*",
},
],
},
});
server.onErrorDirect link to server.onError
类型: (err: Error, c: Context) => Response | Promise<Response>
当发生未处理的错误时,将调用自定义错误处理程序。可以使用它来自定义错误响应,将错误记录到外部服务(如 Sentry),或实现自定义错误格式。
🌐 Custom error handler called when an unhandled error occurs. Use this to customize error responses, log errors to external services like Sentry, or implement custom error formatting.
import { Mastra } from "@mastra/core";
import * as Sentry from "@sentry/node";
export const mastra = new Mastra({
server: {
onError: (err, c) => {
Sentry.captureException(err);
return c.json({
error: err.message,
timestamp: new Date().toISOString(),
}, 500);
},
},
});
server.portDirect link to server.port
类型: number
默认: 4111(如果已设置,则使用 PORT 环境变量)
Mastra 开发服务器绑定的端口。如果设置了 PORT 环境变量,它将优先于默认值。
🌐 Port the Mastra development server binds to. If the PORT environment variable is set, it takes precedence over the default.
import { Mastra } from "@mastra/core";
export const mastra = new Mastra({
server: {
port: 8080,
},
});
server.studioBaseDirect link to server.studioBase
类型: string
默认: /
Mastra Studio 的宿主基础路径。使用此路径可以在现有应用的子路径上托管 Studio,而不是在根路径上。
🌐 Base path for hosting Mastra Studio. Use this to host the Studio on a sub-path of your existing application instead of the root.
当与现有应用集成时,使用像 Cloudflare Zero Trust 这样的身份验证工具(能够利用共享域的优势),或在单一域下管理多个服务时,这非常有用。
🌐 This is useful when integrating with existing applications, using authentication tools like Cloudflare Zero Trust that benefit from shared domains, or managing multiple services under a single domain.
import { Mastra } from "@mastra/core";
export const mastra = new Mastra({
server: {
studioBase: "/my-mastra-studio",
},
});
示例网址:
- 默认:
http://localhost:4111/(根目录下的工作室) - 使用
studioBase:http://localhost:4111/my-mastra-studio/(子路径下的工作室)
server.timeoutDirect link to server.timeout
类型: number
默认: 180000(3分钟)
请求超时(毫秒)。超过此时间的请求将被终止。
🌐 Request timeout in milliseconds. Requests that exceed this duration will be terminated.
import { Mastra } from "@mastra/core";
export const mastra = new Mastra({
server: {
timeout: 30000, // 30 seconds
},
});