@mastra/mcp-docs-server 0.0.1-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (246) hide show
  1. package/.docs/organized/changelogs/%40mastra%2Fastra.md +302 -0
  2. package/.docs/organized/changelogs/%40mastra%2Fchroma.md +302 -0
  3. package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +302 -0
  4. package/.docs/organized/changelogs/%40mastra%2Fcomposio.md +302 -0
  5. package/.docs/organized/changelogs/%40mastra%2Fcore.md +302 -0
  6. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +302 -0
  7. package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +302 -0
  8. package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +302 -0
  9. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +302 -0
  10. package/.docs/organized/changelogs/%40mastra%2Fevals.md +302 -0
  11. package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +302 -0
  12. package/.docs/organized/changelogs/%40mastra%2Fgithub.md +302 -0
  13. package/.docs/organized/changelogs/%40mastra%2Floggers.md +302 -0
  14. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +11 -0
  15. package/.docs/organized/changelogs/%40mastra%2Fmcp.md +302 -0
  16. package/.docs/organized/changelogs/%40mastra%2Fmemory.md +302 -0
  17. package/.docs/organized/changelogs/%40mastra%2Fpg.md +302 -0
  18. package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +302 -0
  19. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +302 -0
  20. package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +302 -0
  21. package/.docs/organized/changelogs/%40mastra%2Frag.md +302 -0
  22. package/.docs/organized/changelogs/%40mastra%2Fragie.md +302 -0
  23. package/.docs/organized/changelogs/%40mastra%2Fspeech-azure.md +302 -0
  24. package/.docs/organized/changelogs/%40mastra%2Fspeech-deepgram.md +302 -0
  25. package/.docs/organized/changelogs/%40mastra%2Fspeech-elevenlabs.md +302 -0
  26. package/.docs/organized/changelogs/%40mastra%2Fspeech-google.md +302 -0
  27. package/.docs/organized/changelogs/%40mastra%2Fspeech-ibm.md +302 -0
  28. package/.docs/organized/changelogs/%40mastra%2Fspeech-murf.md +302 -0
  29. package/.docs/organized/changelogs/%40mastra%2Fspeech-openai.md +302 -0
  30. package/.docs/organized/changelogs/%40mastra%2Fspeech-playai.md +302 -0
  31. package/.docs/organized/changelogs/%40mastra%2Fspeech-replicate.md +302 -0
  32. package/.docs/organized/changelogs/%40mastra%2Fspeech-speechify.md +302 -0
  33. package/.docs/organized/changelogs/%40mastra%2Fstabilityai.md +302 -0
  34. package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +59 -0
  35. package/.docs/organized/changelogs/%40mastra%2Fupstash.md +302 -0
  36. package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +302 -0
  37. package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +302 -0
  38. package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +302 -0
  39. package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +302 -0
  40. package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +302 -0
  41. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +24 -0
  42. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +302 -0
  43. package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +302 -0
  44. package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +12 -0
  45. package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +302 -0
  46. package/.docs/organized/changelogs/create-mastra.md +302 -0
  47. package/.docs/organized/changelogs/mastra.md +302 -0
  48. package/.docs/organized/code-examples/agent.md +385 -0
  49. package/.docs/organized/code-examples/ai-sdk-useChat.md +377 -0
  50. package/.docs/organized/code-examples/assistant-ui.md +37 -0
  51. package/.docs/organized/code-examples/bird-checker-with-express.md +235 -0
  52. package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +360 -0
  53. package/.docs/organized/code-examples/bird-checker-with-nextjs.md +250 -0
  54. package/.docs/organized/code-examples/crypto-chatbot.md +96 -0
  55. package/.docs/organized/code-examples/fireworks-r1.md +159 -0
  56. package/.docs/organized/code-examples/integrations.md +184 -0
  57. package/.docs/organized/code-examples/mcp-configuration.md +341 -0
  58. package/.docs/organized/code-examples/memory-todo-agent.md +161 -0
  59. package/.docs/organized/code-examples/memory-with-context.md +167 -0
  60. package/.docs/organized/code-examples/memory-with-libsql.md +204 -0
  61. package/.docs/organized/code-examples/memory-with-pg.md +224 -0
  62. package/.docs/organized/code-examples/memory-with-upstash.md +268 -0
  63. package/.docs/organized/code-examples/quick-start.md +127 -0
  64. package/.docs/organized/code-examples/stock-price-tool.md +124 -0
  65. package/.docs/organized/code-examples/weather-agent.md +352 -0
  66. package/.docs/organized/code-examples/workflow-ai-recruiter.md +159 -0
  67. package/.docs/organized/code-examples/workflow-with-inline-steps.md +111 -0
  68. package/.docs/organized/code-examples/workflow-with-memory.md +393 -0
  69. package/.docs/organized/code-examples/workflow-with-separate-steps.md +131 -0
  70. package/.docs/raw/agents/00-overview.mdx +185 -0
  71. package/.docs/raw/agents/01-agent-memory.mdx +610 -0
  72. package/.docs/raw/agents/02-adding-tools.mdx +224 -0
  73. package/.docs/raw/agents/03-adding-voice.mdx +170 -0
  74. package/.docs/raw/deployment/deployment.mdx +156 -0
  75. package/.docs/raw/deployment/logging-and-tracing.mdx +242 -0
  76. package/.docs/raw/deployment/server.mdx +114 -0
  77. package/.docs/raw/evals/00-overview.mdx +106 -0
  78. package/.docs/raw/evals/01-supported-evals.mdx +31 -0
  79. package/.docs/raw/evals/02-custom-eval.mdx +187 -0
  80. package/.docs/raw/faq/index.mdx +63 -0
  81. package/.docs/raw/frameworks/01-next-js.mdx +238 -0
  82. package/.docs/raw/frameworks/02-ai-sdk.mdx +218 -0
  83. package/.docs/raw/getting-started/installation.mdx +436 -0
  84. package/.docs/raw/getting-started/project-structure.mdx +80 -0
  85. package/.docs/raw/guides/01-chef-michel.mdx +242 -0
  86. package/.docs/raw/guides/02-stock-agent.mdx +182 -0
  87. package/.docs/raw/guides/03-recruiter.mdx +187 -0
  88. package/.docs/raw/index.mdx +22 -0
  89. package/.docs/raw/local-dev/creating-projects.mdx +74 -0
  90. package/.docs/raw/local-dev/integrations.mdx +127 -0
  91. package/.docs/raw/local-dev/mastra-dev.mdx +65 -0
  92. package/.docs/raw/rag/chunking-and-embedding.mdx +128 -0
  93. package/.docs/raw/rag/overview.mdx +85 -0
  94. package/.docs/raw/rag/retrieval.mdx +362 -0
  95. package/.docs/raw/rag/vector-databases.mdx +271 -0
  96. package/.docs/raw/reference/agents/createTool.mdx +190 -0
  97. package/.docs/raw/reference/agents/generate.mdx +327 -0
  98. package/.docs/raw/reference/agents/getAgent.mdx +54 -0
  99. package/.docs/raw/reference/agents/stream.mdx +361 -0
  100. package/.docs/raw/reference/cli/build.mdx +48 -0
  101. package/.docs/raw/reference/cli/deploy.mdx +22 -0
  102. package/.docs/raw/reference/cli/dev.mdx +97 -0
  103. package/.docs/raw/reference/cli/init.mdx +43 -0
  104. package/.docs/raw/reference/client-js/agents.mdx +90 -0
  105. package/.docs/raw/reference/client-js/error-handling.mdx +38 -0
  106. package/.docs/raw/reference/client-js/index.mdx +127 -0
  107. package/.docs/raw/reference/client-js/logs.mdx +24 -0
  108. package/.docs/raw/reference/client-js/memory.mdx +94 -0
  109. package/.docs/raw/reference/client-js/telemetry.mdx +20 -0
  110. package/.docs/raw/reference/client-js/tools.mdx +44 -0
  111. package/.docs/raw/reference/client-js/vectors.mdx +79 -0
  112. package/.docs/raw/reference/client-js/workflows.mdx +137 -0
  113. package/.docs/raw/reference/core/mastra-class.mdx +232 -0
  114. package/.docs/raw/reference/deployer/cloudflare.mdx +176 -0
  115. package/.docs/raw/reference/deployer/deployer.mdx +159 -0
  116. package/.docs/raw/reference/deployer/netlify.mdx +88 -0
  117. package/.docs/raw/reference/deployer/vercel.mdx +97 -0
  118. package/.docs/raw/reference/evals/answer-relevancy.mdx +186 -0
  119. package/.docs/raw/reference/evals/bias.mdx +186 -0
  120. package/.docs/raw/reference/evals/completeness.mdx +174 -0
  121. package/.docs/raw/reference/evals/content-similarity.mdx +183 -0
  122. package/.docs/raw/reference/evals/context-position.mdx +190 -0
  123. package/.docs/raw/reference/evals/context-precision.mdx +189 -0
  124. package/.docs/raw/reference/evals/context-relevancy.mdx +188 -0
  125. package/.docs/raw/reference/evals/contextual-recall.mdx +191 -0
  126. package/.docs/raw/reference/evals/faithfulness.mdx +193 -0
  127. package/.docs/raw/reference/evals/hallucination.mdx +219 -0
  128. package/.docs/raw/reference/evals/keyword-coverage.mdx +176 -0
  129. package/.docs/raw/reference/evals/prompt-alignment.mdx +238 -0
  130. package/.docs/raw/reference/evals/summarization.mdx +205 -0
  131. package/.docs/raw/reference/evals/textual-difference.mdx +161 -0
  132. package/.docs/raw/reference/evals/tone-consistency.mdx +181 -0
  133. package/.docs/raw/reference/evals/toxicity.mdx +165 -0
  134. package/.docs/raw/reference/index.mdx +8 -0
  135. package/.docs/raw/reference/memory/Memory.mdx +186 -0
  136. package/.docs/raw/reference/memory/createThread.mdx +93 -0
  137. package/.docs/raw/reference/memory/getThreadById.mdx +43 -0
  138. package/.docs/raw/reference/memory/getThreadsByResourceId.mdx +45 -0
  139. package/.docs/raw/reference/memory/query.mdx +164 -0
  140. package/.docs/raw/reference/observability/create-logger.mdx +106 -0
  141. package/.docs/raw/reference/observability/logger.mdx +55 -0
  142. package/.docs/raw/reference/observability/otel-config.mdx +120 -0
  143. package/.docs/raw/reference/observability/providers/braintrust.mdx +40 -0
  144. package/.docs/raw/reference/observability/providers/index.mdx +15 -0
  145. package/.docs/raw/reference/observability/providers/laminar.mdx +41 -0
  146. package/.docs/raw/reference/observability/providers/langfuse.mdx +51 -0
  147. package/.docs/raw/reference/observability/providers/langsmith.mdx +46 -0
  148. package/.docs/raw/reference/observability/providers/langwatch.mdx +45 -0
  149. package/.docs/raw/reference/observability/providers/new-relic.mdx +40 -0
  150. package/.docs/raw/reference/observability/providers/signoz.mdx +40 -0
  151. package/.docs/raw/reference/observability/providers/traceloop.mdx +40 -0
  152. package/.docs/raw/reference/rag/astra.mdx +258 -0
  153. package/.docs/raw/reference/rag/chroma.mdx +281 -0
  154. package/.docs/raw/reference/rag/chunk.mdx +237 -0
  155. package/.docs/raw/reference/rag/document.mdx +129 -0
  156. package/.docs/raw/reference/rag/embeddings.mdx +160 -0
  157. package/.docs/raw/reference/rag/extract-params.mdx +72 -0
  158. package/.docs/raw/reference/rag/graph-rag.mdx +182 -0
  159. package/.docs/raw/reference/rag/libsql.mdx +357 -0
  160. package/.docs/raw/reference/rag/metadata-filters.mdx +298 -0
  161. package/.docs/raw/reference/rag/pg.mdx +477 -0
  162. package/.docs/raw/reference/rag/pinecone.mdx +249 -0
  163. package/.docs/raw/reference/rag/qdrant.mdx +236 -0
  164. package/.docs/raw/reference/rag/rerank.mdx +212 -0
  165. package/.docs/raw/reference/rag/turbopuffer.mdx +249 -0
  166. package/.docs/raw/reference/rag/upstash.mdx +198 -0
  167. package/.docs/raw/reference/rag/vectorize.mdx +253 -0
  168. package/.docs/raw/reference/storage/libsql.mdx +74 -0
  169. package/.docs/raw/reference/storage/postgresql.mdx +48 -0
  170. package/.docs/raw/reference/storage/upstash.mdx +86 -0
  171. package/.docs/raw/reference/tools/client.mdx +180 -0
  172. package/.docs/raw/reference/tools/document-chunker-tool.mdx +141 -0
  173. package/.docs/raw/reference/tools/graph-rag-tool.mdx +154 -0
  174. package/.docs/raw/reference/tools/mcp-configuration.mdx +206 -0
  175. package/.docs/raw/reference/tools/vector-query-tool.mdx +212 -0
  176. package/.docs/raw/reference/voice/composite-voice.mdx +140 -0
  177. package/.docs/raw/reference/voice/deepgram.mdx +164 -0
  178. package/.docs/raw/reference/voice/elevenlabs.mdx +216 -0
  179. package/.docs/raw/reference/voice/google.mdx +198 -0
  180. package/.docs/raw/reference/voice/mastra-voice.mdx +394 -0
  181. package/.docs/raw/reference/voice/murf.mdx +251 -0
  182. package/.docs/raw/reference/voice/openai-realtime.mdx +431 -0
  183. package/.docs/raw/reference/voice/openai.mdx +168 -0
  184. package/.docs/raw/reference/voice/playai.mdx +159 -0
  185. package/.docs/raw/reference/voice/speechify.mdx +145 -0
  186. package/.docs/raw/reference/workflows/after.mdx +88 -0
  187. package/.docs/raw/reference/workflows/commit.mdx +37 -0
  188. package/.docs/raw/reference/workflows/createRun.mdx +77 -0
  189. package/.docs/raw/reference/workflows/else.mdx +72 -0
  190. package/.docs/raw/reference/workflows/execute.mdx +110 -0
  191. package/.docs/raw/reference/workflows/if.mdx +107 -0
  192. package/.docs/raw/reference/workflows/resume.mdx +155 -0
  193. package/.docs/raw/reference/workflows/start.mdx +84 -0
  194. package/.docs/raw/reference/workflows/step-class.mdx +100 -0
  195. package/.docs/raw/reference/workflows/step-condition.mdx +134 -0
  196. package/.docs/raw/reference/workflows/step-function.mdx +92 -0
  197. package/.docs/raw/reference/workflows/step-options.mdx +69 -0
  198. package/.docs/raw/reference/workflows/suspend.mdx +80 -0
  199. package/.docs/raw/reference/workflows/then.mdx +74 -0
  200. package/.docs/raw/reference/workflows/until.mdx +165 -0
  201. package/.docs/raw/reference/workflows/watch.mdx +118 -0
  202. package/.docs/raw/reference/workflows/while.mdx +168 -0
  203. package/.docs/raw/reference/workflows/workflow.mdx +233 -0
  204. package/.docs/raw/workflows/00-overview.mdx +168 -0
  205. package/.docs/raw/workflows/control-flow.mdx +712 -0
  206. package/.docs/raw/workflows/dynamic-workflows.mdx +232 -0
  207. package/.docs/raw/workflows/steps.mdx +98 -0
  208. package/.docs/raw/workflows/suspend-and-resume.mdx +196 -0
  209. package/.docs/raw/workflows/variables.mdx +248 -0
  210. package/LICENSE +44 -0
  211. package/README.md +129 -0
  212. package/dist/index.d.ts +3 -0
  213. package/dist/index.js +19 -0
  214. package/dist/prepare-docs/code-examples.d.ts +4 -0
  215. package/dist/prepare-docs/code-examples.js +91 -0
  216. package/dist/prepare-docs/copy-raw.d.ts +1 -0
  217. package/dist/prepare-docs/copy-raw.js +41 -0
  218. package/dist/prepare-docs/index.d.ts +1 -0
  219. package/dist/prepare-docs/index.js +8 -0
  220. package/dist/prepare-docs/package-changes.d.ts +4 -0
  221. package/dist/prepare-docs/package-changes.js +92 -0
  222. package/dist/prepare-docs/prepare.d.ts +1 -0
  223. package/dist/prepare-docs/prepare.js +13 -0
  224. package/dist/sse.d.ts +1 -0
  225. package/dist/sse.js +9 -0
  226. package/dist/stdio.d.ts +1 -0
  227. package/dist/stdio.js +8 -0
  228. package/dist/tools/__tests__/blog.test.d.ts +1 -0
  229. package/dist/tools/__tests__/blog.test.js +48 -0
  230. package/dist/tools/__tests__/changes.test.d.ts +1 -0
  231. package/dist/tools/__tests__/changes.test.js +36 -0
  232. package/dist/tools/__tests__/docs.test.d.ts +1 -0
  233. package/dist/tools/__tests__/docs.test.js +46 -0
  234. package/dist/tools/__tests__/examples.test.d.ts +1 -0
  235. package/dist/tools/__tests__/examples.test.js +52 -0
  236. package/dist/tools/blog.d.ts +15 -0
  237. package/dist/tools/blog.js +73 -0
  238. package/dist/tools/changes.d.ts +11 -0
  239. package/dist/tools/changes.js +69 -0
  240. package/dist/tools/docs.d.ts +11 -0
  241. package/dist/tools/docs.js +176 -0
  242. package/dist/tools/examples.d.ts +11 -0
  243. package/dist/tools/examples.js +61 -0
  244. package/dist/utils.d.ts +6 -0
  245. package/dist/utils.js +9 -0
  246. package/package.json +66 -0
@@ -0,0 +1,232 @@
1
+ ---
2
+ title: "Mastra Core"
3
+ description: Documentation for the Mastra Class, the core entry point for managing agents, workflows, and server endpoints.
4
+ ---
5
+
6
+ # The Mastra Class
7
+
8
+ The Mastra class is the core entry point for your application. It manages agents, workflows, and server endpoints.
9
+
10
+ ## Constructor Options
11
+
12
+ <PropertiesTable
13
+ content={[
14
+ {
15
+ name: "agents",
16
+ type: "Agent[]",
17
+ description: "Array of Agent instances to register",
18
+ isOptional: true,
19
+ defaultValue: "[]",
20
+ },
21
+ {
22
+ name: "tools",
23
+ type: "Record<string, ToolApi>",
24
+ description:
25
+ "Custom tools to register. Structured as a key-value pair, with keys being the tool name and values being the tool function.",
26
+ isOptional: true,
27
+ defaultValue: "{}",
28
+ },
29
+ {
30
+ name: "storage",
31
+ type: "MastraStorage",
32
+ description: "Storage engine instance for persisting data",
33
+ isOptional: true,
34
+ },
35
+ {
36
+ name: "vectors",
37
+ type: "Record<string, MastraVector>",
38
+ description:
39
+ "Vector store instance, used for semantic search and vector-based tools (eg Pinecone, PgVector or Qdrant)",
40
+ isOptional: true,
41
+ },
42
+ {
43
+ name: "logger",
44
+ type: "Logger",
45
+ description: "Logger instance created with createLogger()",
46
+ isOptional: true,
47
+ defaultValue: "Console logger with INFO level",
48
+ },
49
+ {
50
+ name: "workflows",
51
+ type: "Record<string, Workflow>",
52
+ description: "Workflows to register. Structured as a key-value pair, with keys being the workflow name and values being the workflow instance.",
53
+ isOptional: true,
54
+ defaultValue: "{}",
55
+ },
56
+ {
57
+ name: "serverMiddleware",
58
+ type: "Array<{ handler: (c: any, next: () => Promise<void>) => Promise<Response | void>; path?: string; }>",
59
+ description: "Server middleware functions to be applied to API routes. Each middleware can specify a path pattern (defaults to '/api/*').",
60
+ isOptional: true,
61
+ defaultValue: "[]",
62
+ },
63
+ ]}
64
+ />
65
+
66
+ ## Initialization
67
+
68
+ The Mastra class is typically initialized in your `src/mastra/index.ts` file:
69
+
70
+ ```typescript copy filename=src/mastra/index.ts
71
+ import { Mastra } from "@mastra/core";
72
+ import { createLogger } from "@mastra/core/logger";
73
+
74
+ // Basic initialization
75
+ export const mastra = new Mastra({});
76
+
77
+ // Full initialization with all options
78
+ export const mastra = new Mastra({
79
+ agents: {},
80
+ workflows: [],
81
+ integrations: [],
82
+ logger: createLogger({
83
+ name: "My Project",
84
+ level: "info",
85
+ }),
86
+ storage: {},
87
+ tools: {},
88
+ vectors: {},
89
+ });
90
+ ```
91
+
92
+ You can think of the `Mastra` class as a top-level registry. When you register tools with Mastra, your registered agents and workflows can use them. When you register integrations with Mastra, agents, workflows, and tools can use them.
93
+
94
+ ## Methods
95
+
96
+ <PropertiesTable
97
+ content={[
98
+ {
99
+ name: "getAgent(name)",
100
+ type: "Agent",
101
+ description:
102
+ "Returns an agent instance by id. Throws if agent not found.",
103
+ example: 'const agent = mastra.getAgent("agentOne");',
104
+ },
105
+ {
106
+ name: "getAgents()",
107
+ type: "Record<string, Agent>",
108
+ description:
109
+ "Returns all registered agents as a key-value object.",
110
+ example: 'const agents = mastra.getAgents();',
111
+ },
112
+ {
113
+ name: "getWorkflow(id, { serialized })",
114
+ type: "Workflow",
115
+ description:
116
+ "Returns a workflow instance by id. The serialized option (default: false) returns a simplified representation with just the name.",
117
+ example: 'const workflow = mastra.getWorkflow("myWorkflow");',
118
+ },
119
+ {
120
+ name: "getWorkflows({ serialized })",
121
+ type: "Record<string, Workflow>",
122
+ description:
123
+ "Returns all registered workflows. The serialized option (default: false) returns simplified representations.",
124
+ example: 'const workflows = mastra.getWorkflows();',
125
+ },
126
+ {
127
+ name: "getVector(name)",
128
+ type: "MastraVector",
129
+ description:
130
+ "Returns a vector store instance by name. Throws if not found.",
131
+ example: 'const vectorStore = mastra.getVector("myVectorStore");',
132
+ },
133
+ {
134
+ name: "getVectors()",
135
+ type: "Record<string, MastraVector>",
136
+ description:
137
+ "Returns all registered vector stores as a key-value object.",
138
+ example: 'const vectorStores = mastra.getVectors();',
139
+ },
140
+ {
141
+ name: "getDeployer()",
142
+ type: "MastraDeployer | undefined",
143
+ description:
144
+ "Returns the configured deployer instance, if any.",
145
+ example: 'const deployer = mastra.getDeployer();',
146
+ },
147
+ {
148
+ name: "getStorage()",
149
+ type: "MastraStorage | undefined",
150
+ description:
151
+ "Returns the configured storage instance.",
152
+ example: 'const storage = mastra.getStorage();',
153
+ },
154
+ {
155
+ name: "getMemory()",
156
+ type: "MastraMemory | undefined",
157
+ description:
158
+ "Returns the configured memory instance. Note: This is deprecated, memory should be added to agents directly.",
159
+ example: 'const memory = mastra.getMemory();',
160
+ },
161
+ {
162
+ name: "getServerMiddleware()",
163
+ type: "Array<{ handler: Function; path: string; }>",
164
+ description:
165
+ "Returns the configured server middleware functions.",
166
+ example: 'const middleware = mastra.getServerMiddleware();',
167
+ },
168
+ {
169
+ name: "setStorage(storage)",
170
+ type: "void",
171
+ description:
172
+ "Sets the storage instance for the Mastra instance.",
173
+ example: 'mastra.setStorage(new DefaultStorage());',
174
+ },
175
+ {
176
+ name: "setLogger({ logger })",
177
+ type: "void",
178
+ description:
179
+ "Sets the logger for all components (agents, workflows, etc.).",
180
+ example: 'mastra.setLogger({ logger: createLogger({ name: "MyLogger" }) });',
181
+ },
182
+ {
183
+ name: "setTelemetry(telemetry)",
184
+ type: "void",
185
+ description:
186
+ "Sets the telemetry configuration for all components.",
187
+ example: 'mastra.setTelemetry({ export: { type: "console" } });',
188
+ },
189
+ {
190
+ name: "getLogger()",
191
+ type: "Logger",
192
+ description:
193
+ "Gets the configured logger instance.",
194
+ example: 'const logger = mastra.getLogger();',
195
+ },
196
+ {
197
+ name: "getTelemetry()",
198
+ type: "Telemetry | undefined",
199
+ description:
200
+ "Gets the configured telemetry instance.",
201
+ example: 'const telemetry = mastra.getTelemetry();',
202
+ },
203
+ {
204
+ name: "getLogsByRunId({ runId, transportId })",
205
+ type: "Promise<any>",
206
+ description:
207
+ "Retrieves logs for a specific run ID and transport ID.",
208
+ example: 'const logs = await mastra.getLogsByRunId({ runId: "123", transportId: "456" });',
209
+ },
210
+ {
211
+ name: "getLogs(transportId)",
212
+ type: "Promise<any>",
213
+ description:
214
+ "Retrieves all logs for a specific transport ID.",
215
+ example: 'const logs = await mastra.getLogs("transportId");',
216
+ },
217
+ ]}
218
+ />
219
+
220
+ ## Error Handling
221
+
222
+ The Mastra class methods throw typed errors that can be caught:
223
+
224
+ ```typescript copy
225
+ try {
226
+ const tool = mastra.getTool("nonexistentTool");
227
+ } catch (error) {
228
+ if (error instanceof Error) {
229
+ console.log(error.message); // "Tool with name nonexistentTool not found"
230
+ }
231
+ }
232
+ ```
@@ -0,0 +1,176 @@
1
+ ---
2
+ title: "Cloudflare Deployer"
3
+ description: "Documentation for the CloudflareDeployer class, which deploys Mastra applications to Cloudflare Workers."
4
+ ---
5
+
6
+ # CloudflareDeployer
7
+
8
+ The CloudflareDeployer deploys Mastra applications to Cloudflare Workers, handling configuration, environment variables, and route management. It extends the abstract Deployer class to provide Cloudflare-specific deployment functionality.
9
+
10
+ ## Usage Example
11
+
12
+ ```typescript
13
+ import { Mastra } from '@mastra/core';
14
+ import { CloudflareDeployer } from '@mastra/deployer-cloudflare';
15
+
16
+ const mastra = new Mastra({
17
+ deployer: new CloudflareDeployer({
18
+ scope: 'your-account-id',
19
+ projectName: 'your-project-name',
20
+ routes: [
21
+ {
22
+ pattern: 'example.com/*',
23
+ zone_name: 'example.com',
24
+ custom_domain: true,
25
+ },
26
+ ],
27
+ workerNamespace: 'your-namespace',
28
+ auth: {
29
+ apiToken: 'your-api-token',
30
+ apiEmail: 'your-email',
31
+ },
32
+ }),
33
+ // ... other Mastra configuration options
34
+ });
35
+ ```
36
+
37
+ ## Parameters
38
+
39
+ ### Constructor Parameters
40
+
41
+ <PropertiesTable
42
+ content={[
43
+ {
44
+ name: "scope",
45
+ type: "string",
46
+ description: "Your Cloudflare account ID.",
47
+ isOptional: false,
48
+ },
49
+ {
50
+ name: "projectName",
51
+ type: "string",
52
+ description: "Name of your worker project.",
53
+ isOptional: true,
54
+ defaultValue: "'mastra'",
55
+ },
56
+ {
57
+ name: "routes",
58
+ type: "CFRoute[]",
59
+ description: "Array of route configurations for your worker.",
60
+ isOptional: true,
61
+ },
62
+ {
63
+ name: "workerNamespace",
64
+ type: "string",
65
+ description: "Namespace for your worker.",
66
+ isOptional: true,
67
+ },
68
+ {
69
+ name: "env",
70
+ type: "Record<string, any>",
71
+ description: "Environment variables to be included in the worker configuration.",
72
+ isOptional: true,
73
+ },
74
+ {
75
+ name: "auth",
76
+ type: "object",
77
+ description: "Cloudflare authentication details.",
78
+ isOptional: false,
79
+ },
80
+ ]}
81
+ />
82
+
83
+ ### auth Object
84
+
85
+ <PropertiesTable
86
+ content={[
87
+ {
88
+ name: "apiToken",
89
+ type: "string",
90
+ description: "Your Cloudflare API token.",
91
+ isOptional: false,
92
+ },
93
+ {
94
+ name: "apiEmail",
95
+ type: "string",
96
+ description: "Your Cloudflare account email.",
97
+ isOptional: true,
98
+ },
99
+ ]}
100
+ />
101
+
102
+ ### CFRoute Object
103
+
104
+ <PropertiesTable
105
+ content={[
106
+ {
107
+ name: "pattern",
108
+ type: "string",
109
+ description: "URL pattern to match (e.g., 'example.com/*').",
110
+ isOptional: false,
111
+ },
112
+ {
113
+ name: "zone_name",
114
+ type: "string",
115
+ description: "Domain zone name.",
116
+ isOptional: false,
117
+ },
118
+ {
119
+ name: "custom_domain",
120
+ type: "boolean",
121
+ description: "Whether to use a custom domain.",
122
+ isOptional: true,
123
+ defaultValue: "false",
124
+ },
125
+ ]}
126
+ />
127
+
128
+ ### Wrangler Configuration
129
+
130
+ The CloudflareDeployer automatically generates a `wrangler.json` configuration file with the following settings:
131
+
132
+ ```json
133
+ {
134
+ "name": "your-project-name",
135
+ "main": "./output/index.mjs",
136
+ "compatibility_date": "2024-12-02",
137
+ "compatibility_flags": ["nodejs_compat"],
138
+ "observability": {
139
+ "logs": {
140
+ "enabled": true
141
+ }
142
+ },
143
+ "vars": {
144
+ // Environment variables from .env files and configuration
145
+ },
146
+ "routes": [
147
+ // Route configurations if specified
148
+ ]
149
+ }
150
+ ```
151
+
152
+ ### Route Configuration
153
+
154
+ Routes can be configured to direct traffic to your worker based on URL patterns and domains:
155
+
156
+ ```typescript
157
+ const routes = [
158
+ {
159
+ pattern: 'api.example.com/*',
160
+ zone_name: 'example.com',
161
+ custom_domain: true,
162
+ },
163
+ {
164
+ pattern: 'example.com/api/*',
165
+ zone_name: 'example.com',
166
+ },
167
+ ];
168
+ ```
169
+
170
+ ### Environment Variables
171
+
172
+ The CloudflareDeployer handles environment variables from multiple sources:
173
+
174
+ 1. **Environment Files**: Variables from `.env.production` and `.env` files.
175
+ 2. **Configuration**: Variables passed through the `env` parameter.
176
+
@@ -0,0 +1,159 @@
1
+ ---
2
+ title: "Mastra Deployer"
3
+ description: Documentation for the Deployer abstract class, which handles packaging and deployment of Mastra applications.
4
+ ---
5
+
6
+ # Deployer
7
+
8
+ The Deployer handles the deployment of Mastra applications by packaging code, managing environment files, and serving applications using the Hono framework. Concrete implementations must define the deploy method for specific deployment targets.
9
+
10
+ ## Usage Example
11
+
12
+ ```typescript
13
+ import { Deployer } from "@mastra/deployer";
14
+
15
+ // Create a custom deployer by extending the abstract Deployer class
16
+ class CustomDeployer extends Deployer {
17
+ constructor() {
18
+ super({ name: 'custom-deployer' });
19
+ }
20
+
21
+ // Implement the abstract deploy method
22
+ async deploy(outputDirectory: string): Promise<void> {
23
+ // Prepare the output directory
24
+ await this.prepare(outputDirectory);
25
+
26
+ // Bundle the application
27
+ await this._bundle('server.ts', 'mastra.ts', outputDirectory);
28
+
29
+ // Custom deployment logic
30
+ // ...
31
+ }
32
+ }
33
+ ```
34
+
35
+ ## Parameters
36
+
37
+ ### Constructor Parameters
38
+
39
+ <PropertiesTable
40
+ content={[
41
+ {
42
+ name: "args",
43
+ type: "object",
44
+ description: "Configuration options for the Deployer.",
45
+ isOptional: false,
46
+ },
47
+ {
48
+ name: "args.name",
49
+ type: "string",
50
+ description: "A unique name for the deployer instance.",
51
+ isOptional: false,
52
+ },
53
+ ]}
54
+ />
55
+
56
+ ### deploy Parameters
57
+
58
+ <PropertiesTable
59
+ content={[
60
+ {
61
+ name: "outputDirectory",
62
+ type: "string",
63
+ description: "The directory where the bundled and deployment-ready application will be output.",
64
+ isOptional: false,
65
+ },
66
+ ]}
67
+ />
68
+
69
+ ## Methods
70
+
71
+ <PropertiesTable
72
+ content={[
73
+ {
74
+ name: "getEnvFiles",
75
+ type: "() => Promise<string[]>",
76
+ description: "Returns a list of environment files to be used during deployment. By default, it looks for '.env.production' and '.env' files.",
77
+ },
78
+ {
79
+ name: "deploy",
80
+ type: "(outputDirectory: string) => Promise<void>",
81
+ description: "Abstract method that must be implemented by subclasses. Handles the deployment process to the specified output directory.",
82
+ },
83
+ ]}
84
+ />
85
+
86
+ ## Inherited Methods from Bundler
87
+
88
+ The Deployer class inherits the following key methods from the Bundler class:
89
+
90
+ <PropertiesTable
91
+ content={[
92
+ {
93
+ name: "prepare",
94
+ type: "(outputDirectory: string) => Promise<void>",
95
+ description: "Prepares the output directory by cleaning it and creating necessary subdirectories.",
96
+ },
97
+ {
98
+ name: "writeInstrumentationFile",
99
+ type: "(outputDirectory: string) => Promise<void>",
100
+ description: "Writes an instrumentation file to the output directory for telemetry purposes.",
101
+ },
102
+ {
103
+ name: "writePackageJson",
104
+ type: "(outputDirectory: string, dependencies: Map<string, string>) => Promise<void>",
105
+ description: "Generates a package.json file in the output directory with the specified dependencies.",
106
+ },
107
+ {
108
+ name: "_bundle",
109
+ type: "(serverFile: string, mastraEntryFile: string, outputDirectory: string, bundleLocation?: string) => Promise<void>",
110
+ description: "Bundles the application using the specified server and Mastra entry files.",
111
+ },
112
+ ]}
113
+ />
114
+
115
+ ## Core Concepts
116
+
117
+ ### Deployment Lifecycle
118
+
119
+ The Deployer abstract class implements a structured deployment lifecycle:
120
+
121
+ 1. **Initialization**: The deployer is initialized with a name and creates a Deps instance for dependency management.
122
+ 2. **Environment Setup**: The `getEnvFiles` method identifies environment files (.env.production, .env) to be used during deployment.
123
+ 3. **Preparation**: The `prepare` method (inherited from Bundler) cleans the output directory and creates necessary subdirectories.
124
+ 4. **Bundling**: The `_bundle` method (inherited from Bundler) packages the application code and its dependencies.
125
+ 5. **Deployment**: The abstract `deploy` method is implemented by subclasses to handle the actual deployment process.
126
+
127
+ ### Environment File Management
128
+
129
+ The Deployer class includes built-in support for environment file management through the `getEnvFiles` method. This method:
130
+
131
+ - Looks for environment files in a predefined order (.env.production, .env)
132
+ - Uses the FileService to find the first existing file
133
+ - Returns an array of found environment files
134
+ - Returns an empty array if no environment files are found
135
+
136
+ ```typescript
137
+ getEnvFiles(): Promise<string[]> {
138
+ const possibleFiles = ['.env.production', '.env.local', '.env'];
139
+
140
+ try {
141
+ const fileService = new FileService();
142
+ const envFile = fileService.getFirstExistingFile(possibleFiles);
143
+
144
+ return Promise.resolve([envFile]);
145
+ } catch {}
146
+
147
+ return Promise.resolve([]);
148
+ }
149
+ ```
150
+
151
+ ### Bundling and Deployment Relationship
152
+
153
+ The Deployer class extends the Bundler class, establishing a clear relationship between bundling and deployment:
154
+
155
+ 1. **Bundling as a Prerequisite**: Bundling is a prerequisite step for deployment, where the application code is packaged into a deployable format.
156
+ 2. **Shared Infrastructure**: Both bundling and deployment share common infrastructure like dependency management and file system operations.
157
+ 3. **Specialized Deployment Logic**: While bundling focuses on code packaging, deployment adds environment-specific logic for deploying the bundled code.
158
+ 4. **Extensibility**: The abstract `deploy` method allows for creating specialized deployers for different target environments.
159
+
@@ -0,0 +1,88 @@
1
+ ---
2
+ title: "Netlify Deployer"
3
+ description: "Documentation for the NetlifyDeployer class, which deploys Mastra applications to Netlify Functions."
4
+ ---
5
+
6
+ # NetlifyDeployer
7
+
8
+ The NetlifyDeployer deploys Mastra applications to Netlify Functions, handling site creation, configuration, and deployment processes. It extends the abstract Deployer class to provide Netlify-specific deployment functionality.
9
+
10
+ ## Usage Example
11
+
12
+ ```typescript
13
+ import { Mastra } from '@mastra/core';
14
+ import { NetlifyDeployer } from '@mastra/deployer-netlify';
15
+
16
+ const mastra = new Mastra({
17
+ deployer: new NetlifyDeployer({
18
+ scope: 'your-team-slug',
19
+ projectName: 'your-project-name',
20
+ token: 'your-netlify-token'
21
+ }),
22
+ // ... other Mastra configuration options
23
+ });
24
+ ```
25
+
26
+ ## Parameters
27
+
28
+ ### Constructor Parameters
29
+
30
+ <PropertiesTable
31
+ content={[
32
+ {
33
+ name: "scope",
34
+ type: "string",
35
+ description: "Your Netlify team slug or ID.",
36
+ isOptional: false,
37
+ },
38
+ {
39
+ name: "projectName",
40
+ type: "string",
41
+ description: "Name of your Netlify site (will be created if it doesn't exist).",
42
+ isOptional: false,
43
+ },
44
+ {
45
+ name: "token",
46
+ type: "string",
47
+ description: "Your Netlify authentication token.",
48
+ isOptional: false,
49
+ },
50
+ ]}
51
+ />
52
+
53
+ ### Netlify Configuration
54
+
55
+ The NetlifyDeployer automatically generates a `netlify.toml` configuration file with the following settings:
56
+
57
+ ```toml
58
+ [functions]
59
+ node_bundler = "esbuild"
60
+ directory = "netlify/functions"
61
+
62
+ [[redirects]]
63
+ force = true
64
+ from = "/*"
65
+ status = 200
66
+ to = "/.netlify/functions/api/:splat"
67
+ ```
68
+
69
+ ### Environment Variables
70
+
71
+ The NetlifyDeployer handles environment variables from multiple sources:
72
+
73
+ 1. **Environment Files**: Variables from `.env.production` and `.env` files.
74
+ 2. **Configuration**: Variables passed through the Mastra configuration.
75
+ 3. **Netlify Dashboard**: Variables can also be managed through Netlify's web interface.
76
+
77
+ ### Project Structure
78
+
79
+ The deployer creates the following structure in your output directory:
80
+
81
+ ```
82
+ output-directory/
83
+ ├── netlify/
84
+ │ └── functions/
85
+ │ └── api/
86
+ │ └── index.mjs # Application entry point with Hono server integration
87
+ └── netlify.toml # Deployment configuration
88
+ ```