@mastra/mcp-docs-server 1.1.17-alpha.1 → 1.1.17-alpha.3
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.
- package/.docs/docs/memory/observational-memory.md +7 -5
- package/.docs/docs/observability/tracing/bridges/otel.md +3 -3
- package/.docs/docs/observability/tracing/exporters/sentry.md +1 -1
- package/.docs/docs/server/auth/okta.md +225 -0
- package/.docs/docs/server/auth.md +1 -0
- package/.docs/guides/agent-frameworks/ai-sdk.md +3 -3
- package/.docs/reference/ai-sdk/with-mastra.md +2 -2
- package/.docs/reference/auth/okta.md +162 -0
- package/.docs/reference/client-js/agents.md +2 -2
- package/.docs/reference/evals/noise-sensitivity.md +3 -3
- package/.docs/reference/index.md +1 -0
- package/.docs/reference/memory/observational-memory.md +2 -2
- package/.docs/reference/observability/tracing/interfaces.md +1 -1
- package/.docs/reference/processors/message-history-processor.md +1 -1
- package/.docs/reference/processors/processor-interface.md +3 -3
- package/.docs/reference/processors/semantic-recall-processor.md +1 -1
- package/.docs/reference/processors/tool-call-filter.md +2 -2
- package/.docs/reference/processors/working-memory-processor.md +1 -1
- package/.docs/reference/streaming/agents/stream.md +1 -1
- package/.docs/reference/tools/mcp-client.md +1 -1
- package/CHANGELOG.md +7 -0
- package/package.json +5 -5
|
@@ -150,17 +150,19 @@ const memory = new Memory({
|
|
|
150
150
|
observation: {
|
|
151
151
|
model: new ModelByInputTokens({
|
|
152
152
|
upTo: {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
153
|
+
// Faster, cheaper models for smaller inputs; stronger models for larger contexts
|
|
154
|
+
5_000: 'openrouter/mistralai/ministral-8b-2512',
|
|
155
|
+
20_000: 'openrouter/mistralai/mistral-small-2603',
|
|
156
|
+
40_000: 'openai/gpt-5.4-mini',
|
|
157
|
+
1_000_000: 'google/gemini-3.1-flash-lite-preview',
|
|
156
158
|
},
|
|
157
159
|
}),
|
|
158
160
|
},
|
|
159
161
|
reflection: {
|
|
160
162
|
model: new ModelByInputTokens({
|
|
161
163
|
upTo: {
|
|
162
|
-
20_000: '
|
|
163
|
-
|
|
164
|
+
20_000: 'openai/gpt-5.4-mini',
|
|
165
|
+
100_000: 'google/gemini-2.5-flash',
|
|
164
166
|
},
|
|
165
167
|
}),
|
|
166
168
|
},
|
|
@@ -151,10 +151,10 @@ With the OtelBridge, your traces maintain proper hierarchy across OTEL and Mastr
|
|
|
151
151
|
```text
|
|
152
152
|
HTTP POST /api/chat (from Hono middleware)
|
|
153
153
|
└── agent.assistant (from Mastra via OtelBridge)
|
|
154
|
-
├── chat gpt-
|
|
154
|
+
├── chat gpt-5.4 (LLM call)
|
|
155
155
|
├── tool.execute search (tool execution)
|
|
156
156
|
│ └── HTTP GET api.example.com (from OTEL auto-instrumentation)
|
|
157
|
-
└── chat gpt-
|
|
157
|
+
└── chat gpt-5.4 (follow-up LLM call)
|
|
158
158
|
```
|
|
159
159
|
|
|
160
160
|
## Multi-service distributed tracing
|
|
@@ -167,7 +167,7 @@ Service A: HTTP POST /api/process
|
|
|
167
167
|
|
|
168
168
|
Service B: HTTP POST /api/analyze (incoming call - same trace!)
|
|
169
169
|
└── agent.analyzer (Mastra agent inherits trace context)
|
|
170
|
-
└── chat gpt-
|
|
170
|
+
└── chat gpt-5.4
|
|
171
171
|
```
|
|
172
172
|
|
|
173
173
|
Both services must have:
|
|
@@ -162,7 +162,7 @@ The exporter uses standard GenAI semantic conventions with Sentry-specific attri
|
|
|
162
162
|
**For MODEL\_GENERATION spans:**
|
|
163
163
|
|
|
164
164
|
- `gen_ai.system`: Model provider (e.g., `openai`, `anthropic`)
|
|
165
|
-
- `gen_ai.request.model`: Model identifier (e.g., `gpt-4`)
|
|
165
|
+
- `gen_ai.request.model`: Model identifier (e.g., `gpt-5.4`)
|
|
166
166
|
- `gen_ai.response.model`: Response model
|
|
167
167
|
- `gen_ai.response.text`: Output text response
|
|
168
168
|
- `gen_ai.response.tool_calls`: Tool calls made during generation (JSON array)
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
# Okta
|
|
2
|
+
|
|
3
|
+
The `@mastra/auth-okta` package provides authentication and role-based access control for Mastra using Okta. It supports an OAuth 2.0 / OIDC login flow with encrypted session cookies and maps Okta groups to Mastra permissions.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
This guide uses Okta authentication. Make sure to:
|
|
8
|
+
|
|
9
|
+
1. Create an Okta account at [okta.com](https://www.okta.com/)
|
|
10
|
+
2. Set up an OAuth application in the Okta Admin Console (Web app, Authorization Code grant)
|
|
11
|
+
3. Add your redirect URI to the application's sign-in redirect URIs
|
|
12
|
+
4. Create an API token (required for RBAC)
|
|
13
|
+
|
|
14
|
+
Make sure your environment variables are set.
|
|
15
|
+
|
|
16
|
+
```env
|
|
17
|
+
OKTA_DOMAIN=dev-123456.okta.com
|
|
18
|
+
OKTA_CLIENT_ID=your-client-id
|
|
19
|
+
OKTA_CLIENT_SECRET=your-client-secret
|
|
20
|
+
OKTA_REDIRECT_URI=http://localhost:4111/api/auth/callback
|
|
21
|
+
OKTA_COOKIE_PASSWORD=a-random-string-at-least-32-characters-long
|
|
22
|
+
OKTA_API_TOKEN=your-api-token
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
> **Note:** `OKTA_COOKIE_PASSWORD` encrypts session cookies. If omitted, an auto-generated value is used that does not survive server restarts. Set it explicitly for production.
|
|
26
|
+
>
|
|
27
|
+
> `OKTA_API_TOKEN` is only required when using `MastraRBACOkta` to map Okta groups to permissions.
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
**npm**:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm install @mastra/auth-okta
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**pnpm**:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pnpm add @mastra/auth-okta
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Yarn**:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
yarn add @mastra/auth-okta
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Bun**:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
bun add @mastra/auth-okta
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Usage examples
|
|
56
|
+
|
|
57
|
+
### Basic usage with environment variables
|
|
58
|
+
|
|
59
|
+
With the environment variables above set, all constructor parameters are optional:
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import { Mastra } from '@mastra/core'
|
|
63
|
+
import { MastraAuthOkta } from '@mastra/auth-okta'
|
|
64
|
+
|
|
65
|
+
export const mastra = new Mastra({
|
|
66
|
+
server: {
|
|
67
|
+
auth: new MastraAuthOkta(),
|
|
68
|
+
},
|
|
69
|
+
})
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Auth with RBAC
|
|
73
|
+
|
|
74
|
+
Add `MastraRBACOkta` to map Okta groups to Mastra permissions:
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import { Mastra } from '@mastra/core'
|
|
78
|
+
import { MastraAuthOkta, MastraRBACOkta } from '@mastra/auth-okta'
|
|
79
|
+
|
|
80
|
+
export const mastra = new Mastra({
|
|
81
|
+
server: {
|
|
82
|
+
auth: new MastraAuthOkta(),
|
|
83
|
+
rbac: new MastraRBACOkta({
|
|
84
|
+
roleMapping: {
|
|
85
|
+
Admin: ['*'],
|
|
86
|
+
Engineering: ['agents:*', 'workflows:*', 'tools:*'],
|
|
87
|
+
Viewer: ['agents:read', 'workflows:read'],
|
|
88
|
+
_default: [], // users with unmapped groups get no permissions
|
|
89
|
+
},
|
|
90
|
+
}),
|
|
91
|
+
},
|
|
92
|
+
})
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Cross-provider usage
|
|
96
|
+
|
|
97
|
+
Use a different auth provider (Auth0, Clerk, etc.) for login and Okta for RBAC. Pass a `getUserId` function to resolve the Okta user ID from the other provider's user object:
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
import { Mastra } from '@mastra/core'
|
|
101
|
+
import { MastraAuthAuth0 } from '@mastra/auth-auth0'
|
|
102
|
+
import { MastraRBACOkta } from '@mastra/auth-okta'
|
|
103
|
+
|
|
104
|
+
export const mastra = new Mastra({
|
|
105
|
+
server: {
|
|
106
|
+
auth: new MastraAuthAuth0(),
|
|
107
|
+
rbac: new MastraRBACOkta({
|
|
108
|
+
getUserId: user => user.metadata?.oktaUserId || user.email,
|
|
109
|
+
roleMapping: {
|
|
110
|
+
Engineering: ['agents:*', 'workflows:*'],
|
|
111
|
+
Admin: ['*'],
|
|
112
|
+
_default: [],
|
|
113
|
+
},
|
|
114
|
+
}),
|
|
115
|
+
},
|
|
116
|
+
})
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
> **Note:** To link users between providers, store the Okta user ID in the other provider's user metadata. Mastra uses this ID to fetch groups from Okta.
|
|
120
|
+
|
|
121
|
+
> **Info:** Visit [MastraAuthOkta](https://mastra.ai/reference/auth/okta) for all available configuration options.
|
|
122
|
+
|
|
123
|
+
## Role mapping
|
|
124
|
+
|
|
125
|
+
The `roleMapping` option maps Okta group names to arrays of Mastra permission strings. Permissions follow a `resource:action` pattern and support wildcards:
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
const rbac = new MastraRBACOkta({
|
|
129
|
+
roleMapping: {
|
|
130
|
+
// full access to everything
|
|
131
|
+
Admin: ['*'],
|
|
132
|
+
|
|
133
|
+
// full access to agents and workflows
|
|
134
|
+
Engineering: ['agents:*', 'workflows:*'],
|
|
135
|
+
|
|
136
|
+
// read-only access
|
|
137
|
+
Viewer: ['agents:read', 'workflows:read'],
|
|
138
|
+
|
|
139
|
+
// users whose groups don't match any key above
|
|
140
|
+
_default: [],
|
|
141
|
+
},
|
|
142
|
+
})
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
The `_default` key assigns permissions to users whose Okta groups do not match any other key.
|
|
146
|
+
|
|
147
|
+
## Client-side setup
|
|
148
|
+
|
|
149
|
+
When auth is enabled, requests to Mastra routes require authentication. `MastraAuthOkta` uses SSO, so users authenticate through Okta's hosted login page. After login, an encrypted session cookie is set automatically.
|
|
150
|
+
|
|
151
|
+
### Cookie session (recommended)
|
|
152
|
+
|
|
153
|
+
For cross-origin requests (e.g. a frontend on `:3000` calling Mastra on `:4111`), enable CORS credentials on the Mastra server:
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
export const mastra = new Mastra({
|
|
157
|
+
server: {
|
|
158
|
+
auth: new MastraAuthOkta(),
|
|
159
|
+
cors: {
|
|
160
|
+
origin: 'http://localhost:3000',
|
|
161
|
+
credentials: true,
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
})
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Configure the client to include credentials:
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
import { MastraClient } from '@mastra/client-js'
|
|
171
|
+
|
|
172
|
+
export const mastraClient = new MastraClient({
|
|
173
|
+
baseUrl: 'http://localhost:4111',
|
|
174
|
+
credentials: 'include',
|
|
175
|
+
})
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Bearer token
|
|
179
|
+
|
|
180
|
+
You can also pass an Okta access token as a Bearer token. The token is verified against Okta's JWKS endpoint:
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
import { MastraClient } from '@mastra/client-js'
|
|
184
|
+
|
|
185
|
+
export const createMastraClient = (accessToken: string) => {
|
|
186
|
+
return new MastraClient({
|
|
187
|
+
baseUrl: 'http://localhost:4111',
|
|
188
|
+
headers: {
|
|
189
|
+
Authorization: `Bearer ${accessToken}`,
|
|
190
|
+
},
|
|
191
|
+
})
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
> **Info:** Visit [Mastra Client SDK](https://mastra.ai/docs/server/mastra-client) for more configuration options.
|
|
196
|
+
|
|
197
|
+
### Making authenticated requests
|
|
198
|
+
|
|
199
|
+
**MastraClient**:
|
|
200
|
+
|
|
201
|
+
```typescript
|
|
202
|
+
import { mastraClient } from '../lib/mastra-client'
|
|
203
|
+
|
|
204
|
+
const agent = mastraClient.getAgent('weatherAgent')
|
|
205
|
+
const response = await agent.generate('Weather in London')
|
|
206
|
+
console.log(response)
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
**cURL**:
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
curl -X POST http://localhost:4111/api/agents/weatherAgent/generate \
|
|
213
|
+
-H "Content-Type: application/json" \
|
|
214
|
+
-H "Authorization: Bearer <your-okta-access-token>" \
|
|
215
|
+
-d '{
|
|
216
|
+
"messages": "Weather in London"
|
|
217
|
+
}'
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## Troubleshooting
|
|
221
|
+
|
|
222
|
+
- **401 on every request**: Verify your Okta domain, client ID, and client secret are correct. Check that the redirect URI in your Okta application matches `OKTA_REDIRECT_URI`.
|
|
223
|
+
- **Cookies not sent cross-origin**: Set `credentials: "include"` in `MastraClient` and configure `server.cors` with your frontend origin and `credentials: true`.
|
|
224
|
+
- **Session lost on restart**: Set `OKTA_COOKIE_PASSWORD` to a stable value (at least 32 characters). Without it, an auto-generated key is used that changes on each restart.
|
|
225
|
+
- **RBAC returns empty permissions**: Verify `OKTA_API_TOKEN` is set and the token has permission to list user groups. Check that group names in `roleMapping` match your Okta group names exactly.
|
|
@@ -30,6 +30,7 @@ See [Custom API Routes](https://mastra.ai/docs/server/custom-api-routes) for con
|
|
|
30
30
|
- [Better Auth](https://mastra.ai/docs/server/auth/better-auth)
|
|
31
31
|
- [Clerk](https://mastra.ai/docs/server/auth/clerk)
|
|
32
32
|
- [Firebase](https://mastra.ai/docs/server/auth/firebase)
|
|
33
|
+
- [Okta](https://mastra.ai/docs/server/auth/okta)
|
|
33
34
|
- [Supabase](https://mastra.ai/docs/server/auth/supabase)
|
|
34
35
|
- [WorkOS](https://mastra.ai/docs/server/auth/workos)
|
|
35
36
|
|
|
@@ -56,7 +56,7 @@ const loggingProcessor: Processor<'logger'> = {
|
|
|
56
56
|
},
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
const model = withMastra(openai('gpt-
|
|
59
|
+
const model = withMastra(openai('gpt-5.4'), {
|
|
60
60
|
inputProcessors: [loggingProcessor],
|
|
61
61
|
outputProcessors: [loggingProcessor],
|
|
62
62
|
})
|
|
@@ -85,7 +85,7 @@ await storage.init()
|
|
|
85
85
|
|
|
86
86
|
const memoryStorage = await storage.getStore('memory')
|
|
87
87
|
|
|
88
|
-
const model = withMastra(openai('gpt-
|
|
88
|
+
const model = withMastra(openai('gpt-5.4'), {
|
|
89
89
|
memory: {
|
|
90
90
|
storage: memoryStorage!,
|
|
91
91
|
threadId: 'user-thread-123',
|
|
@@ -115,7 +115,7 @@ await storage.init()
|
|
|
115
115
|
|
|
116
116
|
const memoryStorage = await storage.getStore('memory')
|
|
117
117
|
|
|
118
|
-
const model = withMastra(openai('gpt-
|
|
118
|
+
const model = withMastra(openai('gpt-5.4'), {
|
|
119
119
|
inputProcessors: [myGuardProcessor],
|
|
120
120
|
outputProcessors: [myLoggingProcessor],
|
|
121
121
|
memory: {
|
|
@@ -18,7 +18,7 @@ const loggingProcessor: Processor<'logger'> = {
|
|
|
18
18
|
},
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const model = withMastra(openai('gpt-
|
|
21
|
+
const model = withMastra(openai('gpt-5.4'), {
|
|
22
22
|
inputProcessors: [loggingProcessor],
|
|
23
23
|
})
|
|
24
24
|
|
|
@@ -30,7 +30,7 @@ const { text } = await generateText({
|
|
|
30
30
|
|
|
31
31
|
## Parameters
|
|
32
32
|
|
|
33
|
-
**model** (`LanguageModelV2 | LanguageModelV3`): Any AI SDK v5 or v6 language model (e.g., \`openai('gpt-
|
|
33
|
+
**model** (`LanguageModelV2 | LanguageModelV3`): Any AI SDK v5 or v6 language model (e.g., \`openai('gpt-5.4')\`, \`anthropic('claude-opus-4-6')\`).
|
|
34
34
|
|
|
35
35
|
**options** (`WithMastraOptions`): Configuration object for processors and memory.
|
|
36
36
|
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# MastraAuthOkta & MastraRBACOkta class
|
|
2
|
+
|
|
3
|
+
## MastraAuthOkta class
|
|
4
|
+
|
|
5
|
+
The `MastraAuthOkta` class provides authentication for Mastra using Okta. It implements an OAuth 2.0 / OIDC login flow with encrypted session cookies and integrates with the Mastra server using the `auth` option.
|
|
6
|
+
|
|
7
|
+
### Usage example
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import { Mastra } from '@mastra/core'
|
|
11
|
+
import { MastraAuthOkta } from '@mastra/auth-okta'
|
|
12
|
+
|
|
13
|
+
export const mastra = new Mastra({
|
|
14
|
+
server: {
|
|
15
|
+
auth: new MastraAuthOkta({
|
|
16
|
+
domain: process.env.OKTA_DOMAIN,
|
|
17
|
+
clientId: process.env.OKTA_CLIENT_ID,
|
|
18
|
+
clientSecret: process.env.OKTA_CLIENT_SECRET,
|
|
19
|
+
redirectUri: process.env.OKTA_REDIRECT_URI,
|
|
20
|
+
}),
|
|
21
|
+
},
|
|
22
|
+
})
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
> **Note:** You can omit the constructor parameters if you have the appropriately named environment variables set. In that case, use `new MastraAuthOkta()` without any arguments.
|
|
26
|
+
|
|
27
|
+
### Constructor parameters
|
|
28
|
+
|
|
29
|
+
**domain** (`string`): Your Okta domain (e.g., \`dev-123456.okta.com\`). Used to construct the issuer URL and API endpoints. (Default: `process.env.OKTA_DOMAIN`)
|
|
30
|
+
|
|
31
|
+
**clientId** (`string`): The OAuth client ID from your Okta application. (Default: `process.env.OKTA_CLIENT_ID`)
|
|
32
|
+
|
|
33
|
+
**clientSecret** (`string`): The OAuth client secret. Required for the SSO authorization code flow. (Default: `process.env.OKTA_CLIENT_SECRET`)
|
|
34
|
+
|
|
35
|
+
**issuer** (`string`): The token issuer URL. Override this if you use a custom authorization server. (Default: `` `https://{domain}/oauth2/default` ``)
|
|
36
|
+
|
|
37
|
+
**redirectUri** (`string`): The OAuth redirect URI for the SSO callback. Must match the redirect URI configured in your Okta application. (Default: `process.env.OKTA_REDIRECT_URI`)
|
|
38
|
+
|
|
39
|
+
**scopes** (`string[]`): OAuth scopes to request during the login flow. (Default: `['openid', 'profile', 'email', 'groups']`)
|
|
40
|
+
|
|
41
|
+
**apiToken** (`string`): Okta API token for user lookups via the Users API. Required for \`getUser()\` to return user data by ID. (Default: `process.env.OKTA_API_TOKEN`)
|
|
42
|
+
|
|
43
|
+
**session** (`OktaSessionOptions`): Session cookie configuration.
|
|
44
|
+
|
|
45
|
+
**session.cookieName** (`string`): Name of the session cookie.
|
|
46
|
+
|
|
47
|
+
**session.cookieMaxAge** (`number`): Cookie max age in seconds.
|
|
48
|
+
|
|
49
|
+
**session.cookiePassword** (`string`): Password for encrypting session cookies. Must be at least 32 characters. If not set, an auto-generated value is used that does not survive restarts.
|
|
50
|
+
|
|
51
|
+
**session.secureCookies** (`boolean`): Set the \`Secure\` flag on session cookies.
|
|
52
|
+
|
|
53
|
+
**name** (`string`): Custom name for the auth provider instance. (Default: `'okta'`)
|
|
54
|
+
|
|
55
|
+
### Environment variables
|
|
56
|
+
|
|
57
|
+
The following environment variables are automatically used when constructor options are not provided:
|
|
58
|
+
|
|
59
|
+
**OKTA\_DOMAIN** (`string`): Your Okta domain (e.g., \`dev-123456.okta.com\`). Found in your Okta admin console.
|
|
60
|
+
|
|
61
|
+
**OKTA\_CLIENT\_ID** (`string`): The OAuth client ID from your Okta application.
|
|
62
|
+
|
|
63
|
+
**OKTA\_CLIENT\_SECRET** (`string`): The OAuth client secret from your Okta application.
|
|
64
|
+
|
|
65
|
+
**OKTA\_ISSUER** (`string`): Token issuer URL. Defaults to \`https\://{domain}/oauth2/default\` if not set.
|
|
66
|
+
|
|
67
|
+
**OKTA\_REDIRECT\_URI** (`string`): OAuth redirect URI for the SSO callback.
|
|
68
|
+
|
|
69
|
+
**OKTA\_COOKIE\_PASSWORD** (`string`): Password for encrypting session cookies. Must be at least 32 characters.
|
|
70
|
+
|
|
71
|
+
**OKTA\_API\_TOKEN** (`string`): Okta API token for user lookups and RBAC group resolution.
|
|
72
|
+
|
|
73
|
+
### Authentication flow
|
|
74
|
+
|
|
75
|
+
`MastraAuthOkta` authenticates requests in the following order:
|
|
76
|
+
|
|
77
|
+
1. **Session cookie**: Reads the encrypted session cookie and decrypts it. If the session is valid and not expired, the user is authenticated.
|
|
78
|
+
2. **JWT fallback**: If no session cookie is present, verifies the `Authorization` header token against Okta's JWKS endpoint.
|
|
79
|
+
|
|
80
|
+
After authentication, `authorizeUser` checks that the user has a valid `oktaId`. Provide a custom `authorizeUser` function to implement additional logic.
|
|
81
|
+
|
|
82
|
+
### `OktaUser` type
|
|
83
|
+
|
|
84
|
+
The `OktaUser` type extends the base `EEUser` interface with Okta-specific fields:
|
|
85
|
+
|
|
86
|
+
**id** (`string`): User identifier (maps to the \`sub\` claim).
|
|
87
|
+
|
|
88
|
+
**oktaId** (`string`): Okta user ID (same as \`id\`).
|
|
89
|
+
|
|
90
|
+
**email** (`string`): User email address.
|
|
91
|
+
|
|
92
|
+
**name** (`string`): User display name, constructed from token claims.
|
|
93
|
+
|
|
94
|
+
**avatarUrl** (`string`): URL to the user's profile picture.
|
|
95
|
+
|
|
96
|
+
**groups** (`string[]`): Okta groups the user belongs to, populated from the \`groups\` claim.
|
|
97
|
+
|
|
98
|
+
## MastraRBACOkta class
|
|
99
|
+
|
|
100
|
+
The `MastraRBACOkta` class maps Okta groups to Mastra permissions. It fetches user groups from the Okta API and resolves them against a configurable role mapping. Use it with `MastraAuthOkta` or any other auth provider.
|
|
101
|
+
|
|
102
|
+
> **Note:** RBAC requires a valid Enterprise Edition license. It works without a license in development so you can try it locally, but you’ll need a license for production. [Contact sales](https://mastra.ai/contact) for more information.
|
|
103
|
+
|
|
104
|
+
### Usage example
|
|
105
|
+
|
|
106
|
+
Use `MastraRBACOkta` alongside an auth provider by passing it to the `rbac` option:
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
import { Mastra } from '@mastra/core'
|
|
110
|
+
import { MastraAuthOkta, MastraRBACOkta } from '@mastra/auth-okta'
|
|
111
|
+
|
|
112
|
+
export const mastra = new Mastra({
|
|
113
|
+
server: {
|
|
114
|
+
auth: new MastraAuthOkta(),
|
|
115
|
+
rbac: new MastraRBACOkta({
|
|
116
|
+
roleMapping: {
|
|
117
|
+
Admin: ['*'],
|
|
118
|
+
Engineering: ['agents:*', 'workflows:*', 'tools:*'],
|
|
119
|
+
Viewer: ['agents:read', 'workflows:read'],
|
|
120
|
+
_default: [],
|
|
121
|
+
},
|
|
122
|
+
}),
|
|
123
|
+
},
|
|
124
|
+
})
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
To use Okta RBAC with a different auth provider, pass a `getUserId` function to resolve the Okta user ID from the other provider's user object:
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
import { MastraAuthAuth0 } from '@mastra/auth-auth0'
|
|
131
|
+
import { MastraRBACOkta } from '@mastra/auth-okta'
|
|
132
|
+
|
|
133
|
+
export const mastra = new Mastra({
|
|
134
|
+
server: {
|
|
135
|
+
auth: new MastraAuthAuth0(),
|
|
136
|
+
rbac: new MastraRBACOkta({
|
|
137
|
+
getUserId: user => user.metadata?.oktaUserId || user.email,
|
|
138
|
+
roleMapping: {
|
|
139
|
+
Engineering: ['agents:*', 'workflows:*'],
|
|
140
|
+
Admin: ['*'],
|
|
141
|
+
_default: [],
|
|
142
|
+
},
|
|
143
|
+
}),
|
|
144
|
+
},
|
|
145
|
+
})
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Constructor parameters
|
|
149
|
+
|
|
150
|
+
**roleMapping** (`RoleMapping`): Maps Okta group names to arrays of Mastra permission strings. Use \`'\_default'\` to assign permissions to users who do not match any group. Supports wildcards like \`'\*'\` (full access) and \`'agents:\*'\` (all agent actions).
|
|
151
|
+
|
|
152
|
+
**domain** (`string`): Your Okta domain. Used to initialize the Okta management SDK. (Default: `process.env.OKTA_DOMAIN`)
|
|
153
|
+
|
|
154
|
+
**apiToken** (`string`): Okta API token for the management SDK. Required to fetch user groups from the Okta API. (Default: `process.env.OKTA_API_TOKEN`)
|
|
155
|
+
|
|
156
|
+
**getUserId** (`(user: unknown) => string | undefined`): Extract the Okta user ID from a user object. Use this when combining Okta RBAC with a different auth provider. If not provided, falls back to \`oktaId\` or \`id\` on the user object.
|
|
157
|
+
|
|
158
|
+
**cache** (`PermissionCacheOptions`): Configure the LRU cache for group lookups.
|
|
159
|
+
|
|
160
|
+
**cache.maxSize** (`number`): Maximum number of users to cache.
|
|
161
|
+
|
|
162
|
+
**cache.ttlMs** (`number`): Time-to-live in milliseconds.
|
|
@@ -344,7 +344,7 @@ const agent = await mastraClient.createStoredAgent({
|
|
|
344
344
|
instructions: 'You are a helpful assistant.',
|
|
345
345
|
model: {
|
|
346
346
|
provider: 'openai',
|
|
347
|
-
name: 'gpt-4',
|
|
347
|
+
name: 'gpt-5.4',
|
|
348
348
|
},
|
|
349
349
|
})
|
|
350
350
|
```
|
|
@@ -359,7 +359,7 @@ const agent = await mastraClient.createStoredAgent({
|
|
|
359
359
|
instructions: 'You are a helpful assistant.',
|
|
360
360
|
model: {
|
|
361
361
|
provider: 'openai',
|
|
362
|
-
name: 'gpt-4',
|
|
362
|
+
name: 'gpt-5.4',
|
|
363
363
|
},
|
|
364
364
|
tools: ['calculator', 'weather'],
|
|
365
365
|
workflows: ['data-processing'],
|
|
@@ -546,9 +546,9 @@ import { createNoiseSensitivityScorerLLM } from '@mastra/evals'
|
|
|
546
546
|
|
|
547
547
|
async function compareModelRobustness() {
|
|
548
548
|
const models = [
|
|
549
|
-
{ name: 'GPT-5.
|
|
550
|
-
{ name: 'GPT-4
|
|
551
|
-
{ name: 'Claude', model: 'anthropic/claude-
|
|
549
|
+
{ name: 'GPT-5.4', model: 'openai/gpt-5.4' },
|
|
550
|
+
{ name: 'GPT-5.4-mini', model: 'openai/gpt-5.4-mini' },
|
|
551
|
+
{ name: 'Claude', model: 'anthropic/claude-opus-4-6' },
|
|
552
552
|
]
|
|
553
553
|
|
|
554
554
|
const testScenario = {
|
package/.docs/reference/index.md
CHANGED
|
@@ -35,6 +35,7 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
35
35
|
- [Clerk](https://mastra.ai/reference/auth/clerk)
|
|
36
36
|
- [Firebase](https://mastra.ai/reference/auth/firebase)
|
|
37
37
|
- [JSON Web Token](https://mastra.ai/reference/auth/jwt)
|
|
38
|
+
- [Okta](https://mastra.ai/reference/auth/okta)
|
|
38
39
|
- [Supabase](https://mastra.ai/reference/auth/supabase)
|
|
39
40
|
- [WorkOS](https://mastra.ai/reference/auth/workos)
|
|
40
41
|
- [create-mastra](https://mastra.ai/reference/cli/create-mastra)
|
|
@@ -632,8 +632,8 @@ import { ModelByInputTokens } from '@mastra/memory'
|
|
|
632
632
|
const selector = new ModelByInputTokens({
|
|
633
633
|
upTo: {
|
|
634
634
|
10_000: 'google/gemini-2.5-flash', // Fast for small inputs
|
|
635
|
-
40_000: 'openai/gpt-
|
|
636
|
-
1_000_000: 'openai/gpt-4
|
|
635
|
+
40_000: 'openai/gpt-5.4-mini', // Stronger for medium inputs
|
|
636
|
+
1_000_000: 'openai/gpt-5.4', // Most capable for large inputs
|
|
637
637
|
},
|
|
638
638
|
})
|
|
639
639
|
```
|
|
@@ -268,7 +268,7 @@ Model Generation attributes.
|
|
|
268
268
|
|
|
269
269
|
```typescript
|
|
270
270
|
interface ModelGenerationAttributes {
|
|
271
|
-
/** Model name (e.g., 'gpt-4', 'claude-
|
|
271
|
+
/** Model name (e.g., 'gpt-5.4', 'claude-opus-4-6') */
|
|
272
272
|
model?: string
|
|
273
273
|
|
|
274
274
|
/** Model provider (e.g., 'openai', 'anthropic') */
|
|
@@ -45,7 +45,7 @@ const storage = new PostgresStorage({
|
|
|
45
45
|
export const agent = new Agent({
|
|
46
46
|
name: 'memory-agent',
|
|
47
47
|
instructions: 'You are a helpful assistant with conversation memory',
|
|
48
|
-
model: 'openai
|
|
48
|
+
model: 'openai/gpt-5.4',
|
|
49
49
|
inputProcessors: [
|
|
50
50
|
new MessageHistory({
|
|
51
51
|
storage,
|
|
@@ -202,9 +202,9 @@ The method can return any combination of these properties:
|
|
|
202
202
|
When multiple processors implement `processInputStep`, they run in order and changes chain through:
|
|
203
203
|
|
|
204
204
|
```text
|
|
205
|
-
Processor 1: receives { model: 'gpt-
|
|
206
|
-
Processor 2: receives { model: 'gpt-
|
|
207
|
-
Final: model = 'gpt-
|
|
205
|
+
Processor 1: receives { model: 'gpt-5.4' } → returns { model: 'gpt-5.4-mini' }
|
|
206
|
+
Processor 2: receives { model: 'gpt-5.4-mini' } → returns { toolChoice: 'none' }
|
|
207
|
+
Final: model = 'gpt-5.4-mini', toolChoice = 'none'
|
|
208
208
|
```
|
|
209
209
|
|
|
210
210
|
#### System message isolation
|
|
@@ -82,7 +82,7 @@ const semanticRecall = new SemanticRecall({
|
|
|
82
82
|
export const agent = new Agent({
|
|
83
83
|
name: 'semantic-memory-agent',
|
|
84
84
|
instructions: 'You are a helpful assistant with semantic memory recall',
|
|
85
|
-
model: 'openai
|
|
85
|
+
model: 'openai/gpt-5.4',
|
|
86
86
|
inputProcessors: [semanticRecall, new MessageHistory({ storage, lastMessages: 50 })],
|
|
87
87
|
outputProcessors: [semanticRecall, new MessageHistory({ storage })],
|
|
88
88
|
})
|
|
@@ -39,7 +39,7 @@ import { ToolCallFilter } from '@mastra/core/processors'
|
|
|
39
39
|
export const agent = new Agent({
|
|
40
40
|
name: 'filtered-agent',
|
|
41
41
|
instructions: 'You are a helpful assistant',
|
|
42
|
-
model: 'openai
|
|
42
|
+
model: 'openai/gpt-5.4',
|
|
43
43
|
tools: {
|
|
44
44
|
searchDatabase,
|
|
45
45
|
sendEmail,
|
|
@@ -64,7 +64,7 @@ import { ToolCallFilter } from '@mastra/core/processors'
|
|
|
64
64
|
export const agent = new Agent({
|
|
65
65
|
name: 'no-tools-context-agent',
|
|
66
66
|
instructions: 'You are a helpful assistant',
|
|
67
|
-
model: 'openai
|
|
67
|
+
model: 'openai/gpt-5.4',
|
|
68
68
|
tools: {
|
|
69
69
|
searchDatabase,
|
|
70
70
|
sendEmail,
|
|
@@ -67,7 +67,7 @@ const storage = new PostgresStorage({
|
|
|
67
67
|
export const agent = new Agent({
|
|
68
68
|
name: 'personalized-agent',
|
|
69
69
|
instructions: 'You are a helpful assistant that remembers user preferences',
|
|
70
|
-
model: 'openai
|
|
70
|
+
model: 'openai/gpt-5.4',
|
|
71
71
|
inputProcessors: [
|
|
72
72
|
new WorkingMemory({
|
|
73
73
|
storage,
|
|
@@ -327,7 +327,7 @@ await agent.stream('message for agent', {
|
|
|
327
327
|
|
|
328
328
|
## OpenAI WebSocket transport
|
|
329
329
|
|
|
330
|
-
Opt into OpenAI Responses WebSocket streaming via `providerOptions.openai.transport`. This only applies to streaming calls and is currently supported for direct OpenAI models (for example, `openai/gpt-
|
|
330
|
+
Opt into OpenAI Responses WebSocket streaming via `providerOptions.openai.transport`. This only applies to streaming calls and is currently supported for direct OpenAI models (for example, `openai/gpt-5.4`). If WebSocket streaming is unavailable, Mastra falls back to HTTP streaming. By default, Mastra closes the WebSocket when the stream finishes.
|
|
331
331
|
|
|
332
332
|
```ts
|
|
333
333
|
const stream = await agent.stream('Hello', {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @mastra/mcp-docs-server
|
|
2
2
|
|
|
3
|
+
## 1.1.17-alpha.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`7302e5c`](https://github.com/mastra-ai/mastra/commit/7302e5ce0f52d769d3d63fb0faa8a7d4089cda6d)]:
|
|
8
|
+
- @mastra/core@1.16.1-alpha.1
|
|
9
|
+
|
|
3
10
|
## 1.1.17-alpha.0
|
|
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.1.17-alpha.
|
|
3
|
+
"version": "1.1.17-alpha.3",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"jsdom": "^26.1.0",
|
|
30
30
|
"local-pkg": "^1.1.2",
|
|
31
31
|
"zod": "^4.3.6",
|
|
32
|
-
"@mastra/
|
|
33
|
-
"@mastra/
|
|
32
|
+
"@mastra/mcp": "^1.3.1",
|
|
33
|
+
"@mastra/core": "1.16.1-alpha.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@hono/node-server": "^1.19.11",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"tsx": "^4.21.0",
|
|
47
47
|
"typescript": "^5.9.3",
|
|
48
48
|
"vitest": "4.0.18",
|
|
49
|
-
"@mastra/core": "1.16.1-alpha.0",
|
|
50
49
|
"@internal/lint": "0.0.74",
|
|
51
|
-
"@internal/types-builder": "0.0.49"
|
|
50
|
+
"@internal/types-builder": "0.0.49",
|
|
51
|
+
"@mastra/core": "1.16.1-alpha.1"
|
|
52
52
|
},
|
|
53
53
|
"homepage": "https://mastra.ai",
|
|
54
54
|
"repository": {
|