@mastra/mcp 2.9.0-alpha.4 → 2.9.0

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.
@@ -3,7 +3,7 @@ name: mastra-mcp
3
3
  description: Documentation for @mastra/mcp. Use when working with @mastra/mcp APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/mcp"
6
- version: "2.9.0-alpha.4"
6
+ version: "2.9.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -19,6 +19,7 @@ Read the individual reference documents for detailed explanations and code examp
19
19
  - [Fine-Grained Authorization (FGA)](references/docs-auth-fga.md) - Configure Mastra Fine-Grained Authorization for resource-level permissions that map routes to actions and scope stored resources for enterprise users.
20
20
  - [MCP](references/docs-connections-mcp.md) - Connect Mastra agents to remote MCP servers, expose Mastra tools through MCPServer, manage approvals, subscribe to MCP events, and build interactive MCP Apps for Studio.
21
21
  - [MCP authentication and authorization](references/docs-guides-mcp-authentication-authorization.md) - Choose credentials for MCP connections, protect a Mastra MCP server, and separate delegated access from tool and data permissions.
22
+ - [Built-in MCP server](references/docs-server-mcp.md) - Let MCP clients such as Claude Code, Cursor, and the MCP Inspector call your agents, workflows, and tools through the built-in /api/mcp endpoint, with the same auth, RBAC, and FGA as the HTTP API.
22
23
 
23
24
  ### Reference
24
25
 
@@ -1,71 +1,71 @@
1
1
  {
2
- "version": "2.9.0-alpha.4",
2
+ "version": "2.9.0",
3
3
  "package": "@mastra/mcp",
4
4
  "exports": {
5
5
  "InMemoryMCPEventCursorStore": {
6
6
  "types": "dist/integrations/events-cursor-store.d.ts",
7
7
  "implementation": "dist/index.js",
8
- "line": 25749
8
+ "line": 25752
9
9
  },
10
10
  "InMemoryMCPTaskStore": {
11
11
  "types": "dist/server/tasks/in-memory-store.d.ts",
12
12
  "implementation": "dist/index.js",
13
- "line": 22524
13
+ "line": 22527
14
14
  },
15
15
  "InMemoryOAuthStorage": {
16
16
  "types": "dist/client/oauth-provider.d.ts",
17
17
  "implementation": "dist/index.js",
18
- "line": 18097
18
+ "line": 18100
19
19
  },
20
20
  "InMemoryWebhookSubscriptionStore": {
21
21
  "types": "dist/server/events/webhook-store.d.ts",
22
22
  "implementation": "dist/index.js",
23
- "line": 20894
23
+ "line": 20897
24
24
  },
25
25
  "InternalMastraMCPClient": {
26
26
  "types": "dist/client/client.d.ts",
27
27
  "implementation": "dist/index.js",
28
- "line": 16367
28
+ "line": 16370
29
29
  },
30
30
  "MCPClient": {
31
31
  "types": "dist/client/configuration.d.ts",
32
32
  "implementation": "dist/index.js",
33
- "line": 18590
33
+ "line": 18593
34
34
  },
35
35
  "MCPClientServerProxy": {
36
36
  "types": "dist/client/server-proxy.d.ts",
37
37
  "implementation": "dist/index.js",
38
- "line": 18438
38
+ "line": 18441
39
39
  },
40
40
  "MCPEventsSignalProvider": {
41
41
  "types": "dist/integrations/events-signals.d.ts",
42
42
  "implementation": "dist/index.js",
43
- "line": 25934
43
+ "line": 25937
44
44
  },
45
45
  "MCPOAuthClientProvider": {
46
46
  "types": "dist/client/oauth-provider.d.ts",
47
47
  "implementation": "dist/index.js",
48
- "line": 18149
48
+ "line": 18152
49
49
  },
50
50
  "MCPServer": {
51
51
  "types": "dist/server/server.d.ts",
52
52
  "implementation": "dist/index.js",
53
- "line": 23539
53
+ "line": 23542
54
54
  },
55
55
  "MCPTaskLimitError": {
56
56
  "types": "dist/server/tasks/store.d.ts",
57
57
  "implementation": "dist/index.js",
58
- "line": 21706
58
+ "line": 21709
59
59
  },
60
60
  "MCP_CALL_TOOL_CONTENT": {
61
61
  "types": "dist/client/client.d.ts",
62
62
  "implementation": "dist/index.js",
63
- "line": 16211
63
+ "line": 16214
64
64
  },
65
65
  "MCP_CALL_TOOL_META": {
66
66
  "types": "dist/client/client.d.ts",
67
67
  "implementation": "dist/index.js",
68
- "line": 16213
68
+ "line": 16216
69
69
  },
70
70
  "MCP_CLIENT_PROTOCOL_VERSION": {
71
71
  "types": "dist/client/types.d.ts",
@@ -75,122 +75,122 @@
75
75
  "MCP_DISCOVERY_TIMEOUT_CODE": {
76
76
  "types": "dist/client/configuration.d.ts",
77
77
  "implementation": "dist/index.js",
78
- "line": 18559
78
+ "line": 18562
79
79
  },
80
80
  "MCP_PROTOCOL_VERSION": {
81
81
  "types": "dist/server/types.d.ts",
82
82
  "implementation": "dist/index.js",
83
- "line": 25476
83
+ "line": 25479
84
84
  },
85
85
  "ServerEventActions": {
86
86
  "types": "dist/server/events/actions.d.ts",
87
87
  "implementation": "dist/index.js",
88
- "line": 19995
88
+ "line": 19998
89
89
  },
90
90
  "ServerPromptActions": {
91
91
  "types": "dist/server/actions.d.ts",
92
92
  "implementation": "dist/index.js",
93
- "line": 19975
93
+ "line": 19978
94
94
  },
95
95
  "ServerResourceActions": {
96
96
  "types": "dist/server/actions.d.ts",
97
97
  "implementation": "dist/index.js",
98
- "line": 19961
98
+ "line": 19964
99
99
  },
100
100
  "ServerToolActions": {
101
101
  "types": "dist/server/actions.d.ts",
102
102
  "implementation": "dist/index.js",
103
- "line": 19943
103
+ "line": 19946
104
104
  },
105
105
  "createIntrospectionValidator": {
106
106
  "types": "dist/server/oauth-middleware.d.ts",
107
107
  "implementation": "dist/index.js",
108
- "line": 25668
108
+ "line": 25671
109
109
  },
110
110
  "createOAuthCallbackServer": {
111
111
  "types": "dist/client/oauth-callback-server.d.ts",
112
112
  "implementation": "dist/index.js",
113
- "line": 17979
113
+ "line": 17982
114
114
  },
115
115
  "createOAuthMiddleware": {
116
116
  "types": "dist/server/oauth-middleware.d.ts",
117
117
  "implementation": "dist/index.js",
118
- "line": 25521
118
+ "line": 25524
119
119
  },
120
120
  "createSimpleTokenProvider": {
121
121
  "types": "dist/client/oauth-provider.d.ts",
122
122
  "implementation": "dist/index.js",
123
- "line": 18412
123
+ "line": 18415
124
124
  },
125
125
  "createStaticTokenValidator": {
126
126
  "types": "dist/server/oauth-middleware.d.ts",
127
127
  "implementation": "dist/index.js",
128
- "line": 25637
128
+ "line": 25640
129
129
  },
130
130
  "defineEvent": {
131
131
  "types": "dist/server/events/define-event.d.ts",
132
132
  "implementation": "dist/index.js",
133
- "line": 25739
133
+ "line": 25742
134
134
  },
135
135
  "extractBearerToken": {
136
136
  "types": "dist/shared/oauth-types.d.ts",
137
137
  "implementation": "dist/index.js",
138
- "line": 13517
138
+ "line": 13520
139
139
  },
140
140
  "generateProtectedResourceMetadata": {
141
141
  "types": "dist/shared/oauth-types.d.ts",
142
142
  "implementation": "dist/index.js",
143
- "line": 13501
143
+ "line": 13504
144
144
  },
145
145
  "generateWWWAuthenticateHeader": {
146
146
  "types": "dist/shared/oauth-types.d.ts",
147
147
  "implementation": "dist/index.js",
148
- "line": 13486
148
+ "line": 13489
149
149
  },
150
150
  "getCallbackUrlCandidates": {
151
151
  "types": "dist/client/oauth-callback-server.d.ts",
152
152
  "implementation": "dist/index.js",
153
- "line": 17912
153
+ "line": 17915
154
154
  },
155
155
  "getMcpCallToolContent": {
156
156
  "types": "dist/client/client.d.ts",
157
157
  "implementation": "dist/index.js",
158
- "line": 16233
158
+ "line": 16236
159
159
  },
160
160
  "getMcpCallToolMeta": {
161
161
  "types": "dist/client/client.d.ts",
162
162
  "implementation": "dist/index.js",
163
- "line": 16242
163
+ "line": 16245
164
164
  },
165
165
  "isMCPTaskStoreAdmin": {
166
166
  "types": "dist/server/tasks/store.d.ts",
167
167
  "implementation": "dist/index.js",
168
- "line": 21757
168
+ "line": 21760
169
169
  },
170
170
  "isWorkflowTaskContext": {
171
171
  "types": "dist/server/tasks/workflow-runs.d.ts",
172
172
  "implementation": "dist/index.js",
173
- "line": 23297
173
+ "line": 23300
174
174
  },
175
175
  "principalKeyOf": {
176
176
  "types": "dist/server/tasks/store.d.ts",
177
177
  "implementation": "dist/index.js",
178
- "line": 21698
178
+ "line": 21701
179
179
  },
180
180
  "taskKeyOf": {
181
181
  "types": "dist/shared/tasks/task-id.d.ts",
182
182
  "implementation": "dist/index.js",
183
- "line": 13681
183
+ "line": 13684
184
184
  },
185
185
  "traceContextFromMeta": {
186
186
  "types": "dist/shared/trace-context.d.ts",
187
187
  "implementation": "dist/index.js",
188
- "line": 13703
188
+ "line": 13706
189
189
  },
190
190
  "traceContextToMeta": {
191
191
  "types": "dist/shared/trace-context.d.ts",
192
192
  "implementation": "dist/index.js",
193
- "line": 13715
193
+ "line": 13718
194
194
  }
195
195
  },
196
196
  "modules": {}
@@ -289,6 +289,8 @@ A tool that needs something from the user before it can finish calls `context.su
289
289
 
290
290
  Visit the [`MCPServer` reference](https://mastra.ai/reference/tools/mcp-server) for prompts, resources, transports, and other server options.
291
291
 
292
+ To expose every agent, workflow, and tool on your Mastra app without defining a server, use the [built-in MCP server](https://mastra.ai/docs/server/mcp) at `/api/mcp`.
293
+
292
294
  ### Publish a stdio server package
293
295
 
294
296
  Package a server that uses the standard input/output (stdio) transport when you want clients to run it locally through a command such as `npx`. Create a separate executable entry point that starts the server:
@@ -446,71 +448,6 @@ export const mastra = new Mastra({
446
448
 
447
449
  Tools loaded through `listTools()` include a `serverId` in `_meta.ui`, allowing Studio to resolve each app resource without scanning every server. Visit [`toMCPServerProxies()`](https://mastra.ai/reference/tools/mcp-client) for proxy configuration details.
448
450
 
449
- ### Use prebuilt Mastra apps
450
-
451
- The `@mastra/mcp-apps-components` package includes prebuilt MCP Apps. Each one is a self-contained HTML page that you register as an app resource, next to the tools it talks to.
452
-
453
- **npm**:
454
-
455
- ```bash
456
- npm install @mastra/mcp-apps-components
457
- ```
458
-
459
- **pnpm**:
460
-
461
- ```bash
462
- pnpm add @mastra/mcp-apps-components
463
- ```
464
-
465
- **Yarn**:
466
-
467
- ```bash
468
- yarn add @mastra/mcp-apps-components
469
- ```
470
-
471
- **Bun**:
472
-
473
- ```bash
474
- bun add @mastra/mcp-apps-components
475
- ```
476
-
477
- `greetingApp` greets someone by name. The host sends it the arguments of the tool that opened it, and the app reads `name`. It then calls the `getGreeting` tool on the same server for its data and shows the `greeting` from the result. Mark `getGreeting` as app-only with `visibility: ['app']`, so the model doesn't see it:
478
-
479
- ```typescript
480
- import { createTool } from '@mastra/core/tools'
481
- import { MCPServer } from '@mastra/mcp'
482
- import { greetingApp } from '@mastra/mcp-apps-components'
483
- import { z } from 'zod'
484
-
485
- const uri = 'ui://mastra/greeting'
486
-
487
- export const greetingServer = new MCPServer({
488
- id: 'greeting-server',
489
- name: 'Greeting Server',
490
- version: '1.0.0',
491
- appResources: { [uri]: greetingApp },
492
- tools: {
493
- showGreeting: createTool({
494
- id: 'showGreeting',
495
- description: 'Shows a greeting card for someone',
496
- inputSchema: z.object({ name: z.string() }),
497
- mcp: { _meta: { ui: { resourceUri: uri } } },
498
- execute: async ({ name }) => ({ name }),
499
- }),
500
- getGreeting: createTool({
501
- id: 'getGreeting',
502
- description: 'Returns the greeting for a name',
503
- inputSchema: z.object({ name: z.string() }),
504
- outputSchema: z.object({ greeting: z.string() }),
505
- mcp: { _meta: { ui: { resourceUri: uri, visibility: ['app'] } } },
506
- execute: async ({ name }) => ({ greeting: `Hello, ${name}!` }),
507
- }),
508
- },
509
- })
510
- ```
511
-
512
- `getGreeting` runs on your server, so it can call any API with your server's credentials. The app's iframe has no network access of its own.
513
-
514
451
  ### Sandbox security
515
452
 
516
453
  Mastra Studio uses [`@mcp-ui/client`](https://www.npmjs.com/package/@mcp-ui/client) to load app HTML through a sandbox proxy and communicate over JSON-RPC with `postMessage`.