@mastra/mcp-docs-server 1.2.3-alpha.13 → 1.2.3-alpha.15

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.
@@ -103,6 +103,7 @@ The following table shows the supported file-based agent surface:
103
103
  | `agents/<name>/skills/*.ts` | Each default-exported [`createSkill()`](https://mastra.ai/reference/agents/createSkill), added to the agent `skills`. |
104
104
  | `agents/<name>/skills/<skill>/SKILL.md` | A packaged skill. Frontmatter supplies `name` and `description`, the body is the instructions, and files under `references/` are inlined. |
105
105
  | `agents/<name>/skills/<skill>.md` | A flat skill. The filename is the skill name and the body is the instructions. |
106
+ | `agents/<name>/memory.ts` | Default export: a [`Memory`](https://mastra.ai/reference/memory/memory-class) instance used as the agent `memory`. |
106
107
  | `agents/<name>/workspace.ts` | Default export: a [`Workspace`](https://mastra.ai/reference/workspace/workspace-class) for the agent. |
107
108
  | `agents/<name>/workspace/` | Seed files mirrored into the agent's default workspace at build time. |
108
109
  | `agents/<name>/subagents/<childId>/` | A declared subagent with the same layout as an agent directory. Wired into the parent as a delegation tool named `<childId>`. |
@@ -146,6 +147,18 @@ Add skills to a file-based agent by placing them under `agents/<name>/skills/`.
146
147
 
147
148
  Discovered skills merge with any `skills` in `config.ts`. On a name collision, `config.skills` wins and a warning is logged. If `config.skills` is a function, discovered skills are ignored with a warning because they can't be statically merged.
148
149
 
150
+ ## Add memory
151
+
152
+ Give a file-based agent [memory](https://mastra.ai/docs/memory/overview) by adding a `memory.ts` that default-exports a [`Memory`](https://mastra.ai/reference/memory/memory-class) instance:
153
+
154
+ ```typescript
155
+ import { Memory } from '@mastra/memory'
156
+
157
+ export default new Memory()
158
+ ```
159
+
160
+ The exported instance becomes the agent's `memory`. You can also set `memory` directly in `config.ts`. `config.memory` wins over `memory.ts`, and a warning is logged when both are present. If neither is present, the agent has no memory, which is the default.
161
+
149
162
  ## Add a workspace
150
163
 
151
164
  When a file-based agent is discovered through `mastra dev` or `mastra build`, it gets a default workspace unless `config.workspace` or `workspace.ts` supplies one. The default workspace uses a contained filesystem and shell sandbox rooted at a per-agent `workspace/` directory in the bundle.
@@ -180,7 +193,7 @@ Seed files are copied into the bundle next to the running server. Commit the sta
180
193
 
181
194
  ## Add subagents
182
195
 
183
- A file-based agent can declare **subagents**, specialist child agents it can delegate to. Add a `subagents/` directory under the agent, with one directory per subagent. Each subagent directory has the same layout as a top-level agent: `config.ts`, `instructions.md`, `tools/`, `skills/`, `workspace.ts`, and `workspace/`.
196
+ A file-based agent can declare **subagents**, specialist child agents it can delegate to. Add a `subagents/` directory under the agent, with one directory per subagent. Each subagent directory has the same layout as a top-level agent: `config.ts`, `instructions.md`, `tools/`, `skills/`, `memory.ts`, `workspace.ts`, and `workspace/`.
184
197
 
185
198
  ```text
186
199
  src/mastra/agents/
@@ -224,11 +237,12 @@ Naming rules:
224
237
  File-based and code-based agents coexist with deterministic rules:
225
238
 
226
239
  - **Code wins on name collisions:** If an agent name exists in both code and the filesystem, the code-registered agent is kept and a warning is logged.
227
- - **A folder can hold a code agent:** If `config.ts` exports `new Agent({...})`, that instance is used as-is. Sibling `instructions.md`, `tools/`, `skills/`, `workspace.ts`, and `subagents/` entries are ignored with warnings.
240
+ - **A folder can hold a code agent:** If `config.ts` exports `new Agent({...})`, that instance is used as-is. Sibling `instructions.md`, `tools/`, `skills/`, `memory.ts`, `workspace.ts`, and `subagents/` entries are ignored with warnings.
228
241
  - **Instructions:** Dynamic function instructions in `config.ts` win over `instructions.md`. Otherwise, `instructions.md` wins over a static `instructions` string. If neither is present, the build fails for that agent.
229
242
  - **Model:** A missing `model` fails the build and names the agent directory.
230
243
  - **Tools:** Tools from `tools/*.ts` merge with `config.tools`. On a key collision, `config.tools` wins and a warning is logged. If `config.tools` is a function, discovered tools are ignored with a warning.
231
244
  - **Skills:** Skills from `skills/` merge with `config.skills`. On a name collision, `config.skills` wins and a warning is logged. If `config.skills` is a function, discovered skills are ignored with a warning.
245
+ - **Memory:** `config.memory` wins over `memory.ts`, and a warning is logged when both are present. If neither is set, the agent has no memory.
232
246
  - **Workspace:** `config.workspace` wins over `workspace.ts`, which wins over the default workspace.
233
247
  - **Subagents:** Subagents from `subagents/` merge with `config.agents`. On an id collision, `config.agents` wins and a warning is logged. A subagent id that collides with a tool key, or a duplicate subagent id, is a build error.
234
248
 
@@ -261,10 +275,12 @@ export const mastra = new Mastra({
261
275
  - [Agents overview](https://mastra.ai/docs/agents/overview)
262
276
  - [Tools](https://mastra.ai/docs/agents/using-tools)
263
277
  - [Skills](https://mastra.ai/docs/agents/skills)
278
+ - [Memory](https://mastra.ai/docs/memory/overview)
264
279
  - [Supervisor agents](https://mastra.ai/docs/agents/supervisor-agents)
265
280
  - [Workspace](https://mastra.ai/docs/workspace/overview)
266
281
  - [Studio overview](https://mastra.ai/docs/studio/overview)
267
282
  - [`Agent` reference](https://mastra.ai/reference/agents/agent)
268
283
  - [`createTool()` reference](https://mastra.ai/reference/tools/create-tool)
269
284
  - [`createSkill()` reference](https://mastra.ai/reference/agents/createSkill)
285
+ - [`Memory` reference](https://mastra.ai/reference/memory/memory-class)
270
286
  - [`Workspace` reference](https://mastra.ai/reference/workspace/workspace-class)
@@ -0,0 +1,75 @@
1
+ # buildBasePrompt()
2
+
3
+ `buildBasePrompt()` builds the shared base system prompt for a coding agent — the behavioral instructions that make the agent a good coding assistant. It takes a `PromptContext` describing the current environment (project, platform, git branch, mode, model) and returns the prompt as a string.
4
+
5
+ Product-specific strings are parameterized through `productName`, `coAuthorName`, and `coAuthorEmail`, so you can rebrand the prompt and commit trailer without forking it. They default to `"Mastra Code"` / `"noreply@mastra.ai"`, so existing callers keep identical output.
6
+
7
+ Use this with [`createCodingAgent()`](https://mastra.ai/reference/coding-agent/create-coding-agent) when you build dynamic instructions for the agent.
8
+
9
+ ## Usage example
10
+
11
+ Build the base prompt from a `PromptContext`:
12
+
13
+ ```typescript
14
+ import { buildBasePrompt } from '@mastra/core/coding-agent'
15
+
16
+ const prompt = buildBasePrompt({
17
+ projectPath: process.cwd(),
18
+ projectName: 'my-app',
19
+ gitBranch: 'main',
20
+ platform: process.platform,
21
+ date: new Date().toDateString(),
22
+ mode: 'build',
23
+ modelId: 'openai/gpt-5',
24
+ toolGuidance: '',
25
+ })
26
+ ```
27
+
28
+ To rebrand the prompt, pass the product and co-author fields:
29
+
30
+ ```typescript
31
+ const prompt = buildBasePrompt({
32
+ // ...environment fields
33
+ productName: 'Acme Coder',
34
+ coAuthorName: 'Acme Bot',
35
+ coAuthorEmail: 'bot@acme.dev',
36
+ })
37
+ ```
38
+
39
+ ## Parameters
40
+
41
+ `buildBasePrompt()` takes a single `PromptContext` object.
42
+
43
+ **projectPath** (`string`): Absolute path to the project root.
44
+
45
+ **projectName** (`string`): Display name of the project.
46
+
47
+ **gitBranch** (`string`): Current git branch, if the project is a git repository.
48
+
49
+ **platform** (`string`): Operating system platform (for example, the value of process.platform).
50
+
51
+ **commonBinaries** (`{ name: string; path: string | null }[]`): Common binaries detected on the system, each with a name and resolved path (or null when not found).
52
+
53
+ **date** (`string`): Current date string injected into the prompt.
54
+
55
+ **mode** (`string`): Active agent mode (for example, "build" or "plan").
56
+
57
+ **modelId** (`string`): Identifier of the active model, included in the commit Co-Authored-By line when provided.
58
+
59
+ **activePlan** (`{ title: string; plan: string; approvedAt: string } | null`): The currently approved plan, if any.
60
+
61
+ **toolGuidance** (`string`): Tool-usage guidance section appended to the prompt.
62
+
63
+ **productName** (`string`): Display name used in the prompt header. (Default: `Mastra Code`)
64
+
65
+ **coAuthorName** (`string`): Name used in the commit Co-Authored-By line. (Default: `Mastra Code`)
66
+
67
+ **coAuthorEmail** (`string`): Email used in the commit Co-Authored-By line. (Default: `noreply@mastra.ai`)
68
+
69
+ ## Returns
70
+
71
+ **prompt** (`string`): The base system prompt for the coding agent.
72
+
73
+ ## Related
74
+
75
+ - [`createCodingAgent()`](https://mastra.ai/reference/coding-agent/create-coding-agent)
@@ -0,0 +1,97 @@
1
+ # createCodingAgent()
2
+
3
+ `createCodingAgent()` builds a coding [`Agent`](https://mastra.ai/reference/agents/agent) with portable defaults for the pieces a coding agent always needs: a local workspace, the task-list signal provider, network-retry error processors, and the goal judge prompt. Supply only `model`, `instructions`, and `tools` to get a working agent, or override any default.
4
+
5
+ The returned value is a standard `Agent`, so it works anywhere an `Agent` does — including as the agent passed to an [`AgentController`](https://mastra.ai/reference/agent-controller/agent-controller-class).
6
+
7
+ ## Usage example
8
+
9
+ Pass a model, instructions, and tools. The factory fills in the workspace, task signal, error processors, and goal prompt:
10
+
11
+ ```typescript
12
+ import { createCodingAgent } from '@mastra/core/coding-agent'
13
+
14
+ const agent = createCodingAgent({
15
+ id: 'my-coding-agent',
16
+ name: 'My Coding Agent',
17
+ model: 'openai/gpt-5',
18
+ instructions: 'You are a helpful coding assistant.',
19
+ tools: {},
20
+ })
21
+ ```
22
+
23
+ ## Parameters
24
+
25
+ `createCodingAgent()` accepts every field of [`AgentConfig`](https://mastra.ai/reference/agents/agent) plus the fields below. Fields you provide always take precedence over the factory defaults.
26
+
27
+ **model** (`MastraLanguageModel | DynamicArgument<MastraLanguageModel>`): The language model the agent uses. Passed straight through to Agent.
28
+
29
+ **instructions** (`string | DynamicArgument<string>`): System instructions for the agent. Passed straight through to Agent.
30
+
31
+ **tools** (`ToolsInput | DynamicArgument<ToolsInput>`): Tools available to the agent. Passed straight through to Agent.
32
+
33
+ **workspace** (`AnyWorkspace | undefined`): The workspace backing the agent. When the key is omitted, a default local workspace is built. When set explicitly to undefined, the factory builds no default — opt out when the workspace is wired elsewhere (for example at the AgentController level).
34
+
35
+ **basePath** (`string`): Base path for the default workspace built when workspace is omitted. (Default: `process.cwd()`)
36
+
37
+ **signals** (`SignalProvider[]`): Signal providers for the agent. When omitted, defaults to a single TaskSignalProvider.
38
+
39
+ **errorProcessors** (`Processor[]`): Error processors for the agent. When omitted, defaults to the ECONNRESET/bad-request retry stack plus PrefillErrorHandler and ProviderHistoryCompat.
40
+
41
+ **goal** (`AgentGoalConfig`): Goal configuration. When provided without a prompt, the prompt defaults to DEFAULT\_GOAL\_JUDGE\_PROMPT.
42
+
43
+ ## Returns
44
+
45
+ **agent** (`Agent`): A coding agent with the resolved workspace, signals, error processors, and goal applied.
46
+
47
+ ## Defaults
48
+
49
+ The factory only fills a default when you do not provide the corresponding field. Caller-provided values always win.
50
+
51
+ | Field | Default when omitted |
52
+ | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
53
+ | `workspace` | A [`Workspace`](https://mastra.ai/reference/workspace/workspace-class) backed by `LocalFilesystem` and `LocalSandbox` rooted at the base path. |
54
+ | `signals` | A single [`TaskSignalProvider`](https://mastra.ai/reference/signals/task-signal-provider). |
55
+ | `errorProcessors` | ECONNRESET and bad-request retry processors plus `PrefillErrorHandler` and `ProviderHistoryCompat`. |
56
+ | `goal.prompt` | `DEFAULT_GOAL_JUDGE_PROMPT` (only when a `goal` is configured). |
57
+
58
+ ### Workspace
59
+
60
+ When the `workspace` key is omitted, the factory builds a local workspace rooted at `basePath` (default `process.cwd()`):
61
+
62
+ ```typescript
63
+ import { Workspace, LocalFilesystem, LocalSandbox } from '@mastra/core/workspace'
64
+
65
+ new Workspace({
66
+ filesystem: new LocalFilesystem({ basePath }),
67
+ sandbox: new LocalSandbox({ workingDirectory: basePath }),
68
+ })
69
+ ```
70
+
71
+ To opt out — for example when the workspace is injected at the [`AgentController`](https://mastra.ai/reference/agent-controller/agent-controller-class) level — pass `workspace: undefined` explicitly:
72
+
73
+ ```typescript
74
+ const agent = createCodingAgent({
75
+ id: 'my-coding-agent',
76
+ name: 'My Coding Agent',
77
+ model: 'openai/gpt-5',
78
+ instructions: 'You are a helpful coding assistant.',
79
+ tools: {},
80
+ workspace: undefined, // opt out of the default workspace
81
+ })
82
+ ```
83
+
84
+ ### Error processors
85
+
86
+ The default error processors apply a retry policy for transient failures:
87
+
88
+ - Network resets (`ECONNRESET` / `socket hang up`) retry up to twice with exponential backoff (`1000ms * 2^retryCount`, capped at `30000ms`).
89
+ - Bad-request errors retry once after `2000ms`.
90
+
91
+ `PrefillErrorHandler` and `ProviderHistoryCompat` are also included for provider compatibility.
92
+
93
+ ## Related
94
+
95
+ - [`buildBasePrompt()`](https://mastra.ai/reference/coding-agent/build-base-prompt)
96
+ - [`Agent`](https://mastra.ai/reference/agents/agent)
97
+ - [`AgentController`](https://mastra.ai/reference/agent-controller/agent-controller-class)
@@ -74,6 +74,8 @@ The Reference section provides documentation of Mastra's API, including paramete
74
74
  - [Tools API](https://mastra.ai/reference/client-js/tools)
75
75
  - [Vectors API](https://mastra.ai/reference/client-js/vectors)
76
76
  - [Workflows API](https://mastra.ai/reference/client-js/workflows)
77
+ - [buildBasePrompt()](https://mastra.ai/reference/coding-agent/build-base-prompt)
78
+ - [createCodingAgent()](https://mastra.ai/reference/coding-agent/create-coding-agent)
77
79
  - [Mastra Class](https://mastra.ai/reference/core/mastra-class)
78
80
  - [MastraModelGateway](https://mastra.ai/reference/core/mastra-model-gateway)
79
81
  - [.addGateway()](https://mastra.ai/reference/core/addGateway)
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @mastra/mcp-docs-server
2
2
 
3
+ ## 1.2.3-alpha.14
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`0ac14ce`](https://github.com/mastra-ai/mastra/commit/0ac14cea48e1b0a7857782153c78f7242fdf7e1a), [`c2f0b7f`](https://github.com/mastra-ai/mastra/commit/c2f0b7f1370f4428d165f51f0d1d9a48331cc257)]:
8
+ - @mastra/core@1.48.0-alpha.8
9
+
3
10
  ## 1.2.3-alpha.13
4
11
 
5
12
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/mcp-docs-server",
3
- "version": "1.2.3-alpha.13",
3
+ "version": "1.2.3-alpha.15",
4
4
  "description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -28,7 +28,7 @@
28
28
  "jsdom": "^26.1.0",
29
29
  "local-pkg": "^1.1.2",
30
30
  "zod": "^4.4.3",
31
- "@mastra/core": "1.48.0-alpha.7",
31
+ "@mastra/core": "1.48.0-alpha.8",
32
32
  "@mastra/mcp": "^1.12.1-alpha.0"
33
33
  },
34
34
  "devDependencies": {
@@ -45,9 +45,9 @@
45
45
  "tsx": "^4.22.4",
46
46
  "typescript": "^6.0.3",
47
47
  "vitest": "4.1.8",
48
- "@internal/types-builder": "0.0.84",
49
48
  "@internal/lint": "0.0.109",
50
- "@mastra/core": "1.48.0-alpha.7"
49
+ "@internal/types-builder": "0.0.84",
50
+ "@mastra/core": "1.48.0-alpha.8"
51
51
  },
52
52
  "homepage": "https://mastra.ai",
53
53
  "repository": {