@stacksjs/defaults 0.75.622 → 0.75.624

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.
@@ -532,6 +532,45 @@ JSON primitives only. String bounds count Unicode code points. Diagnostics and
532
532
  response-metadata callback failures cannot reject the protocol handler.
533
533
 
534
534
 
535
+ ## Generate MCP tools from router APIs
536
+
537
+ For an existing API, use `mountRouterMCPServer` from
538
+ `@stacksjs/ai/router-mcp` in `routes/api.ts`:
539
+
540
+ ```typescript
541
+ import { mountRouterMCPServer } from '@stacksjs/ai/router-mcp'
542
+
543
+ mountRouterMCPServer({
544
+ name: 'my-app', version: '1.0.0',
545
+ authenticate: request => authenticateIntegrationToken(request),
546
+ })
547
+ ```
548
+
549
+ The app supplies the integration-token check, returning a principal or 401/403
550
+ Response. This mounts `/api/mcp`; the route file's prefix applies. It snapshots
551
+ this router's registered `/api` CRUD endpoints on the first POST, including
552
+ selected `useApi` models and user overrides. Calls re-enter the router with
553
+ Authorization forwarded, preserving middleware, validation, authorization and
554
+ ownership. Ambient cookies are not forwarded. The credential must satisfy the
555
+ API's own guards too. Arguments are `{ path?, query?, body? }`; field validation
556
+ remains in the API, and results are `{ status, body }`. Wildcard, optional and
557
+ constrained path parameters are omitted. Restart to rediscover changed routes.
558
+
559
+ Use `prefix` and `filter` to select routes, `configureTool(endpoint, tool)` to
560
+ rename/describe/change schemas/set availability/replace execution (or return
561
+ false), and `requestHeaders(context, endpoint)` for scoped API credentials.
562
+ Retain generated `execute` to retain the router's checks. Custom `tools`,
563
+ resources, prompts and every native server option can be supplied alongside
564
+ generated tools. `path` changes the mount; `router` chooses an instance;
565
+ `origin` supplies a canonical API URL context for in-process calls;
566
+ `maxResponseBytes` bounds API replies (default 1 MiB).
567
+
568
+ `createRouterMCPServer` returns an unmounted `{ handle }` for manual registration;
569
+ the first request's endpoint path is excluded. Filter out additional aliases.
570
+ See `docs/packages/ai.md` for the customization example and limitations.
571
+ Tests: `core/ai/tests/router-mcp.test.ts` and
572
+ `core/ai/tests/router-mcp-use-api.test.ts` (real generated CRUD over HTTP).
573
+
535
574
  ## Local CPU transcription
536
575
 
537
576
  `@stacksjs/ai/local-speech` exports `createLocalSpeechHandler` and
@@ -12,7 +12,7 @@ Browser runtime bindings are documented separately in `stacks-auto-imports`.
12
12
  |---|---|---|---|
13
13
  | `@stacksjs/action-runner` | [`stacks-actions`](../stacks-actions/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/action-runner/src/index.ts) | 1 |
14
14
  | `@stacksjs/actions` | [`stacks-actions`](../stacks-actions/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/actions/src/index.ts) | 127 |
15
- | `@stacksjs/ai` | [`stacks-ai`](../stacks-ai/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/index.ts) | 24 |
15
+ | `@stacksjs/ai` | [`stacks-ai`](../stacks-ai/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/index.ts) | 26 |
16
16
  | `@stacksjs/alias` | [`stacks-alias`](../stacks-alias/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/alias/src/index.ts) | 3 |
17
17
  | `@stacksjs/analytics` | [`stacks-analytics`](../stacks-analytics/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/analytics/src/index.ts) | 7 |
18
18
  | `@stacksjs/api` | [`stacks-api`](../stacks-api/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/api/src/index.ts) | 12 |
@@ -130,9 +130,9 @@ Guidance: [`stacks-ai`](../stacks-ai/SKILL.md). Source: [storage/framework/core/
130
130
 
131
131
  Declared runtime exports: `RealtimeError`, `assistantTurn`, `buildMessageWithImages`, `clearUsageReporters`, `connectRealtime`, `estimateMessageTokens`, `estimateTokens`, `fetchWithRetry`, `listUsageReporters`, `normalizeMessagesForProvider`, `onUsage`, `recordUsage`, `sanitizePrompt`, `toolResultsTurn`.
132
132
 
133
- Local source modules: [src/agents/index.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/agents/index.ts), [src/buddy.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/buddy.ts), [src/client.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/client.ts), [src/complete.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/complete.ts), [src/context.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/context.ts), [src/documents.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/documents.ts), [src/drivers/index.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/drivers/index.ts), [src/durable-retrieval.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/durable-retrieval.ts), [src/embedding-client.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/embedding-client.ts), [src/image.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/image.ts), [src/mcp-server.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/mcp-server.ts), [src/mcp.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/mcp.ts), [src/models.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/models.ts), [src/personalization.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/personalization.ts), [src/realtime.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/realtime.ts), [src/search.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/search.ts), [src/speech.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/speech.ts), [src/text.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/text.ts), [src/types.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/types.ts), [src/utils/client-bedrock-runtime.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/utils/client-bedrock-runtime.ts), [src/utils/client-bedrock.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/utils/client-bedrock.ts), [src/utils/model-access.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/utils/model-access.ts), [src/utils/retry.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/utils/retry.ts), [src/utils/tokens.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/utils/tokens.ts), [src/utils/tools.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/utils/tools.ts), [src/utils/usage.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/utils/usage.ts), [src/utils/vision.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/utils/vision.ts).
133
+ Local source modules: [src/agents/index.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/agents/index.ts), [src/buddy.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/buddy.ts), [src/client.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/client.ts), [src/complete.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/complete.ts), [src/context.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/context.ts), [src/documents.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/documents.ts), [src/drivers/index.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/drivers/index.ts), [src/durable-retrieval.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/durable-retrieval.ts), [src/embedding-client.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/embedding-client.ts), [src/image.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/image.ts), [src/mcp-server.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/mcp-server.ts), [src/mcp.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/mcp.ts), [src/models.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/models.ts), [src/personalization.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/personalization.ts), [src/realtime.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/realtime.ts), [src/router-mcp.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/router-mcp.ts), [src/search.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/search.ts), [src/speech.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/speech.ts), [src/text.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/text.ts), [src/types.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/types.ts), [src/utils/client-bedrock-runtime.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/utils/client-bedrock-runtime.ts), [src/utils/client-bedrock.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/utils/client-bedrock.ts), [src/utils/model-access.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/utils/model-access.ts), [src/utils/retry.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/utils/retry.ts), [src/utils/tokens.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/utils/tokens.ts), [src/utils/tools.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/utils/tools.ts), [src/utils/usage.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/utils/usage.ts), [src/utils/vision.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/src/utils/vision.ts).
134
134
 
135
- Evidence directory: [24 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
135
+ Evidence directory: [26 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ai/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
136
136
 
137
137
  ### @stacksjs/alias
138
138
 
@@ -2,7 +2,7 @@
2
2
  "publisher": "Stacks",
3
3
  "name": "vscode-stacks",
4
4
  "displayName": "Stacks",
5
- "version": "0.75.622",
5
+ "version": "0.75.624",
6
6
  "description": "Stacks, built into VS Code: stx templates, pickier linting and formatting, encrypted env files, the dev server preview and every buddy command. No other extensions required.",
7
7
  "license": "MIT",
8
8
  "funding": "https://github.com/sponsors/chrisbbreuer",
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/defaults",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.75.622",
5
+ "version": "0.75.624",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/stacksjs/stacks.git",
@@ -45,14 +45,14 @@
45
45
  "dependencies": {
46
46
  "@iconify-json/f7": "^1.2.2",
47
47
  "@iconify-json/hugeicons": "^1.2.35",
48
- "@stacksjs/mobile": "0.75.622",
48
+ "@stacksjs/mobile": "0.75.624",
49
49
  "@stacksjs/sanitizer": "^0.2.908",
50
50
  "@stacksjs/stx": "^0.2.908",
51
- "@stacksjs/strings": "0.75.622",
51
+ "@stacksjs/strings": "0.75.624",
52
52
  "@xterm/addon-fit": "^0.11.0",
53
53
  "@xterm/xterm": "^6.0.0",
54
54
  "ts-qr-codes": "^0.1.8",
55
- "@stacksjs/support": "0.75.622",
56
- "@stacksjs/browser": "0.75.622"
55
+ "@stacksjs/support": "0.75.624",
56
+ "@stacksjs/browser": "0.75.624"
57
57
  }
58
58
  }