@veloxts/mcp 0.6.73 → 0.6.75

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/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @veloxts/mcp
2
2
 
3
+ ## 0.6.75
4
+
5
+ ### Patch Changes
6
+
7
+ - feat(create): add --pm flag to skip package manager prompt
8
+ - Updated dependencies
9
+ - @veloxts/cli@0.6.75
10
+ - @veloxts/router@0.6.75
11
+ - @veloxts/validation@0.6.75
12
+
13
+ ## 0.6.74
14
+
15
+ ### Patch Changes
16
+
17
+ - docs: fix erroneous file paths and improve auth context documentation
18
+ - Updated dependencies
19
+ - @veloxts/cli@0.6.74
20
+ - @veloxts/router@0.6.74
21
+ - @veloxts/validation@0.6.74
22
+
3
23
  ## 0.6.73
4
24
 
5
25
  ### Patch Changes
package/dist/server.js CHANGED
@@ -96,6 +96,12 @@ export function createVeloxMCPServer(options = {}) {
96
96
  description: 'VeloxTS project information and structure',
97
97
  mimeType: 'text/plain',
98
98
  },
99
+ {
100
+ uri: 'velox://auth-context',
101
+ name: 'Authentication Context Guide',
102
+ description: 'How ctx.user is populated by userLoader and how to extend it',
103
+ mimeType: 'text/plain',
104
+ },
99
105
  ],
100
106
  };
101
107
  });
@@ -181,6 +187,106 @@ export function createVeloxMCPServer(options = {}) {
181
187
  ],
182
188
  };
183
189
  }
190
+ case 'velox://auth-context': {
191
+ const text = `# Authentication Context (ctx.user)
192
+
193
+ ## Overview
194
+
195
+ \`ctx.user\` is populated by the \`userLoader\` function, NOT directly from the database.
196
+ Only fields you explicitly return from \`userLoader\` will be available on \`ctx.user\`.
197
+
198
+ ## How ctx.user Gets Populated
199
+
200
+ 1. JWT token is validated from cookie/header
201
+ 2. User ID is extracted from token payload
202
+ 3. Your \`userLoader(userId)\` function is called
203
+ 4. The returned object becomes \`ctx.user\`
204
+
205
+ ## Default userLoader Returns
206
+
207
+ The scaffolded templates return:
208
+ \`\`\`typescript
209
+ {
210
+ id: string;
211
+ email: string;
212
+ name: string;
213
+ roles: string[];
214
+ }
215
+ \`\`\`
216
+
217
+ ## Where to Find userLoader
218
+
219
+ - **API template (\`--auth\`)**: \`src/config/auth.ts\`
220
+ - **RSC template (\`--rsc-auth\`)**: \`src/api/handler.ts\` (inline in \`createAuthConfig()\`)
221
+
222
+ ## Adding Fields to ctx.user
223
+
224
+ ### Step 1: Update userLoader
225
+
226
+ \`\`\`typescript
227
+ // In your userLoader function:
228
+ async function userLoader(userId: string) {
229
+ const user = await db.user.findUnique({ where: { id: userId } });
230
+ if (!user) return null;
231
+
232
+ return {
233
+ id: user.id,
234
+ email: user.email,
235
+ name: user.name,
236
+ roles: parseUserRoles(user.roles),
237
+ organizationId: user.organizationId, // Add new field here
238
+ };
239
+ }
240
+ \`\`\`
241
+
242
+ ### Step 2: Extend TypeScript Type (Optional)
243
+
244
+ \`\`\`typescript
245
+ declare module '@veloxts/auth' {
246
+ interface User {
247
+ organizationId: string;
248
+ }
249
+ }
250
+ \`\`\`
251
+
252
+ ## Alternative: Fetch Full User
253
+
254
+ If you only occasionally need extra fields, use the \`getFullUser\` helper:
255
+
256
+ \`\`\`typescript
257
+ import { getFullUser } from '@/utils/auth';
258
+
259
+ // In a procedure:
260
+ .query(async ({ ctx }) => {
261
+ const fullUser = await getFullUser(ctx);
262
+ return { organizationId: fullUser.organizationId };
263
+ })
264
+ \`\`\`
265
+
266
+ ## Common Mistake
267
+
268
+ \`\`\`typescript
269
+ // ❌ WRONG - undefined if not returned by userLoader
270
+ const orgId = ctx.user.organizationId;
271
+
272
+ // ✅ CORRECT - After adding to userLoader
273
+ const orgId = ctx.user.organizationId;
274
+
275
+ // ✅ ALTERNATIVE - Fetch full user when needed
276
+ const fullUser = await getFullUser(ctx);
277
+ const orgId = fullUser.organizationId;
278
+ \`\`\`
279
+ `;
280
+ return {
281
+ contents: [
282
+ {
283
+ uri,
284
+ mimeType: 'text/plain',
285
+ text,
286
+ },
287
+ ],
288
+ };
289
+ }
184
290
  default:
185
291
  throw new Error(`Unknown resource: ${uri}`);
186
292
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veloxts/mcp",
3
- "version": "0.6.73",
3
+ "version": "0.6.75",
4
4
  "description": "Model Context Protocol server for VeloxTS - expose project context to AI tools",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -24,9 +24,9 @@
24
24
  "dependencies": {
25
25
  "@modelcontextprotocol/sdk": "1.25.1",
26
26
  "typescript": "5.9.3",
27
- "@veloxts/cli": "0.6.73",
28
- "@veloxts/validation": "0.6.73",
29
- "@veloxts/router": "0.6.73"
27
+ "@veloxts/cli": "0.6.75",
28
+ "@veloxts/router": "0.6.75",
29
+ "@veloxts/validation": "0.6.75"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "zod": ">=3.25.0"