@frontmcp/sdk 1.10.8 → 1.10.9-rc.2
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/auth/flows/auth.verify.flow.d.ts +1 -1
- package/auth/flows/oauth.auth-ui.flow.d.ts +2 -2
- package/auth/flows/oauth.authorize.flow.d.ts +2 -2
- package/auth/flows/oauth.callback.flow.d.ts +2 -2
- package/auth/flows/oauth.connect.flow.d.ts +2 -2
- package/auth/flows/oauth.provider-callback.flow.d.ts +2 -2
- package/auth/flows/oauth.register.flow.d.ts +2 -2
- package/auth/flows/oauth.token.flow.d.ts +2 -2
- package/auth/flows/oauth.userinfo.flow.d.ts +2 -2
- package/auth/flows/session.verify.flow.d.ts +1 -1
- package/auth/flows/well-known.jwks.flow.d.ts +2 -2
- package/auth/flows/well-known.oauth-authorization-server.flow.d.ts +2 -2
- package/auth/flows/well-known.prm.flow.d.ts +2 -2
- package/auth/instances/instance.local-primary-auth.d.ts.map +1 -1
- package/browser/agent/agent.registry.mjs +1 -1
- package/browser/app/instances/app.esm.instance.mjs +4 -4
- package/browser/app/instances/app.remote.instance.mjs +6 -6
- package/browser/auth/auth-ui/auth-ui.registry.mjs +6 -6
- package/browser/auth/flows/oauth.authorize.flow.mjs +5 -5
- package/browser/auth/flows/oauth.callback.flow.mjs +11 -11
- package/browser/auth/flows/oauth.connect.flow.mjs +1 -1
- package/browser/auth/flows/oauth.register.flow.mjs +1 -1
- package/browser/auth/flows/oauth.token.flow.mjs +1 -1
- package/browser/auth/flows/well-known.oauth-authorization-server.flow.mjs +5 -5
- package/browser/auth/instances/instance.local-primary-auth.mjs +35 -11
- package/browser/auth/session/utils/session-id.utils.mjs +1 -1
- package/browser/common/entries/skill.entry.mjs +2 -2
- package/browser/common/entries/tool.entry.mjs +3 -3
- package/browser/common/interfaces/channel.interface.mjs +1 -1
- package/browser/common/interfaces/execution-context.interface.mjs +4 -4
- package/browser/common/interfaces/flow.interface.mjs +10 -0
- package/browser/common/interfaces/internal/primary-auth-provider.interface.mjs +2 -2
- package/browser/common/metadata/app.metadata.mjs +1 -1
- package/browser/common/metadata/front-mcp.metadata.mjs +5 -5
- package/browser/common/schemas/http-input.schema.mjs +9 -3
- package/browser/common/tokens/app.tokens.mjs +1 -1
- package/browser/common/tokens/front-mcp.tokens.mjs +1 -1
- package/browser/common/types/options/http/schema.mjs +4 -4
- package/browser/common/types/options/redis/schema.mjs +1 -1
- package/browser/common/types/options/sqlite/schema.mjs +3 -3
- package/browser/common/types/options/transport/schema.mjs +4 -4
- package/browser/common/utils/decide-request-intent.utils.mjs +13 -11
- package/browser/context/frontmcp-context.mjs +1 -1
- package/browser/direct/direct-client.mjs +29 -29
- package/browser/direct/direct-server.mjs +14 -14
- package/browser/errors/job.errors.mjs +1 -1
- package/browser/errors/mcp.error.mjs +4 -4
- package/browser/errors/plugin.errors.mjs +1 -1
- package/browser/errors/task.error.mjs +1 -1
- package/browser/errors/tool-credentials-required.error.mjs +2 -2
- package/browser/esm-loader/esm-module-loader.mjs +1 -7
- package/browser/esm-loader/import-computed.mjs +11 -0
- package/browser/esm-loader/semver.utils.mjs +17 -11
- package/browser/flows/flow.instance.mjs +55 -24
- package/browser/flows/flow.stages.mjs +3 -2
- package/browser/front-mcp/front-mcp.mjs +10 -14
- package/browser/ha/ha-manager.mjs +1 -1
- package/browser/ha/notification-relay.mjs +1 -1
- package/browser/index.cjs +1346 -1490
- package/browser/index.mjs +4 -4
- package/browser/job/store/job-definition-store.factory.mjs +1 -1
- package/browser/job/store/redis-job-definition.store.mjs +2 -2
- package/browser/job/tools/get-job-status.tool.mjs +1 -1
- package/browser/logger/logger.registry.mjs +1 -1
- package/browser/metrics/metrics.service.mjs +3 -3
- package/browser/prompt/prompt.registry.mjs +1 -1
- package/browser/provider/provider.registry.mjs +4 -4
- package/browser/remote-mcp/mcp-client.service.mjs +19 -19
- package/browser/remote-mcp/resilience/circuit-breaker.mjs +2 -2
- package/browser/resource/resource.registry.mjs +2 -2
- package/browser/scope/flows/http.request.flow.mjs +3 -3
- package/browser/scope/scope.instance.mjs +4 -4
- package/browser/scope/scope.utils.mjs +1 -1
- package/browser/skill/providers/memory-skill.provider.mjs +31 -9
- package/browser/skill/skill.registry.mjs +10 -10
- package/browser/task/flows/tasks-result.flow.mjs +2 -2
- package/browser/task/task.registry.mjs +5 -5
- package/browser/tool/flows/call-tool.flow.mjs +4 -4
- package/browser/tool/tool.instance.mjs +16 -7
- package/browser/tool/tool.registry.mjs +4 -4
- package/browser/tool/ui/ui-shared.mjs +1 -1
- package/browser/transport/adapters/transport.local.adapter.mjs +2 -2
- package/browser/transport/adapters/transport.streamable-http.adapter.mjs +13 -4
- package/browser/transport/event-stores/redis.event-store.mjs +1 -1
- package/browser/transport/mcp-20260728/client/mcp-stateless.client.mjs +1 -1
- package/browser/transport/mcp-20260728/request-notifications.mjs +1 -1
- package/browser/transport/transport.registry.mjs +15 -9
- package/browser/transport/web-response.renderer.mjs +2 -2
- package/browser/utils/lineage.utils.mjs +1 -1
- package/browser/workflow/tools/get-workflow-status.tool.mjs +1 -1
- package/common/interfaces/flow.interface.d.ts.map +1 -1
- package/common/schemas/http-input.schema.d.ts +3 -3
- package/common/schemas/http-input.schema.d.ts.map +1 -1
- package/common/utils/decide-request-intent.utils.d.ts.map +1 -1
- package/esm/esm-loader/import-computed.mjs +10 -0
- package/esm/index.mjs +136 -77029
- package/esm-loader/esm-module-loader.d.ts.map +1 -1
- package/esm-loader/import-computed.d.ts +21 -0
- package/esm-loader/import-computed.d.ts.map +1 -0
- package/esm-loader/import-computed.js +34 -0
- package/esm-loader/semver.utils.d.ts.map +1 -1
- package/flows/flow.instance.d.ts +1 -0
- package/flows/flow.instance.d.ts.map +1 -1
- package/flows/flow.stages.d.ts.map +1 -1
- package/front-mcp/front-mcp.d.ts.map +1 -1
- package/index.d.ts +9 -8
- package/index.d.ts.map +1 -1
- package/index.js +140 -77685
- package/mcp-registry/flows/server-card.flow.d.ts +2 -2
- package/mcp-registry/flows/well-known.ai-catalog.flow.d.ts +2 -2
- package/mcp-registry/flows/well-known.mcp-registry-auth.flow.d.ts +2 -2
- package/package.json +14 -10
- package/skill/flows/http/llm-full-txt.flow.d.ts +2 -2
- package/skill/flows/http/llm-txt.flow.d.ts +2 -2
- package/skill/flows/http/skills-api.flow.d.ts +2 -2
- package/skill/providers/memory-skill.provider.d.ts +1 -0
- package/skill/providers/memory-skill.provider.d.ts.map +1 -1
- package/tool/tool.instance.d.ts +3 -0
- package/tool/tool.instance.d.ts.map +1 -1
- package/transport/adapters/transport.streamable-http.adapter.d.ts +2 -1
- package/transport/adapters/transport.streamable-http.adapter.d.ts.map +1 -1
- package/transport/transport.registry.d.ts +1 -0
- package/transport/transport.registry.d.ts.map +1 -1
- package/browser/transport/index.mjs +0 -32
|
@@ -1,5 +1,14 @@
|
|
|
1
|
+
var __frontmcpModule = typeof process !== "undefined" && typeof process.getBuiltinModule === "function" ? process.getBuiltinModule("module") : undefined;
|
|
2
|
+
const require = __frontmcpModule ? __frontmcpModule.createRequire(import.meta.url || 'file:///') : undefined;
|
|
3
|
+
// __frontmcpCreateRequire
|
|
4
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
5
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
6
|
+
}) : x)(function(x) {
|
|
7
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
8
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
9
|
+
});
|
|
10
|
+
|
|
1
11
|
// libs/sdk/src/auth/instances/instance.local-primary-auth.ts
|
|
2
|
-
import { jwtVerify, SignJWT } from "jose";
|
|
3
12
|
import {
|
|
4
13
|
createSecureStore,
|
|
5
14
|
createTokenStorageAdapter,
|
|
@@ -45,6 +54,7 @@ import {
|
|
|
45
54
|
} from "../../common/types/options/auth/index.mjs";
|
|
46
55
|
import { installContextExtensions } from "../../context/context-extension.mjs";
|
|
47
56
|
import { JwtSecretRequiredError, JwtSecretWeakError } from "../../errors/index.mjs";
|
|
57
|
+
import { importWithRequireFallback } from "../../utils/dynamic-import.utils.mjs";
|
|
48
58
|
import { CimdService } from "../cimd/index.mjs";
|
|
49
59
|
import { createCredentialsProviders } from "../credentials/index.mjs";
|
|
50
60
|
import { credentialsContextExtension } from "../credentials/credentials.context-extension.mjs";
|
|
@@ -62,6 +72,17 @@ import WellKnownAsFlow from "../flows/well-known.oauth-authorization-server.flow
|
|
|
62
72
|
import WellKnownPrmFlow from "../flows/well-known.prm.flow.mjs";
|
|
63
73
|
import { createSecureStoreProviders } from "../secure-store/index.mjs";
|
|
64
74
|
import { secureStoreContextExtension } from "../secure-store/secure-store.context-extension.mjs";
|
|
75
|
+
var jose;
|
|
76
|
+
function loadJose() {
|
|
77
|
+
jose ??= importWithRequireFallback(
|
|
78
|
+
() => import("jose"),
|
|
79
|
+
() => __require("jose")
|
|
80
|
+
).catch((error) => {
|
|
81
|
+
jose = void 0;
|
|
82
|
+
throw error;
|
|
83
|
+
});
|
|
84
|
+
return jose;
|
|
85
|
+
}
|
|
65
86
|
var MIN_HS256_SECRET_BYTES = 32;
|
|
66
87
|
var defaultNoAuthSecret;
|
|
67
88
|
function getDefaultNoAuthSecret() {
|
|
@@ -183,8 +204,8 @@ var LocalPrimaryAuth = class extends FrontMcpAuth {
|
|
|
183
204
|
cimdService;
|
|
184
205
|
/**
|
|
185
206
|
* Token storage backend selected from `options.tokenStorage`.
|
|
186
|
-
* - `'memory'` / undefined
|
|
187
|
-
* - `{ redis }` / `{ sqlite }`
|
|
207
|
+
* - `'memory'` / undefined \u2192 in-memory stores (default; lost on restart).
|
|
208
|
+
* - `{ redis }` / `{ sqlite }` \u2192 adapter-backed stores that survive restart.
|
|
188
209
|
*
|
|
189
210
|
* The three stores below are constructed in-memory synchronously in the
|
|
190
211
|
* constructor (preserving the exact legacy default behavior). When a
|
|
@@ -320,8 +341,8 @@ var LocalPrimaryAuth = class extends FrontMcpAuth {
|
|
|
320
341
|
* `FRONTMCP_PUBLIC_HOST` overrides only the HOST portion of the boot-time
|
|
321
342
|
* issuer (see `this.host` in the constructor); the scheme stays `http` and
|
|
322
343
|
* the port stays `this.port`. To override the scheme and/or port (e.g.
|
|
323
|
-
* advertise `https
|
|
324
|
-
* explicit `local.issuer`
|
|
344
|
+
* advertise `https://\u2026` with no explicit port behind a TLS proxy), set an
|
|
345
|
+
* explicit `local.issuer` \u2014 that is the supported way to make the boot-time
|
|
325
346
|
* issuer match what discovery advertises. JWT verification accepts an issuer
|
|
326
347
|
* array, so tokens minted under a different scheme/port are still tolerated
|
|
327
348
|
* when running behind a TLS-terminating proxy, but `local.issuer` is the
|
|
@@ -563,11 +584,11 @@ var LocalPrimaryAuth = class extends FrontMcpAuth {
|
|
|
563
584
|
*
|
|
564
585
|
* Skipped in pure public mode (no authenticated subject / no session-bound
|
|
565
586
|
* secrets there). The backing comes from `auth.secureStore`:
|
|
566
|
-
* - unset / `'memory'`
|
|
567
|
-
* - `{ sqlite }` / `{ redis }`
|
|
587
|
+
* - unset / `'memory'` \u2192 in-memory, AES-256-GCM-encrypted store (default);
|
|
588
|
+
* - `{ sqlite }` / `{ redis }` \u2192 persistent encrypted store. When the chosen
|
|
568
589
|
* persistent backing matches the configured `tokenStorage`, the SAME
|
|
569
590
|
* StorageAdapter is reused (one connection);
|
|
570
|
-
* - `{ backend }`
|
|
591
|
+
* - `{ backend }` \u2192 a custom backing used as-is (e.g. an OS keychain) \u2014 the
|
|
571
592
|
* framework bundles NO native dependency for this path.
|
|
572
593
|
*
|
|
573
594
|
* The HKDF pepper for the built-in encrypted backings derives from the server
|
|
@@ -638,6 +659,7 @@ var LocalPrimaryAuth = class extends FrontMcpAuth {
|
|
|
638
659
|
* @param options.issuer The issuer to name (`iss`): {@link issuerFor} the request. Default: the boot-time issuer.
|
|
639
660
|
*/
|
|
640
661
|
async signAnonymousJwt(options = {}) {
|
|
662
|
+
const { SignJWT } = await loadJose();
|
|
641
663
|
const jwt = new SignJWT({ sub: `anon:${randomUUID()}`, anonymous: true, scope: this.anonymousScopes().join(" ") }).setProtectedHeader({ alg: "HS256", typ: "JWT" }).setIssuedAt().setIssuer(options.issuer ?? this.issuer).setExpirationTime(`${this.anonymousTokenTtlSeconds()}s`).setJti(randomUUID());
|
|
642
664
|
if (options.audience) jwt.setAudience(options.audience);
|
|
643
665
|
return jwt.sign(this.secret);
|
|
@@ -653,8 +675,8 @@ var LocalPrimaryAuth = class extends FrontMcpAuth {
|
|
|
653
675
|
}
|
|
654
676
|
/**
|
|
655
677
|
* Cryptographically verify a gateway-issued access token (public/local/remote
|
|
656
|
-
* "gateway" modes). Gateway tokens
|
|
657
|
-
* ({@link signAccessToken}) and anonymous tokens ({@link signAnonymousJwt})
|
|
678
|
+
* "gateway" modes). Gateway tokens \u2014 both authenticated access tokens
|
|
679
|
+
* ({@link signAccessToken}) and anonymous tokens ({@link signAnonymousJwt}) \u2014
|
|
658
680
|
* are HS256-signed with `this.secret`.
|
|
659
681
|
*
|
|
660
682
|
* The secret alone doesn't make a token this server's: every server started
|
|
@@ -673,6 +695,7 @@ var LocalPrimaryAuth = class extends FrontMcpAuth {
|
|
|
673
695
|
*/
|
|
674
696
|
async verifyGatewayToken(token, requestBaseUrl, expectedAudience, expectedIssuer) {
|
|
675
697
|
try {
|
|
698
|
+
const { jwtVerify } = await loadJose();
|
|
676
699
|
const { payload, protectedHeader } = await jwtVerify(token, this.secret, {
|
|
677
700
|
algorithms: ["HS256"],
|
|
678
701
|
issuer: typeof expectedIssuer === "string" ? expectedIssuer : expectedIssuer ? [...expectedIssuer] : this.issuer,
|
|
@@ -732,6 +755,7 @@ var LocalPrimaryAuth = class extends FrontMcpAuth {
|
|
|
732
755
|
}
|
|
733
756
|
}
|
|
734
757
|
}
|
|
758
|
+
const { SignJWT } = await loadJose();
|
|
735
759
|
const jwt = new SignJWT(claims).setProtectedHeader({ alg: "HS256", typ: "JWT" }).setIssuedAt().setIssuer(issuer ?? this.issuer).setExpirationTime(`${this.accessTokenTtlSeconds}s`).setJti(randomUUID());
|
|
736
760
|
if (audience) {
|
|
737
761
|
jwt.setAudience(audience);
|
|
@@ -1151,7 +1175,7 @@ var LocalPrimaryAuth = class extends FrontMcpAuth {
|
|
|
1151
1175
|
* `userInfoEndpoint`/`jwksUri`) are mapped onto an {@link UpstreamProviderConfig}.
|
|
1152
1176
|
* Endpoints not explicitly overridden are derived from the `provider` base URL
|
|
1153
1177
|
* using the standard OIDC paths (`/authorize`, `/token`, `/userinfo`,
|
|
1154
|
-
* `/.well-known/jwks.json`)
|
|
1178
|
+
* `/.well-known/jwks.json`) \u2014 the same convention `transparent` mode uses for
|
|
1155
1179
|
* discovery. The provider id comes from `providerConfig.id` when set, else it
|
|
1156
1180
|
* is derived from the provider hostname (mirroring `deriveProviderId`).
|
|
1157
1181
|
*
|
|
@@ -19,7 +19,7 @@ function isValidSessionPayload(dec, sig) {
|
|
|
19
19
|
function isValidPublicSessionPayload(dec, expectedAuthSig = "public") {
|
|
20
20
|
if (typeof dec !== "object" || dec === null) return false;
|
|
21
21
|
const d = dec;
|
|
22
|
-
return typeof d["nodeId"] === "string" && d["authSig"] === expectedAuthSig && typeof d["uuid"] === "string" && typeof d["iat"] === "number" && // `isPublic` is set only for public mode, so it must track the signature
|
|
22
|
+
return typeof d["nodeId"] === "string" && d["authSig"] === expectedAuthSig && typeof d["uuid"] === "string" && typeof d["iat"] === "number" && // `isPublic` is set only for public mode, so it must track the signature \u2014
|
|
23
23
|
// a static-mode session must never decrypt as a public one.
|
|
24
24
|
d["isPublic"] === (expectedAuthSig === "public");
|
|
25
25
|
}
|
|
@@ -44,7 +44,7 @@ var SkillEntry = class extends BaseEntry {
|
|
|
44
44
|
return this.metadata.hideFromDiscovery === true;
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
|
-
* Check if this skill is always loaded
|
|
47
|
+
* Check if this skill is always loaded \u2014 bindings derived from this skill
|
|
48
48
|
* are merged into every codecall:execute call regardless of the skills the
|
|
49
49
|
* agent passed. See SkillMetadata.alwaysLoad for guidance on when to set this.
|
|
50
50
|
*/
|
|
@@ -60,7 +60,7 @@ var SkillEntry = class extends BaseEntry {
|
|
|
60
60
|
return this.metadata.referencedOperations ?? [];
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
|
-
* Whether this skill is "executable"
|
|
63
|
+
* Whether this skill is "executable" \u2014 has at least one declared tool
|
|
64
64
|
* OR at least one referenced openapi operation. Skills with neither are
|
|
65
65
|
* pure-knowledge: discoverable via searchKnowledge, callable via execute()
|
|
66
66
|
* but with no tool bindings (the agentscript can only do pure computation).
|
|
@@ -82,10 +82,10 @@ var ToolEntry = class extends BaseEntry {
|
|
|
82
82
|
*
|
|
83
83
|
* Prefers an explicit `rawOutputSchema` (the JSON Schema set by the OpenAPI adapter /
|
|
84
84
|
* remote tools); otherwise converts a Zod-shape or `z.object()` `outputSchema` to JSON
|
|
85
|
-
* Schema
|
|
85
|
+
* Schema \u2014 symmetric with {@link getInputJsonSchema}. Returns `null` for output forms
|
|
86
86
|
* that have no object-typed schema to advertise: primitive / media string literals
|
|
87
|
-
* (`'string'`, `'image'`,
|
|
88
|
-
* schema that does not serialize to a top-level `type: 'object'` (e.g. a union)
|
|
87
|
+
* (`'string'`, `'image'`, \u2026), multi-content arrays (`['string', 'image']`), and any
|
|
88
|
+
* schema that does not serialize to a top-level `type: 'object'` (e.g. a union) \u2014 those
|
|
89
89
|
* flow through `content`, not `structuredContent`, per the MCP spec.
|
|
90
90
|
*
|
|
91
91
|
* @returns JSON Schema object, or null if there is no advertisable output schema.
|
|
@@ -63,7 +63,7 @@ var ChannelContext = class extends ExecutionContextBase {
|
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
65
|
* Push an incoming event from a service connection into the notification pipeline.
|
|
66
|
-
* This triggers `onEvent()`
|
|
66
|
+
* This triggers `onEvent()` \u2192 notification push to all capable Claude Code sessions.
|
|
67
67
|
*
|
|
68
68
|
* Use this inside `onConnect()` when you receive events from persistent connections
|
|
69
69
|
* (WebSocket messages, polling results, etc.).
|
|
@@ -194,7 +194,7 @@ var ExecutionContextBase = class {
|
|
|
194
194
|
* blocks `tools/call` for tools with `metadata.visibility === 'internal'`.
|
|
195
195
|
* Public and hidden tools are reachable through this helper too.
|
|
196
196
|
*
|
|
197
|
-
* Authority/authorization checks still run
|
|
197
|
+
* Authority/authorization checks still run \u2014 an internal call carries the
|
|
198
198
|
* same `authInfo` as the surrounding request, so ABAC/RBAC guards apply.
|
|
199
199
|
*
|
|
200
200
|
* `availableWhen.surface`: the call carries {@link callToolSurface}. From a tool, resource or
|
|
@@ -203,7 +203,7 @@ var ExecutionContextBase = class {
|
|
|
203
203
|
* leaves that caller out answers as an unknown tool.
|
|
204
204
|
*
|
|
205
205
|
* @param name Tool name, or one qualified with its app's id: `owner:name` or `owner.name`.
|
|
206
|
-
* @param args Tool arguments
|
|
206
|
+
* @param args Tool arguments \u2014 validated by the tool's input schema.
|
|
207
207
|
* @param opts Optional progress token / abort signal forwarded into `_meta`.
|
|
208
208
|
* @returns The tool's `CallToolResult`.
|
|
209
209
|
*/
|
|
@@ -324,13 +324,13 @@ var ExecutionContextBase = class {
|
|
|
324
324
|
}
|
|
325
325
|
// ---- Platform bindings ----
|
|
326
326
|
/**
|
|
327
|
-
* The hosting platform's bindings for the current request
|
|
327
|
+
* The hosting platform's bindings for the current request \u2014 on a Cloudflare Worker, the `env`
|
|
328
328
|
* object holding KV namespaces, D1 databases, R2 buckets, Durable Object namespaces, `[vars]`
|
|
329
329
|
* and secrets. `undefined` where the request carries no such object: Node/Express and stdio.
|
|
330
330
|
*
|
|
331
331
|
* A direct server (`create()`, `FrontMcpInstance.createDirect()`, `connect()`) has the bindings
|
|
332
332
|
* its caller passes: `DirectCallOptions.workerEnv` for one call, `ConnectOptions.workerEnv` for a
|
|
333
|
-
* client, or the server-wide default `create({ workerEnv })`
|
|
333
|
+
* client, or the server-wide default `create({ workerEnv })` \u2014 so a server embedded in a Durable
|
|
334
334
|
* Object, queue consumer or custom route reaches its KV, D1 and R2. `undefined` when none is passed.
|
|
335
335
|
*
|
|
336
336
|
* The SDK never writes `process.env`. The Worker entry that `frontmcp build --target cloudflare`
|
|
@@ -2,11 +2,21 @@
|
|
|
2
2
|
import { brandClass, isBrandedInstance } from "@frontmcp/utils";
|
|
3
3
|
import { FrontMcpContextStorage } from "../../context/frontmcp-context-storage.mjs";
|
|
4
4
|
import { FlowState } from "./internal/flow.utils.mjs";
|
|
5
|
+
function setStackTraceLimit(limit) {
|
|
6
|
+
try {
|
|
7
|
+
Error.stackTraceLimit = limit;
|
|
8
|
+
} catch {
|
|
9
|
+
}
|
|
10
|
+
}
|
|
5
11
|
var FlowControl = class _FlowControl extends Error {
|
|
6
12
|
constructor(type, output) {
|
|
13
|
+
const stackTraceLimit = Error.stackTraceLimit;
|
|
14
|
+
const skipStack = typeof stackTraceLimit === "number" && type !== "fail" && type !== "abort";
|
|
15
|
+
if (skipStack) setStackTraceLimit(0);
|
|
7
16
|
super();
|
|
8
17
|
this.type = type;
|
|
9
18
|
this.output = output;
|
|
19
|
+
if (skipStack) setStackTraceLimit(stackTraceLimit);
|
|
10
20
|
}
|
|
11
21
|
type;
|
|
12
22
|
output;
|
|
@@ -36,13 +36,13 @@ var FrontMcpAuth = class {
|
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
38
|
* Cryptographically verify a gateway-issued access token (public/local/remote
|
|
39
|
-
* "gateway" modes
|
|
39
|
+
* "gateway" modes \u2014 i.e. NOT transparent). Gateway tokens are signed by this
|
|
40
40
|
* instance, so the instance is the only place that holds the verification key.
|
|
41
41
|
*
|
|
42
42
|
* The base implementation rejects everything: only auth instances that
|
|
43
43
|
* actually mint gateway tokens (i.e. {@link LocalPrimaryAuth}) override this
|
|
44
44
|
* with a real signature + expiration check. Transparent mode never calls this
|
|
45
|
-
*
|
|
45
|
+
* \u2014 it verifies against the upstream provider's JWKS instead.
|
|
46
46
|
*
|
|
47
47
|
* @param _token The raw bearer token (already confirmed to be a JWT).
|
|
48
48
|
* @param _requestBaseUrl The request-derived base URL, for context / logging.
|
|
@@ -22,7 +22,7 @@ import { widgetServingModeSchema } from "./ui-serving-mode.mjs";
|
|
|
22
22
|
var frontMcpLocalAppMetadataSchema = z.looseObject({
|
|
23
23
|
id: z.string().optional(),
|
|
24
24
|
name: z.string().min(1),
|
|
25
|
-
// Captured call-site dir (#469
|
|
25
|
+
// Captured call-site dir (#469 \u2014 anchors auth.ui relative paths for splitByApp).
|
|
26
26
|
__sourceDir: z.string().optional(),
|
|
27
27
|
description: z.string().optional(),
|
|
28
28
|
providers: z.array(z.lazy(() => annotatedFrontMcpProvidersSchema)).optional().default([]),
|
|
@@ -37,7 +37,7 @@ import { outputPolicySchema } from "./output-policy.mjs";
|
|
|
37
37
|
import { widgetServingModeSchema } from "./ui-serving-mode.mjs";
|
|
38
38
|
var frontMcpBaseSchema = z.object({
|
|
39
39
|
info: serverInfoOptionsSchema,
|
|
40
|
-
// Captured call-site dir (#469
|
|
40
|
+
// Captured call-site dir (#469 \u2014 anchors auth.ui relative paths). Passthrough
|
|
41
41
|
// so it survives the strict-object parse and reaches the scope metadata.
|
|
42
42
|
__sourceDir: z.string().optional(),
|
|
43
43
|
instructions: z.string().optional(),
|
|
@@ -70,7 +70,7 @@ var frontMcpBaseSchema = z.object({
|
|
|
70
70
|
/**
|
|
71
71
|
* Output-validation policy applied after entry-level Zod parsing succeeds.
|
|
72
72
|
* `allowNonFinite: true` lets `Infinity`, `-Infinity`, and `NaN` reach JSON
|
|
73
|
-
* serialization (where they become `null`). Default is `false`
|
|
73
|
+
* serialization (where they become `null`). Default is `false` \u2014 non-finite
|
|
74
74
|
* numeric output throws `InvalidOutputError`.
|
|
75
75
|
*/
|
|
76
76
|
output: outputPolicySchema.optional(),
|
|
@@ -185,7 +185,7 @@ function applyAutoTransportPersistence(data) {
|
|
|
185
185
|
var frontMcpMetadataSchema = frontMcpMultiAppSchema.or(frontMcpSplitByAppSchema).transform(applyAutoTransportPersistence);
|
|
186
186
|
var frontMcpLiteSchema = z.object({
|
|
187
187
|
info: serverInfoOptionsSchema,
|
|
188
|
-
// Captured call-site dir (#469)
|
|
188
|
+
// Captured call-site dir (#469) \u2014 round-trip through the lite parser too.
|
|
189
189
|
__sourceDir: z.string().optional(),
|
|
190
190
|
// Server-level instructions injected into the MCP `initialize` response.
|
|
191
191
|
// Must round-trip through the lite parser so CLI/MCPB builds preserve it.
|
|
@@ -203,7 +203,7 @@ var frontMcpLiteSchema = z.object({
|
|
|
203
203
|
logging: loggingOptionsSchema.optional(),
|
|
204
204
|
skillsConfig: skillsConfigOptionsSchema.optional(),
|
|
205
205
|
loader: packageLoaderSchema.optional(),
|
|
206
|
-
// Pass through without deep validation
|
|
206
|
+
// Pass through without deep validation \u2014 not used in CLI mode
|
|
207
207
|
http: z.any().optional(),
|
|
208
208
|
redis: z.any().optional(),
|
|
209
209
|
pubsub: z.any().optional(),
|
|
@@ -218,7 +218,7 @@ var frontMcpLiteSchema = z.object({
|
|
|
218
218
|
throttle: z.any().optional(),
|
|
219
219
|
health: z.any().optional(),
|
|
220
220
|
metrics: z.any().optional(),
|
|
221
|
-
// Required by Scope.validateAuthoritiesConfig
|
|
221
|
+
// Required by Scope.validateAuthoritiesConfig \u2014 when entries declare
|
|
222
222
|
// `authorities` metadata the engine still needs the top-level config
|
|
223
223
|
// to instantiate. Pass-through (`z.any()`) so CLI/MCPB builds work
|
|
224
224
|
// without forcing the full base-schema validation pipeline.
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
// libs/sdk/src/common/schemas/http-input.schema.ts
|
|
2
2
|
import { z } from "@frontmcp/lazy-zod";
|
|
3
|
+
var httpObjectSchema = () => z.custom().check((ctx) => {
|
|
4
|
+
const value = ctx.value;
|
|
5
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
6
|
+
ctx.issues.push({ code: "invalid_type", expected: "object", input: value });
|
|
7
|
+
}
|
|
8
|
+
});
|
|
3
9
|
var httpInputSchema = z.object({
|
|
4
|
-
request:
|
|
10
|
+
request: httpObjectSchema(),
|
|
5
11
|
// TODO: must be validated
|
|
6
|
-
response:
|
|
12
|
+
response: httpObjectSchema(),
|
|
7
13
|
next: z.function().optional()
|
|
8
14
|
});
|
|
9
15
|
var httpRequestInputSchema = z.object({
|
|
10
|
-
request:
|
|
16
|
+
request: httpObjectSchema()
|
|
11
17
|
// TODO: must be validated
|
|
12
18
|
});
|
|
13
19
|
export {
|
|
@@ -22,7 +22,7 @@ var FrontMcpLocalAppTokens = {
|
|
|
22
22
|
// tool UI defaults (`ui.servingMode`) for the app's tools (#720)
|
|
23
23
|
ui: tokenFactory.meta("ui"),
|
|
24
24
|
standalone: tokenFactory.meta("standalone"),
|
|
25
|
-
// Captured call-site dir (#469)
|
|
25
|
+
// Captured call-site dir (#469) \u2014 anchors auth.ui relative paths for splitByApp.
|
|
26
26
|
__sourceDir: tokenFactory.meta("__sourceDir")
|
|
27
27
|
};
|
|
28
28
|
var FrontMcpRemoteAppTokens = {
|
|
@@ -3,7 +3,7 @@ import { tokenFactory } from "./base.tokens.mjs";
|
|
|
3
3
|
var FrontMcpTokens = {
|
|
4
4
|
type: tokenFactory.type("root"),
|
|
5
5
|
info: tokenFactory.meta("info"),
|
|
6
|
-
// Captured call-site dir (#469)
|
|
6
|
+
// Captured call-site dir (#469) \u2014 anchors auth.ui relative paths.
|
|
7
7
|
__sourceDir: tokenFactory.meta("__sourceDir"),
|
|
8
8
|
instructions: tokenFactory.meta("instructions"),
|
|
9
9
|
apps: tokenFactory.meta("apps"),
|
|
@@ -54,7 +54,7 @@ var httpOptionsSchema = z.object({
|
|
|
54
54
|
port: z.number().optional().default(defaultHttpPort),
|
|
55
55
|
// `FRONTMCP_HTTP_ENTRY_PATH` lets `frontmcp dev` propagate the configured
|
|
56
56
|
// `transport.http.path` to the spawned server so the MCP endpoint is mounted
|
|
57
|
-
// where the generated client URL points (#446)
|
|
57
|
+
// where the generated client URL points (#446) \u2014 mirrors how `port` reads
|
|
58
58
|
// `PORT` above. The function default reads the env at parse time. An explicit
|
|
59
59
|
// `entryPath` in `@FrontMcp({ http })` still wins (the default applies only
|
|
60
60
|
// when the field is omitted).
|
|
@@ -70,7 +70,7 @@ var httpOptionsSchema = z.object({
|
|
|
70
70
|
socketPath: z.string().optional(),
|
|
71
71
|
/**
|
|
72
72
|
* CORS configuration.
|
|
73
|
-
* - undefined (default): NO CORS headers
|
|
73
|
+
* - undefined (default): NO CORS headers \u2014 same-origin only. A browser will not let another
|
|
74
74
|
* origin read the response. Set `{ origin: true }` for the old permissive behaviour.
|
|
75
75
|
* - false: CORS disabled (same effect as the default; kept for explicitness)
|
|
76
76
|
* - CorsOptions object: custom CORS config
|
|
@@ -80,9 +80,9 @@ var httpOptionsSchema = z.object({
|
|
|
80
80
|
* Security configuration for transport hardening.
|
|
81
81
|
*
|
|
82
82
|
* The defaults are the SAFE choice: the server binds loopback and sends no CORS headers. Reaching
|
|
83
|
-
* it from another host or another origin is something you opt into
|
|
83
|
+
* it from another host or another origin is something you opt into \u2014 `bindAddress: 'all'`, the
|
|
84
84
|
* `FRONTMCP_BIND_ADDRESS=all` env var (no rebuild; the right fit for a Dockerfile), or a
|
|
85
|
-
* distributed build
|
|
85
|
+
* distributed build \u2014 and an explicit `cors` config.
|
|
86
86
|
*/
|
|
87
87
|
security: z.object({
|
|
88
88
|
strict: z.boolean().optional(),
|
|
@@ -106,7 +106,7 @@ function parseRedisUrl(raw) {
|
|
|
106
106
|
}
|
|
107
107
|
var redisUrlSchema = z.object({
|
|
108
108
|
/**
|
|
109
|
-
* Storage provider type
|
|
109
|
+
* Storage provider type \u2014 optional, a `url` already says Redis.
|
|
110
110
|
*/
|
|
111
111
|
provider: z.literal("redis").optional(),
|
|
112
112
|
/**
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
import { z } from "@frontmcp/lazy-zod";
|
|
3
3
|
var sqliteOptionsSchema = z.object({
|
|
4
4
|
/**
|
|
5
|
-
* Path to the .sqlite database file. **Optional**
|
|
5
|
+
* Path to the .sqlite database file. **Optional** \u2014 when omitted the SDK
|
|
6
6
|
* resolves a default at startup (see `resolveDefaultSqlitePath` in
|
|
7
7
|
* `./resolve.ts`):
|
|
8
|
-
* - dev + node + non-CLI
|
|
9
|
-
* - prod OR CLI mode
|
|
8
|
+
* - dev + node + non-CLI \u2192 `<projectRoot>/dist/sessions.sqlite`
|
|
9
|
+
* - prod OR CLI mode \u2192 `~/.{info.name}/sessions.sqlite`
|
|
10
10
|
* Set this explicitly to override either default.
|
|
11
11
|
*/
|
|
12
12
|
path: z.string().min(1).optional(),
|
|
@@ -115,7 +115,7 @@ var transportOptionsSchema = z.object({
|
|
|
115
115
|
// Session Lifecycle
|
|
116
116
|
// ============================================
|
|
117
117
|
/**
|
|
118
|
-
* @deprecated Ignored
|
|
118
|
+
* @deprecated Ignored \u2014 sessions follow `protocol` (`'stateless-api'` serves without them). A value
|
|
119
119
|
* other than `'stateful'` logs a startup warning (`warnIfSessionModeIgnored`). Removed in the next
|
|
120
120
|
* major (#702).
|
|
121
121
|
*/
|
|
@@ -128,13 +128,13 @@ var transportOptionsSchema = z.object({
|
|
|
128
128
|
/**
|
|
129
129
|
* Which MCP revision to serve a request that does not identify its own.
|
|
130
130
|
*
|
|
131
|
-
* A client that names a revision always gets that revision
|
|
131
|
+
* A client that names a revision always gets that revision \u2014 this only
|
|
132
132
|
* decides the fallback for a bare JSON-RPC call carrying no `initialize`, no
|
|
133
133
|
* `Mcp-Session-Id`, and no `MCP-Protocol-Version`.
|
|
134
134
|
*
|
|
135
|
-
* - `'2026-07-28'`
|
|
135
|
+
* - `'2026-07-28'` \u2014 serve it statelessly. No session is minted, so the
|
|
136
136
|
* deployment needs no session storage (on Cloudflare, no Durable Object).
|
|
137
|
-
* - `'legacy'`
|
|
137
|
+
* - `'legacy'` \u2014 the session/`initialize` pipeline, as before.
|
|
138
138
|
*
|
|
139
139
|
* Defaults to `'2026-07-28'` on V8-isolate runtimes (Cloudflare Workers and
|
|
140
140
|
* friends), where statelessness is the natural fit and sessions cost a
|
|
@@ -9,7 +9,7 @@ var intentSchema = z.union([
|
|
|
9
9
|
z.literal("delete-session"),
|
|
10
10
|
// Protocol 2026-07-28: stateless, sessionless, per-request version negotiation.
|
|
11
11
|
// Decided by the router from the request's headers/`_meta`, not by the bitmap
|
|
12
|
-
// rules below
|
|
12
|
+
// rules below \u2014 those describe the session-oriented transports only.
|
|
13
13
|
z.literal("mcp-20260728"),
|
|
14
14
|
z.literal("unknown")
|
|
15
15
|
]);
|
|
@@ -65,7 +65,9 @@ function tryDecodeTransportType(sessionId) {
|
|
|
65
65
|
if (!sessionId) return;
|
|
66
66
|
try {
|
|
67
67
|
const b64 = sessionId.replace(/-/g, "+").replace(/_/g, "/");
|
|
68
|
-
const
|
|
68
|
+
const json = Buffer.from(b64, "base64").toString("utf8");
|
|
69
|
+
if (json.trimStart()[0] !== "{") return;
|
|
70
|
+
const obj = JSON.parse(json);
|
|
69
71
|
return obj?.transportType;
|
|
70
72
|
} catch {
|
|
71
73
|
return;
|
|
@@ -108,7 +110,7 @@ function computeBitmap(req, cfg) {
|
|
|
108
110
|
return { key: channel & CH_MASK | flags, channel, flags, init };
|
|
109
111
|
}
|
|
110
112
|
var RULES = [
|
|
111
|
-
// A) Legacy SSE via GET /sse path (without session)
|
|
113
|
+
// A) Legacy SSE via GET /sse path (without session) \u2192 requires legacy enabled
|
|
112
114
|
{
|
|
113
115
|
care: CH_MASK | B_HAS_SESSION | B_LEGACY_EN,
|
|
114
116
|
match: CH_GET_SSE_PATH | B_LEGACY_EN,
|
|
@@ -124,7 +126,7 @@ var RULES = [
|
|
|
124
126
|
recommendation: { httpStatus: 405, message: "Legacy SSE disabled" }
|
|
125
127
|
}
|
|
126
128
|
},
|
|
127
|
-
// A2) GET / + SSE (not /sse path) with session ID
|
|
129
|
+
// A2) GET / + SSE (not /sse path) with session ID \u2192 SSE listener for streamable-http
|
|
128
130
|
// Per MCP 2025-11-25 spec, clients can open SSE stream via GET with session ID
|
|
129
131
|
{
|
|
130
132
|
care: CH_MASK | B_HAS_SESSION | B_SSE_LISTENER_EN | B_STREAMABLE_EN,
|
|
@@ -141,7 +143,7 @@ var RULES = [
|
|
|
141
143
|
recommendation: { httpStatus: 405, message: "SSE listener disabled" }
|
|
142
144
|
}
|
|
143
145
|
},
|
|
144
|
-
// A2c) GET / + SSE without session
|
|
146
|
+
// A2c) GET / + SSE without session \u2192 forward to next middleware
|
|
145
147
|
{
|
|
146
148
|
care: CH_MASK | B_HAS_SESSION,
|
|
147
149
|
match: CH_GET_SSE,
|
|
@@ -165,7 +167,7 @@ var RULES = [
|
|
|
165
167
|
recommendation: { httpStatus: 405, message: "Legacy SSE disabled" }
|
|
166
168
|
}
|
|
167
169
|
},
|
|
168
|
-
// C) Modern SSE (GET /sse with session)
|
|
170
|
+
// C) Modern SSE (GET /sse with session) \u2192 requires SSE listener enabled
|
|
169
171
|
{
|
|
170
172
|
care: CH_MASK | B_SSE_LISTENER_EN | B_HAS_SESSION,
|
|
171
173
|
match: CH_GET_SSE_PATH | B_HAS_SESSION,
|
|
@@ -180,10 +182,10 @@ var RULES = [
|
|
|
180
182
|
match: CH_GET_SSE_PATH | B_SSE_LISTENER_EN | B_HAS_SESSION,
|
|
181
183
|
outcome: { intent: "sse", reason: "GET /sse with Mcp-Session-Id." }
|
|
182
184
|
},
|
|
183
|
-
// D) Initialize (POST
|
|
185
|
+
// D) Initialize (POST \u2192 SSE)
|
|
184
186
|
// D1) Stateless initialize (no session, stateless enabled, streamable NOT enabled)
|
|
185
187
|
// When streamable is also enabled, prefer streamable-http (which creates a session).
|
|
186
|
-
// Per MCP spec, first initialize naturally has no session
|
|
188
|
+
// Per MCP spec, first initialize naturally has no session \u2014 stateless should only
|
|
187
189
|
// match when it's the sole enabled protocol.
|
|
188
190
|
{
|
|
189
191
|
care: CH_MASK | B_HAS_SESSION | B_STATELESS_EN | B_STREAMABLE_EN,
|
|
@@ -204,7 +206,7 @@ var RULES = [
|
|
|
204
206
|
match: CH_POST_INIT_SSE | B_STREAMABLE_EN,
|
|
205
207
|
outcome: { intent: "streamable-http", reason: "Initialize with SSE." }
|
|
206
208
|
},
|
|
207
|
-
// E) Initialize (POST
|
|
209
|
+
// E) Initialize (POST \u2192 JSON)
|
|
208
210
|
// E1) Stateless initialize JSON (no session, stateless enabled, streamable NOT enabled)
|
|
209
211
|
{
|
|
210
212
|
care: CH_MASK | B_HAS_SESSION | B_STATELESS_EN | B_STREAMABLE_EN,
|
|
@@ -225,7 +227,7 @@ var RULES = [
|
|
|
225
227
|
match: CH_POST_INIT_JSON | B_STREAMABLE_EN,
|
|
226
228
|
outcome: { intent: "stateful-http", reason: "Initialize with JSON." }
|
|
227
229
|
},
|
|
228
|
-
// F) POST non-init
|
|
230
|
+
// F) POST non-init \u2192 SSE
|
|
229
231
|
{
|
|
230
232
|
care: CH_MASK | B_REQ_SESSION | B_HAS_SESSION | B_STATELESS_EN,
|
|
231
233
|
match: CH_POST_SSE | B_REQ_SESSION,
|
|
@@ -255,7 +257,7 @@ var RULES = [
|
|
|
255
257
|
match: CH_POST_SSE,
|
|
256
258
|
outcome: { intent: "streamable-http", reason: "Short-lived SSE for this request." }
|
|
257
259
|
},
|
|
258
|
-
// G) POST non-init
|
|
260
|
+
// G) POST non-init \u2192 JSON
|
|
259
261
|
{
|
|
260
262
|
care: CH_MASK | B_REQ_SESSION | B_HAS_SESSION | B_STATELESS_EN,
|
|
261
263
|
match: CH_POST_JSON | B_REQ_SESSION,
|
|
@@ -307,7 +307,7 @@ var FrontMcpContext = class {
|
|
|
307
307
|
* Attach the request's MRTR exchange.
|
|
308
308
|
*
|
|
309
309
|
* Set by the 2026-07-28 dispatcher before running a request. Its presence is
|
|
310
|
-
* what switches `elicit()` from the inline server
|
|
310
|
+
* what switches `elicit()` from the inline server\u2192client round trip (removed
|
|
311
311
|
* in this revision) to the `InputRequiredResult` round trip.
|
|
312
312
|
*
|
|
313
313
|
* @internal
|