@mastra/mcp-docs-server 1.2.18-alpha.3 → 1.2.18-alpha.5

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.
@@ -1,24 +1,14 @@
1
1
  > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
2
 
3
- # Workspace skills
3
+ # Filesystem-backed skills
4
4
 
5
- Skills are reusable instructions that teach agents how to perform specific tasks. They follow the [Agent Skills specification](https://agentskills.io) - an open standard for packaging agent capabilities.
5
+ Filesystem-backed skills are directories of reusable instructions and supporting files. Mastra discovers them from paths in the `skills` option, then makes them available to every agent using that configuration. Skills follow the [Agent Skills specification](https://agentskills.io).
6
6
 
7
- > **Note:** Workspace skills are discovered through a workspace and shared with every agent that uses it. To attach skills directly to one agent without requiring a workspace, use [agent skills](https://mastra.ai/docs/skills).
8
-
9
- ## When to use skills
10
-
11
- Use workspace skills when your agent needs to:
12
-
13
- - Follow repeatable instructions for specialized tasks
14
- - Load detailed guidance only when it becomes relevant
15
- - Share instructions, reference files, scripts, and assets across agents
16
- - Discover capabilities from one or more directories
17
- - Search skill content alongside other workspace content
7
+ Use [agent skills](https://mastra.ai/docs/skills) instead when you want to define a skill directly in one agent's code. An agent can use both types. If a direct agent skill and a filesystem-backed skill have the same name, the direct agent skill takes precedence.
18
8
 
19
9
  ## Quickstart
20
10
 
21
- Create a skill with a `SKILL.md` file:
11
+ Create a directory with a `SKILL.md` file:
22
12
 
23
13
  ```markdown
24
14
  ---
@@ -31,203 +21,156 @@ description: Reviews code for bugs and readability issues
31
21
  Check the code for bugs, missing error handling, and unclear naming.
32
22
  ```
33
23
 
34
- Configure the skill directory on a workspace:
24
+ Configure the directory:
35
25
 
36
26
  ```typescript
37
- import { Workspace, LocalFilesystem } from '@mastra/core/workspace'
27
+ import { LocalFilesystem, Workspace } from '@mastra/core/workspace'
38
28
 
39
- const workspace = new Workspace({
40
- filesystem: new LocalFilesystem({ basePath: './workspace' }),
29
+ export const workspace = new Workspace({
30
+ filesystem: new LocalFilesystem({
31
+ basePath: './workspace',
32
+ }),
41
33
  skills: ['skills'],
42
34
  })
43
35
  ```
44
36
 
45
- Agents that use this workspace can now discover and load the `code-review` skill when needed.
37
+ The `skills` path is relative to the filesystem root, so Mastra discovers `./workspace/skills/code-review/SKILL.md`. An agent using this configuration can now discover and load `code-review` when a request needs it.
46
38
 
47
39
  ## Skill structure
48
40
 
49
- A skill is a folder containing:
50
-
51
- - `SKILL.md`: Instructions and metadata for the agent
52
- - `references/`: Supporting documentation (optional)
53
- - `scripts/`: Executable scripts (optional)
54
- - `assets/`: Images and other files (optional)
41
+ Each skill is a directory with a required `SKILL.md` file. It can also contain supporting files:
55
42
 
56
43
  ```plaintext
57
- skills/
58
- code-review/
59
- SKILL.md
60
- references/
61
- style-guide.md
62
- pr-checklist.md
63
- scripts/
64
- lint.ts
44
+ code-review/
45
+ SKILL.md
46
+ references/
47
+ style-guide.md
48
+ scripts/
49
+ lint.ts
50
+ assets/
51
+ review-template.md
65
52
  ```
66
53
 
67
- ## `SKILL.md` format
54
+ - `SKILL.md`: Metadata and instructions that Mastra loads when the agent selects the skill
55
+ - `references/`: Documentation that the agent can read or search as needed
56
+ - `scripts/`: Scripts used by the skill
57
+ - `assets/`: Templates, images, and other supporting files
68
58
 
69
- Follow the official [skill specification](https://agentskills.io/specification) when creating your skill. Here is an example `SKILL.md` for a code review skill:
59
+ Keep the main workflow in `SKILL.md`. Move detailed material to `references/` so the agent only reads it when needed.
70
60
 
71
- ```markdown
72
- ---
73
- name: code-review
74
- description: Reviews code for quality, style, and potential issues
75
- version: 1.0.0
76
- tags:
77
- - development
78
- - review
79
- ---
80
-
81
- # Code Review
82
-
83
- You are a code reviewer. When reviewing code:
84
-
85
- 1. Check for bugs and edge cases
86
- 2. Verify the code follows the style guide in references/style-guide.md
87
- 3. Suggest improvements for readability
88
- 4. Run the linter using scripts/lint.ts
89
-
90
- ## What to look out for
91
-
92
- - Unused variables and imports
93
- - Missing error handling
94
- - Security vulnerabilities
95
- - Performance issues
96
- ```
61
+ ## `SKILL.md` format
97
62
 
98
- ## Configuring skills
63
+ The YAML frontmatter requires `name` and `description`. The `name` must match the skill directory name, contain at most 64 lowercase letters, numbers, or hyphens, not start or end with a hyphen, and not contain consecutive hyphens. The Markdown body contains the instructions returned to the agent when it loads the skill.
99
64
 
100
- You can specify multiple skill directories:
65
+ Mastra also reads the optional `license`, `compatibility`, `user-invocable`, and `metadata` fields. See the [Agent Skills specification](https://agentskills.io/specification) for the complete package format and field guidance.
101
66
 
102
- ```typescript
103
- const workspace = new Workspace({
104
- filesystem: new LocalFilesystem({ basePath: './workspace' }),
105
- skills: [
106
- 'skills', // Project skills
107
- 'team-skills', // Shared team skills
108
- ],
109
- })
110
- ```
67
+ ## How agents use skills
111
68
 
112
- You can also pass a direct path to a skill directory or `SKILL.md` file:
69
+ When skills are configured, Mastra adds each skill's name, description, path, and source type to the system message. This lets the agent discover available skills without loading every instruction file into its context.
113
70
 
114
- ```typescript
115
- const workspace = new Workspace({
116
- filesystem: new LocalFilesystem({ basePath: './workspace' }),
117
- skills: ['path/to/my-skill'],
118
- })
119
- ```
71
+ Mastra also gives the agent three tools:
120
72
 
121
- Glob patterns let you discover skills across nested directories:
73
+ | Tool | Does |
74
+ | -------------- | ----------------------------------------------------------------------------------------- |
75
+ | `skill` | Loads a skill's `SKILL.md` instructions and lists its reference, script, and asset files. |
76
+ | `skill_read` | Reads all or part of any file under the selected skill directory. |
77
+ | `skill_search` | Searches skill instructions and reference files. |
122
78
 
123
- ```typescript
124
- const workspace = new Workspace({
125
- filesystem: new LocalFilesystem({ basePath: './workspace' }),
126
- skills: ['./**/skills'],
127
- })
128
- ```
79
+ Loading is stateless. The instructions remain in the conversation as a tool result, and the agent can call `skill` again if they leave the context after compaction.
129
80
 
130
- ## How agents use skills
81
+ ## Configure skill paths
131
82
 
132
- When a workspace has skills configured, agents automatically get access to skill tools. Available skills are listed in the system message so the agent knows what's available, and the agent can load any skill on demand.
83
+ The `skills` array accepts several path forms:
133
84
 
134
- The agent has three skill tools:
85
+ | Path | Discovery behavior |
86
+ | ----------------------------- | ----------------------------------------------------------------- |
87
+ | `skills` | Scans each immediate subdirectory for a `SKILL.md` file. |
88
+ | `skills/code-review` | Loads one skill directory directly. |
89
+ | `skills/code-review/SKILL.md` | Loads one skill file directly. |
90
+ | `./**/skills` | Finds matching directories, then discovers skills under each one. |
91
+ | `./**/SKILL.md` | Finds and loads matching skill files. |
135
92
 
136
- - **`skill`**: Loads a skill's full instructions and returns them in the tool result. The agent calls this whenever it needs a skill's guidance.
137
- - **`skill_read`**: Reads a file from a skill's `references/`, `scripts/`, or `assets/` directory.
138
- - **`skill_search`**: Searches across all skill content. Uses BM25 or vector search when configured, otherwise falls back to basic text matching.
93
+ Add more entries to discover skills from several roots, such as project, team, or package directories.
139
94
 
140
- Skill tools are registered when skills are configured. They aren't part of `WORKSPACE_TOOLS`, which configures filesystem, sandbox, search, and LSP tools.
95
+ Glob traversal is limited to four directory levels below the glob base.
141
96
 
142
- This design is stateless, there is no activation state to track. If the skill instructions leave the conversation context (due to context window limits or compaction), the agent can call `skill` again to reload them.
97
+ Paths use the configured filesystem when one is available. Without a filesystem, Mastra reads them from local disk relative to the application process's current working directory. An explicit [`skillSource`](#custom-skill-sources) replaces both defaults.
143
98
 
144
99
  ## Same-named skills
145
100
 
146
- When multiple skill directories contain a skill with the same name, all of them are discovered and listed. The agent sees every skill in its system message, along with each skill's path and source type, so it can tell them apart.
101
+ Mastra lists every distinct filesystem-backed skill in the system message, including its path and source type. If several skills have the same name, a lookup by name uses this priority:
147
102
 
148
- When the agent activates a skill by name, tie-breaking determines which one is returned:
103
+ 1. Local project paths
104
+ 2. Managed paths under `.mastra/skills`
105
+ 3. External paths under `node_modules`
149
106
 
150
- 1. **Source-type priority**: local skills take precedence over managed (`.mastra/`) skills, which take precedence over external (`node_modules/`) skills.
151
- 2. **Unresolvable conflicts throw**: if two skills share the same name and the same source type (for example, two local skills that both use the name `brand-guidelines`), `get()` throws an error. Rename one or move it to a different source type to resolve the conflict.
152
- 3. **Path escape hatch**: the agent can pass a skill's full path instead of its name to activate a specific skill, bypassing tie-breaking entirely.
107
+ If multiple highest-priority candidates have the same source type, Mastra can't choose between them and throws an error. Rename one skill or move it to a different source type.
153
108
 
154
- ```typescript
155
- const workspace = new Workspace({
156
- filesystem: new LocalFilesystem({ basePath: './workspace' }),
157
- skills: [
158
- 'node_modules/@myorg/skills', // external: provides "brand-guidelines"
159
- 'skills', // local: also provides "brand-guidelines"
160
- ],
161
- })
109
+ The agent can bypass name-based resolution by passing the exact path shown in the system message to `skill` or `skill_read`. Paths with or without the trailing `/SKILL.md` work. If several configured paths resolve to the same canonical directory, Mastra treats them as aliases and lists the skill once.
162
110
 
163
- // get('brand-guidelines') returns the local copy (local > external)
164
- // get('node_modules/@myorg/skills/brand-guidelines') returns the external copy
165
- ```
111
+ Direct [agent skills](https://mastra.ai/docs/skills) are resolved before filesystem-backed skills, so a direct skill wins when both types use the same name.
166
112
 
167
- ## Skill search
113
+ ## Search skill content
168
114
 
169
- If BM25 or vector search is enabled on the workspace, skills are automatically indexed. Agents can search across skill content to find relevant instructions.
115
+ When [BM25 or vector search](https://mastra.ai/docs/sandbox/search) is configured alongside skills, Mastra automatically indexes each skill's `SKILL.md` instructions and reference files. Scripts and assets aren't indexed.
170
116
 
171
- ```typescript
172
- const workspace = new Workspace({
173
- filesystem: new LocalFilesystem({ basePath: './workspace' }),
174
- skills: ['skills'],
175
- bm25: true,
176
- })
177
- ```
178
-
179
- ## Custom skill source
117
+ Without BM25 or vector search, `skill_search` falls back to case-insensitive text matching across the instructions and references. This keeps skill search available without a separate search configuration, while indexed search provides ranking and semantic retrieval for larger collections.
180
118
 
181
- By default, skills are read from the workspace filesystem. For advanced use cases, provide a custom `skillSource` to load skills from a different backend.
119
+ ## Dynamic skill paths
182
120
 
183
- `VersionedSkillSource` serves published skill versions from a content-addressable blob store, so production agents use a specific published version without touching the live filesystem:
121
+ Pass a synchronous or asynchronous function when the available paths depend on request context. This example adds development skills for users with the `developer` role:
184
122
 
185
123
  ```typescript
186
- import { Workspace, LocalFilesystem } from '@mastra/core/workspace'
187
- import { VersionedSkillSource } from '@mastra/core/workspace'
124
+ import { LocalFilesystem, Workspace } from '@mastra/core/workspace'
188
125
 
189
126
  const workspace = new Workspace({
190
127
  filesystem: new LocalFilesystem({ basePath: './workspace' }),
191
- skills: ['skills'],
192
- skillSource: new VersionedSkillSource(versionTree, blobStore, versionCreatedAt),
193
- })
194
- ```
195
-
196
- `VersionedSkillSource` accepts three parameters:
197
-
198
- - **`versionTree`** (`SkillVersionTree`): A manifest mapping relative file paths to blob entries (`{ entries: Record<string, { blobHash, size, mimeType?, encoding? }> }`).
199
- - **`blobStore`** (`BlobStore`): A content-addressable blob store instance that holds the actual file contents referenced by hash.
200
- - **`versionCreatedAt`** (`Date`): The timestamp when this skill version was published. Used as the modification time for all files in the version.
128
+ skills: ({ requestContext }) => {
129
+ const paths = ['skills']
201
130
 
202
- When `skillSource` is provided, it's used instead of the workspace filesystem for skill discovery.
131
+ if (requestContext?.get('user-role') === 'developer') {
132
+ paths.push('developer-skills')
133
+ }
203
134
 
204
- ## Agent-level skills
135
+ return paths
136
+ },
137
+ })
138
+ ```
205
139
 
206
- You can also attach skills directly to an agent without a workspace using `createSkill()` and the agent's `skills` config. When both agent-level and workspace-level skills exist, they merge, agent-level skills take precedence on name conflicts.
140
+ Mastra resolves the function for each execution and gives the agent the skill set for that request. The returned paths support the same directory, file, and glob forms as a static array.
207
141
 
208
- See [Agent skills](https://mastra.ai/docs/skills) for details.
142
+ ## Custom skill sources
209
143
 
210
- ## Dynamic skills
144
+ Set `skillSource` when skills should come from a backend other than the configured filesystem or local disk. A custom source handles skill discovery and file reads for every configured path.
211
145
 
212
- For runtime skill paths based on context, pass a function:
146
+ For example, `CompositeVersionedSkillSource` mounts published skill versions from a content-addressable blob store under directories where Mastra can discover them:
213
147
 
214
148
  ```typescript
149
+ import { CompositeVersionedSkillSource, Workspace } from '@mastra/core/workspace'
150
+
151
+ const skillSource = new CompositeVersionedSkillSource(
152
+ [
153
+ {
154
+ dirName: 'code-review',
155
+ tree: versionTree,
156
+ versionCreatedAt,
157
+ },
158
+ ],
159
+ blobStore,
160
+ )
161
+
215
162
  const workspace = new Workspace({
216
- filesystem: new LocalFilesystem({ basePath: './workspace' }),
217
- skills: ctx => {
218
- const paths = ['skills']
219
- if (ctx.requestContext?.get('userRole') === 'developer') {
220
- paths.push('dev-skills')
221
- }
222
- return paths
223
- },
163
+ skills: ['.'],
164
+ skillSource,
224
165
  })
225
166
  ```
226
167
 
168
+ An explicit `skillSource` doesn't fall back to the configured filesystem or local disk when a path is missing. See the [configuration reference](https://mastra.ai/reference/workspace/workspace-class) for the source interface and related options.
169
+
227
170
  ## Related
228
171
 
229
172
  - [Agent skills](https://mastra.ai/docs/skills)
230
- - [Agent skills specification](https://agentskills.io)
231
- - [Sandbox](https://mastra.ai/docs/sandbox/overview)
173
+ - [Agent Skills specification](https://agentskills.io)
174
+ - [Sandboxes](https://mastra.ai/docs/sandbox/overview)
232
175
  - [Search and indexing](https://mastra.ai/docs/sandbox/search)
233
176
  - [`createSkill()` reference](https://mastra.ai/reference/agents/createSkill)