@mastra/mcp-docs-server 1.3.8-alpha.5 → 1.3.8-alpha.7
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.
|
@@ -93,6 +93,14 @@ Configure validation appropriate to your issuer, including audience and expiry c
|
|
|
93
93
|
|
|
94
94
|
Protecting Mastra routes with `server.auth` and providing interoperable OAuth discovery are different tasks. Don't assume configuring one supplies the other.
|
|
95
95
|
|
|
96
|
+
### Routes Mastra registers for an MCP server
|
|
97
|
+
|
|
98
|
+
Alongside the MCP transport, Mastra registers REST routes used by Studio to list servers, inspect tools, execute tools, and read resources. See the [MCP routes reference](https://mastra.ai/reference/server/routes) for the full list. These paths use the default `/api` prefix.
|
|
99
|
+
|
|
100
|
+
The `POST /api/mcp/:serverId/tools/:toolId/execute` route calls `executeTool()` directly, without a protocol client. With a Mastra FGA provider configured, `MCPServer.executeTool()` enforces tool execution permission using the user in `requestContext`. The REST tool list also filters tools through FGA. These permission checks don't replace route authentication.
|
|
101
|
+
|
|
102
|
+
Built-in authentication for these routes depends on `server.auth`. Without it, `requiresAuth: true` doesn't enforce authentication. Custom middleware that checks only the `/mcp` or `/sse` transport paths leaves the REST routes open. If you use custom middleware instead of `server.auth`, default-deny `/api/mcp/*` and allow access only after authentication.
|
|
103
|
+
|
|
96
104
|
### Pass verified identity to tools
|
|
97
105
|
|
|
98
106
|
When a Mastra server handles an MCP request, its auth bridge preserves an existing `req.auth`. Otherwise, it uses `server.mcpOptions.setRequestAuth` when configured, or builds `authInfo` from the request context. With the default bridge, the authenticated user is available in `authInfo.extra.user`.
|
|
@@ -121,9 +129,10 @@ Keep access tokens, refresh tokens, and service credentials outside model-visibl
|
|
|
121
129
|
|
|
122
130
|
- [ ] **Validate tokens:** Configure validation for your issuer, including audience and expiry checks, and confirm an unvalidated token is rejected.
|
|
123
131
|
- [ ] **Challenge missing tokens:** Confirm every protected server path returns `401` without a bearer token.
|
|
132
|
+
- [ ] **Protect MCP REST routes:** If you don't use `server.auth`, confirm `/api/mcp/:serverId/tools*`, `/api/mcp/:serverId/resources*`, and `/api/mcp/v0/servers*` aren't reachable without authentication. Use your configured API prefix if it differs from `/api`.
|
|
124
133
|
- [ ] **Isolate users:** Confirm one user's provider, connection, and stored credentials aren't reused for another user.
|
|
125
134
|
- [ ] **Bind credentials to the issuer:** Confirm registration and tokens aren't reused when the authorization server changes.
|
|
126
|
-
- [ ] **Deny unauthorized operations:** Confirm a caller without permission is denied `tools/call`, including for a tool it never listed.
|
|
135
|
+
- [ ] **Deny unauthorized operations:** Confirm a caller without permission is denied both `tools/call` and `POST /api/mcp/:serverId/tools/:toolId/execute`, including for a tool it never listed.
|
|
127
136
|
- [ ] **Scope records to the caller:** Confirm record lookups resolve the tenant from trusted server context rather than tool arguments.
|
|
128
137
|
- [ ] **Keep tokens at their audience:** Confirm upstream calls use separate credentials and never forward the MCP token.
|
|
129
138
|
- [ ] **Keep secrets out of model data:** Confirm tokens and credentials stay out of instructions, tool arguments, and tool results.
|
|
@@ -86,6 +86,10 @@ Generated servers pass `server.apiPrefix` to the Hono adapter's [`prefix` constr
|
|
|
86
86
|
|
|
87
87
|
This approach can't block routes declared public with `requiresAuth: false`, because Mastra skips user middleware for those routes. With a non-Hono server adapter, register equivalent middleware through the server framework instead.
|
|
88
88
|
|
|
89
|
+
During `mastra dev`, inspect the full built-in route list, including MCP routes, in the [OpenAPI specification](http://localhost:4111/api/openapi.json). See the [server overview](https://mastra.ai/docs/server/overview) for API exploration and production settings.
|
|
90
|
+
|
|
91
|
+
If you use middleware for authentication without `server.auth`, prefer default-deny middleware that authenticates requests before allowing access, rather than enumerating protected paths. Include the full API prefix so REST routes alongside MCP transports are covered.
|
|
92
|
+
|
|
89
93
|
### Using `RequestContext`
|
|
90
94
|
|
|
91
95
|
You can populate `RequestContext` in a runtime server middleware by extracting information from the request. In this example, the `temperature-unit` is set based on the Cloudflare `CF-IPCountry` header to ensure responses match the user's locale.
|
|
@@ -542,12 +542,20 @@ Returns the persisted experiment result row.
|
|
|
542
542
|
|
|
543
543
|
## MCP
|
|
544
544
|
|
|
545
|
-
| Method | Path
|
|
546
|
-
| ------ |
|
|
547
|
-
| `GET` | `/api/mcp/servers`
|
|
548
|
-
| `GET` | `/api/mcp/servers/:
|
|
549
|
-
| `
|
|
550
|
-
| `GET` | `/api/mcp/:serverId/
|
|
545
|
+
| Method | Path | Description |
|
|
546
|
+
| ------ | ------------------------------------------ | ------------------------ |
|
|
547
|
+
| `GET` | `/api/mcp/v0/servers` | List MCP servers |
|
|
548
|
+
| `GET` | `/api/mcp/v0/servers/:id` | Get server details |
|
|
549
|
+
| `GET` | `/api/mcp/:serverId/tools` | List server tools |
|
|
550
|
+
| `GET` | `/api/mcp/:serverId/tools/:toolId` | Get tool details |
|
|
551
|
+
| `POST` | `/api/mcp/:serverId/tools/:toolId/execute` | Execute a tool |
|
|
552
|
+
| `GET` | `/api/mcp/:serverId/resources` | List server resources |
|
|
553
|
+
| `POST` | `/api/mcp/:serverId/resources/read` | Read a resource |
|
|
554
|
+
| `ALL` | `/api/mcp/:serverId/mcp` | MCP HTTP transport |
|
|
555
|
+
| `ALL` | `/api/mcp/:serverId/sse` | Legacy MCP SSE transport |
|
|
556
|
+
| `POST` | `/api/mcp/:serverId/messages` | Legacy MCP SSE messages |
|
|
557
|
+
|
|
558
|
+
All MCP routes declare `requiresAuth: true`. Authentication is enforced only when `server.auth` is configured. Paths use the default `/api` prefix. The legacy SSE routes return `404` for MCP v2 servers.
|
|
551
559
|
|
|
552
560
|
## Responses API
|
|
553
561
|
|
|
@@ -456,7 +456,7 @@ getToolInfo(toolId: string): ToolInfo | undefined
|
|
|
456
456
|
|
|
457
457
|
### `executeTool()`
|
|
458
458
|
|
|
459
|
-
Runs a tool without a protocol client, which is how the Mastra REST route `POST /api/mcp/:serverId/tools/:toolId/execute` and Studio invoke tools.
|
|
459
|
+
Runs a tool without a protocol client, which is how the Mastra REST route `POST /api/mcp/:serverId/tools/:toolId/execute` and Studio invoke tools. See [authentication for registered MCP routes](https://mastra.ai/docs/guides/mcp-authentication-authorization) and the [MCP routes reference](https://mastra.ai/reference/server/routes).
|
|
460
460
|
|
|
461
461
|
```typescript
|
|
462
462
|
async executeTool(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp-docs-server",
|
|
3
|
-
"version": "1.3.8-alpha.
|
|
3
|
+
"version": "1.3.8-alpha.7",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@mastra/mcp-legacy": "npm:@mastra/mcp@^1.18.0",
|
|
27
27
|
"local-pkg": "^1.1.2",
|
|
28
28
|
"zod": "^4.6.4",
|
|
29
|
-
"@mastra/core": "1.78.0-alpha.
|
|
29
|
+
"@mastra/core": "1.78.0-alpha.5",
|
|
30
30
|
"@mastra/mcp": "^2.4.1-alpha.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"typescript": "^7.0.2",
|
|
45
45
|
"vitest": "4.1.11",
|
|
46
46
|
"@internal/lint": "0.0.143",
|
|
47
|
-
"@
|
|
48
|
-
"@
|
|
47
|
+
"@mastra/core": "1.78.0-alpha.5",
|
|
48
|
+
"@internal/types-builder": "0.0.118"
|
|
49
49
|
},
|
|
50
50
|
"homepage": "https://mastra.ai",
|
|
51
51
|
"repository": {
|