@frontmcp/sdk 1.11.0 → 1.11.1-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/app/instances/app.esm.instance.d.ts.map +1 -1
- package/app/instances/empty-app-registries.d.ts +1 -0
- package/app/instances/empty-app-registries.d.ts.map +1 -1
- package/auth/flows/oauth.callback.flow.d.ts +5 -0
- package/auth/flows/oauth.callback.flow.d.ts.map +1 -1
- package/auth/flows/oauth.connect.flow.d.ts +4 -2
- package/auth/flows/oauth.connect.flow.d.ts.map +1 -1
- package/auth/vault/auth-providers.providers.d.ts +7 -16
- package/auth/vault/auth-providers.providers.d.ts.map +1 -1
- package/auth/vault/index.d.ts +1 -2
- package/auth/vault/index.d.ts.map +1 -1
- package/auth/vault/unconfigured-auth-providers.d.ts +4 -0
- package/auth/vault/unconfigured-auth-providers.d.ts.map +1 -0
- package/browser/app/instances/app.esm.instance.mjs +2 -0
- package/browser/app/instances/empty-app-registries.mjs +2 -0
- package/browser/auth/flows/oauth.callback.flow.mjs +26 -1
- package/browser/auth/flows/oauth.connect.flow.mjs +31 -24
- package/browser/auth/vault/auth-providers.providers.mjs +96 -0
- package/browser/auth/vault/credential-cache.mjs +5 -0
- package/browser/auth/vault/unconfigured-auth-providers.mjs +21 -0
- package/browser/common/entries/scope.entry.mjs +35 -0
- package/browser/common/interfaces/execution-context.interface.mjs +5 -0
- package/browser/common/interfaces/server.interface.mjs +2 -0
- package/browser/common/metadata/front-mcp.metadata.mjs +3 -0
- package/browser/common/metadata/plugin.metadata.mjs +2 -1
- package/browser/common/schemas/http-output.schema.mjs +12 -1
- package/browser/common/tokens/front-mcp.tokens.mjs +1 -0
- package/browser/common/tokens/plugin.tokens.mjs +2 -1
- package/browser/common/types/options/skills-http/schema.mjs +13 -0
- package/browser/direct/direct-client.mjs +10 -1
- package/browser/direct/token-auth-info.mjs +33 -0
- package/browser/elicitation/helpers/elicit.helper.mjs +10 -7
- package/browser/errors/http-route.errors.mjs +9 -0
- package/browser/errors/index.mjs +3 -1
- package/browser/errors/misconfiguration.mjs +4 -1
- package/browser/errors/plugin.errors.mjs +30 -0
- package/browser/errors/tool-credentials-required.error.mjs +18 -5
- package/browser/front-mcp/front-mcp.mjs +7 -5
- package/browser/health/health.service.mjs +14 -6
- package/browser/http-route/flows/http.route.flow.mjs +47 -19
- package/browser/index.cjs +3581 -2501
- package/browser/index.mjs +20 -4
- package/browser/job/enclave/browser-enclave-core.mjs +9 -0
- package/browser/job/enclave/job-enclave.bridge.mjs +3 -20
- package/browser/notification/notification.service.mjs +5 -5
- package/browser/plugin/plugin.registry.mjs +56 -3
- package/browser/provider/provider.registry.mjs +2 -0
- package/browser/resource/flows/resources-list.flow.mjs +31 -1
- package/browser/scope/dev-events-observability.mjs +9 -5
- package/browser/scope/scope.instance.mjs +15 -6
- package/browser/server/server.validation.mjs +3 -6
- package/browser/skill/decision/decisions-api.decider.mjs +62 -0
- package/browser/skill/decision/skill-decision.ranker.mjs +96 -0
- package/browser/skill/errors/skill-bundle-not-loaded.error.mjs +21 -0
- package/browser/skill/flows/load-skill.flow.mjs +21 -12
- package/browser/skill/flows/search-skills.flow.mjs +10 -2
- package/browser/skill/index.mjs +6 -0
- package/browser/skill/providers/memory-skill.provider.mjs +41 -135
- package/browser/skill/sep-2640/resources/skill-index.resource.mjs +2 -0
- package/browser/skill/sep-2640/resources/skill-md.resource.mjs +3 -3
- package/browser/skill/sep-2640/sep-2640.builders.mjs +24 -2
- package/browser/skill/sep-2640/sep-2640.per-skill.mjs +3 -4
- package/browser/skill/sep-2640/sep-2640.resource-helpers.mjs +14 -2
- package/browser/skill/skill-catalog-source.mjs +55 -0
- package/browser/skill/skill-instructions.helper.mjs +25 -7
- package/browser/skill/skill-search-text.mjs +166 -0
- package/browser/skill/skill.registry.mjs +64 -3
- package/browser/subsystems.mjs +14 -1
- package/browser/surface/index.mjs +6 -0
- package/browser/surface/list-change-batch.mjs +51 -0
- package/browser/surface/live-surface.mjs +2 -2
- package/browser/tool/flows/call-tool.flow.mjs +18 -4
- package/browser/tool/flows/tool-credentials.gate.mjs +60 -10
- package/browser/tool/tool.registry.mjs +9 -2
- package/browser/transport/mcp-20260728/mrtr.mjs +13 -6
- package/browser/transport/mcp-20260728/subscriptions.mjs +6 -6
- package/browser/transport/mcp-handlers/skills-list-request.handler.mjs +19 -7
- package/browser/transport/mcp-handlers/skills-mcp.types.mjs +8 -4
- package/browser/transport/relay/relay-http.mjs +2 -1
- package/browser/transport/web-fetch-handler.mjs +6 -8
- package/browser/transport/web-response.renderer.mjs +6 -2
- package/browser/utils/http-location.utils.mjs +8 -0
- package/common/decorators/tool.decorator.d.ts +2 -1
- package/common/decorators/tool.decorator.d.ts.map +1 -1
- package/common/entries/scope.entry.d.ts +20 -0
- package/common/entries/scope.entry.d.ts.map +1 -1
- package/common/interfaces/execution-context.interface.d.ts +3 -1
- package/common/interfaces/execution-context.interface.d.ts.map +1 -1
- package/common/interfaces/server.interface.d.ts +2 -0
- package/common/interfaces/server.interface.d.ts.map +1 -1
- package/common/interfaces/skill.interface.d.ts +5 -0
- package/common/interfaces/skill.interface.d.ts.map +1 -1
- package/common/metadata/app.metadata.d.ts +1 -1
- package/common/metadata/front-mcp.metadata.d.ts +394 -92
- package/common/metadata/front-mcp.metadata.d.ts.map +1 -1
- package/common/metadata/plugin.metadata.d.ts +8 -0
- package/common/metadata/plugin.metadata.d.ts.map +1 -1
- package/common/schemas/http-output.schema.d.ts.map +1 -1
- package/common/tokens/front-mcp.tokens.d.ts.map +1 -1
- package/common/tokens/plugin.tokens.d.ts +1 -0
- package/common/tokens/plugin.tokens.d.ts.map +1 -1
- package/common/types/options/elicitation/schema.d.ts +1 -1
- package/common/types/options/redis/schema.d.ts +3 -3
- package/common/types/options/redis/schema.d.ts.map +1 -1
- package/common/types/options/skills-http/interfaces.d.ts +16 -0
- package/common/types/options/skills-http/interfaces.d.ts.map +1 -1
- package/common/types/options/skills-http/schema.d.ts +13 -2
- package/common/types/options/skills-http/schema.d.ts.map +1 -1
- package/common/types/options/transport/schema.d.ts +4 -4
- package/context/frontmcp-context.d.ts +1 -1
- package/context/frontmcp-context.d.ts.map +1 -1
- package/direct/client.types.d.ts +60 -21
- package/direct/client.types.d.ts.map +1 -1
- package/direct/create.types.d.ts +6 -1
- package/direct/create.types.d.ts.map +1 -1
- package/direct/index.d.ts +1 -1
- package/direct/index.d.ts.map +1 -1
- package/direct/token-auth-info.d.ts +9 -0
- package/direct/token-auth-info.d.ts.map +1 -0
- package/elicitation/helpers/elicit.helper.d.ts +5 -0
- package/elicitation/helpers/elicit.helper.d.ts.map +1 -1
- package/errors/error-handler.d.ts +1 -0
- package/errors/error-handler.d.ts.map +1 -1
- package/errors/http-route.errors.d.ts +4 -0
- package/errors/http-route.errors.d.ts.map +1 -1
- package/errors/index.d.ts +1 -1
- package/errors/index.d.ts.map +1 -1
- package/errors/mcp.error.d.ts +2 -0
- package/errors/mcp.error.d.ts.map +1 -1
- package/errors/misconfiguration.d.ts.map +1 -1
- package/errors/plugin.errors.d.ts +12 -0
- package/errors/plugin.errors.d.ts.map +1 -1
- package/errors/tool-credentials-required.error.d.ts +10 -2
- package/errors/tool-credentials-required.error.d.ts.map +1 -1
- package/esm/index.mjs +39 -31
- package/front-mcp/front-mcp.d.ts +3 -0
- package/front-mcp/front-mcp.d.ts.map +1 -1
- package/health/health.service.d.ts +10 -3
- package/health/health.service.d.ts.map +1 -1
- package/http-route/flows/http.route.flow.d.ts +6 -0
- package/http-route/flows/http.route.flow.d.ts.map +1 -1
- package/index.d.ts +10 -10
- package/index.d.ts.map +1 -1
- package/index.js +46 -38
- package/job/enclave/browser-enclave-core.d.ts +3 -0
- package/job/enclave/browser-enclave-core.d.ts.map +1 -0
- package/job/enclave/enclave-core.d.ts +3 -0
- package/job/enclave/enclave-core.d.ts.map +1 -0
- package/job/enclave/job-enclave.bridge.d.ts +1 -9
- package/job/enclave/job-enclave.bridge.d.ts.map +1 -1
- package/package.json +16 -11
- package/plugin/plugin.registry.d.ts +5 -1
- package/plugin/plugin.registry.d.ts.map +1 -1
- package/provider/provider.registry.d.ts.map +1 -1
- package/resource/flows/resources-list.flow.d.ts +3 -1
- package/resource/flows/resources-list.flow.d.ts.map +1 -1
- package/scope/dev-events-observability.d.ts +2 -0
- package/scope/dev-events-observability.d.ts.map +1 -1
- package/scope/scope.instance.d.ts.map +1 -1
- package/server/adapters/utf8-json.parser.d.ts +2 -0
- package/server/adapters/utf8-json.parser.d.ts.map +1 -1
- package/server/server.validation.d.ts.map +1 -1
- package/skill/decision/decisions-api.decider.d.ts +26 -0
- package/skill/decision/decisions-api.decider.d.ts.map +1 -0
- package/skill/decision/index.d.ts +4 -0
- package/skill/decision/index.d.ts.map +1 -0
- package/skill/decision/skill-decision.ranker.d.ts +28 -0
- package/skill/decision/skill-decision.ranker.d.ts.map +1 -0
- package/skill/decision/skill-decision.types.d.ts +63 -0
- package/skill/decision/skill-decision.types.d.ts.map +1 -0
- package/skill/errors/index.d.ts +1 -0
- package/skill/errors/index.d.ts.map +1 -1
- package/skill/errors/skill-bundle-not-loaded.error.d.ts +16 -0
- package/skill/errors/skill-bundle-not-loaded.error.d.ts.map +1 -0
- package/skill/flows/load-skill.flow.d.ts +4 -2
- package/skill/flows/load-skill.flow.d.ts.map +1 -1
- package/skill/flows/search-skills.flow.d.ts +5 -1
- package/skill/flows/search-skills.flow.d.ts.map +1 -1
- package/skill/index.d.ts +6 -0
- package/skill/index.d.ts.map +1 -1
- package/skill/providers/memory-skill.provider.d.ts +10 -12
- package/skill/providers/memory-skill.provider.d.ts.map +1 -1
- package/skill/sep-2640/resources/skill-index.resource.d.ts.map +1 -1
- package/skill/sep-2640/sep-2640.builders.d.ts +7 -2
- package/skill/sep-2640/sep-2640.builders.d.ts.map +1 -1
- package/skill/sep-2640/sep-2640.per-skill.d.ts.map +1 -1
- package/skill/sep-2640/sep-2640.resource-helpers.d.ts +7 -1
- package/skill/sep-2640/sep-2640.resource-helpers.d.ts.map +1 -1
- package/skill/skill-catalog-source.d.ts +69 -0
- package/skill/skill-catalog-source.d.ts.map +1 -0
- package/skill/skill-instructions.helper.d.ts +15 -0
- package/skill/skill-instructions.helper.d.ts.map +1 -1
- package/skill/skill-search-text.d.ts +60 -0
- package/skill/skill-search-text.d.ts.map +1 -0
- package/skill/skill-storage.interface.d.ts +5 -0
- package/skill/skill-storage.interface.d.ts.map +1 -1
- package/skill/skill.registry.d.ts +29 -0
- package/skill/skill.registry.d.ts.map +1 -1
- package/subsystems.d.ts +1 -1
- package/subsystems.d.ts.map +1 -1
- package/surface/index.d.ts +1 -0
- package/surface/index.d.ts.map +1 -1
- package/surface/list-change-batch.d.ts +28 -0
- package/surface/list-change-batch.d.ts.map +1 -0
- package/tool/flows/call-tool.flow.d.ts +5 -2
- package/tool/flows/call-tool.flow.d.ts.map +1 -1
- package/tool/flows/tool-credentials.gate.d.ts +26 -0
- package/tool/flows/tool-credentials.gate.d.ts.map +1 -1
- package/tool/tool.registry.d.ts +2 -0
- package/tool/tool.registry.d.ts.map +1 -1
- package/transport/mcp-20260728/mrtr.d.ts +6 -2
- package/transport/mcp-20260728/mrtr.d.ts.map +1 -1
- package/transport/mcp-20260728/subscriptions.d.ts.map +1 -1
- package/transport/mcp-handlers/index.d.ts +1 -1
- package/transport/mcp-handlers/skills-list-request.handler.d.ts.map +1 -1
- package/transport/mcp-handlers/skills-mcp.types.d.ts +4 -1
- package/transport/mcp-handlers/skills-mcp.types.d.ts.map +1 -1
- package/transport/relay/relay-http.d.ts.map +1 -1
- package/transport/web-response.renderer.d.ts.map +1 -1
- package/utils/http-location.utils.d.ts +8 -0
- package/utils/http-location.utils.d.ts.map +1 -0
- package/auth/vault/auth-providers.context-extension.d.ts +0 -68
- package/auth/vault/auth-providers.context-extension.d.ts.map +0 -1
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
formatResultForPlatform,
|
|
29
29
|
formatToolsForPlatform
|
|
30
30
|
} from "./llm-platform.mjs";
|
|
31
|
+
import { authInfoForToken } from "./token-auth-info.mjs";
|
|
31
32
|
var DirectClientImpl = class _DirectClientImpl {
|
|
32
33
|
// Use a flexible type to handle dynamic import type differences between ESM/CJS
|
|
33
34
|
mcpClient;
|
|
@@ -83,6 +84,9 @@ var DirectClientImpl = class _DirectClientImpl {
|
|
|
83
84
|
if (options?.session?.scopes) {
|
|
84
85
|
authInfo["scopes"] = options.session.scopes;
|
|
85
86
|
}
|
|
87
|
+
if (options?.authToken) {
|
|
88
|
+
Object.assign(authInfo, await authInfoForToken(scope, options.authToken));
|
|
89
|
+
}
|
|
86
90
|
const { clientTransport, close } = await createInMemoryServer(scope, {
|
|
87
91
|
sessionId,
|
|
88
92
|
authInfo: Object.keys(authInfo).length > 0 ? authInfo : void 0,
|
|
@@ -314,7 +318,7 @@ var DirectClientImpl = class _DirectClientImpl {
|
|
|
314
318
|
* Response is validated using `SkillsLoadResultSchema`.
|
|
315
319
|
*/
|
|
316
320
|
async loadSkills(skillIds, options) {
|
|
317
|
-
|
|
321
|
+
const result = await this.mcpClient.request(
|
|
318
322
|
{
|
|
319
323
|
method: "skills/load",
|
|
320
324
|
params: {
|
|
@@ -324,6 +328,7 @@ var DirectClientImpl = class _DirectClientImpl {
|
|
|
324
328
|
},
|
|
325
329
|
SkillsLoadResultSchema
|
|
326
330
|
);
|
|
331
|
+
return result;
|
|
327
332
|
}
|
|
328
333
|
/**
|
|
329
334
|
* List available skills with optional filtering and pagination.
|
|
@@ -531,6 +536,10 @@ var DirectClientImpl = class _DirectClientImpl {
|
|
|
531
536
|
} catch {
|
|
532
537
|
}
|
|
533
538
|
}
|
|
539
|
+
if (typeof meta.instructions === "string") {
|
|
540
|
+
const loaded = await scope.skills.loadSkill(meta.id ?? meta.name).catch(() => void 0);
|
|
541
|
+
if (loaded?.skill.bundleVersion !== void 0) entry.bundleVersion = loaded.skill.bundleVersion;
|
|
542
|
+
}
|
|
534
543
|
const resources = skill.getResources?.();
|
|
535
544
|
if (resources) {
|
|
536
545
|
entry.resources = {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// libs/sdk/src/direct/token-auth-info.ts
|
|
2
|
+
import { isAnonymousSubject } from "@frontmcp/auth";
|
|
3
|
+
import { DirectPublicAuth } from "../auth/direct-public-auth.mjs";
|
|
4
|
+
import {
|
|
5
|
+
authInfoFromAuthorization,
|
|
6
|
+
normalizeEntryPrefix,
|
|
7
|
+
normalizeScopeBase
|
|
8
|
+
} from "../common/index.mjs";
|
|
9
|
+
import { PublicMcpError, SessionVerificationFailedError, UnauthorizedError } from "../errors/index.mjs";
|
|
10
|
+
async function authInfoForToken(scope, token) {
|
|
11
|
+
if (scope.auth instanceof DirectPublicAuth) return {};
|
|
12
|
+
const mcpPath = `${normalizeEntryPrefix(scope.entryPath)}${normalizeScopeBase(scope.routeBase)}` || "/";
|
|
13
|
+
const request = {
|
|
14
|
+
method: "POST",
|
|
15
|
+
path: mcpPath,
|
|
16
|
+
url: mcpPath,
|
|
17
|
+
headers: { host: "localhost", authorization: `Bearer ${token}` },
|
|
18
|
+
query: {}
|
|
19
|
+
};
|
|
20
|
+
const verified = await scope.runFlow("session:verify", { request, sessionless: true });
|
|
21
|
+
if (!verified) throw new SessionVerificationFailedError();
|
|
22
|
+
if (verified.kind === "unauthorized") {
|
|
23
|
+
throw new UnauthorizedError("The server's auth did not accept the auth token", verified.prmMetadataHeader);
|
|
24
|
+
}
|
|
25
|
+
if (verified.kind === "forbidden") {
|
|
26
|
+
throw new PublicMcpError("The auth token lacks the scopes the server requires", "INSUFFICIENT_SCOPE", 403);
|
|
27
|
+
}
|
|
28
|
+
if (isAnonymousSubject(verified.authorization.user.sub)) return {};
|
|
29
|
+
return authInfoFromAuthorization(verified.authorization);
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
authInfoForToken
|
|
33
|
+
};
|
|
@@ -31,13 +31,16 @@ async function performElicit(deps, message, requestedSchema, options) {
|
|
|
31
31
|
}
|
|
32
32
|
if (mrtr) {
|
|
33
33
|
const zodSchema = requestedSchema instanceof z.ZodType ? requestedSchema : z.object(requestedSchema);
|
|
34
|
-
const answer2 = mrtr.resolveElicitation(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
const answer2 = mrtr.resolveElicitation(
|
|
35
|
+
{
|
|
36
|
+
message,
|
|
37
|
+
requestedSchema: toJSONSchema(zodSchema),
|
|
38
|
+
...elicitOptions?.mode ? { mode: elicitOptions.mode } : {},
|
|
39
|
+
...elicitOptions?.url ? { url: elicitOptions.url } : {},
|
|
40
|
+
...elicitOptions?.elicitationId ? { elicitationId: elicitOptions.elicitationId } : {}
|
|
41
|
+
},
|
|
42
|
+
deps.inputKey
|
|
43
|
+
);
|
|
41
44
|
if (answer2.status !== "accept") {
|
|
42
45
|
return answer2;
|
|
43
46
|
}
|
|
@@ -5,6 +5,14 @@ var InvalidHttpRouteError = class extends InternalMcpError {
|
|
|
5
5
|
super(`HTTP route ${method} ${path}: ${reason}`, "INVALID_HTTP_ROUTE");
|
|
6
6
|
}
|
|
7
7
|
};
|
|
8
|
+
var InvalidHttpRouteResponseError = class extends InternalMcpError {
|
|
9
|
+
constructor(method, path, kind, problems) {
|
|
10
|
+
super(
|
|
11
|
+
`HTTP route ${method} ${path} returned an invalid "${kind}" response: ${problems}`,
|
|
12
|
+
"INVALID_HTTP_ROUTE_RESPONSE"
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
8
16
|
var InvalidPeopleAuthOptionsError = class extends InternalMcpError {
|
|
9
17
|
constructor(problems) {
|
|
10
18
|
super(`http.auth.people: ${problems.join("; ")}`, "INVALID_PEOPLE_AUTH_OPTIONS");
|
|
@@ -41,6 +49,7 @@ var SignInLockedError = class extends PublicMcpError {
|
|
|
41
49
|
export {
|
|
42
50
|
CrossOriginRequestError,
|
|
43
51
|
InvalidHttpRouteError,
|
|
52
|
+
InvalidHttpRouteResponseError,
|
|
44
53
|
InvalidPeopleAuthOptionsError,
|
|
45
54
|
PersonNotSignedInError,
|
|
46
55
|
SignInLockedError,
|
package/browser/errors/index.mjs
CHANGED
|
@@ -160,6 +160,7 @@ import { BrowserEntryPointUnavailableError } from "./browser-entry-point.errors.
|
|
|
160
160
|
import {
|
|
161
161
|
CrossOriginRequestError,
|
|
162
162
|
InvalidHttpRouteError,
|
|
163
|
+
InvalidHttpRouteResponseError,
|
|
163
164
|
InvalidPeopleAuthOptionsError,
|
|
164
165
|
PersonNotSignedInError,
|
|
165
166
|
SignInLockedError,
|
|
@@ -259,7 +260,7 @@ import {
|
|
|
259
260
|
CallRecorderConfigurationError
|
|
260
261
|
} from "./sdk.errors.mjs";
|
|
261
262
|
export { DynamicJobRegistrationDisabledError, JobAdmissionTimeoutError, JobCancelledError, JobInterruptedError, JobNotAuthorizedError, JobRunFinishedError, JobRunNotCancellableError, JobRunNotFoundError, JobRunnerBootError, JobRunnerUnavailableError, JobStoreNotSupportedError, JobTimeoutError } from "./job.errors.mjs";
|
|
262
|
-
export { UnenforcedMetadataError } from "./plugin.errors.mjs";
|
|
263
|
+
export { DuplicatePluginEntryError, DuplicatePluginError, PluginConfiguredTwiceError, UnenforcedMetadataError } from "./plugin.errors.mjs";
|
|
263
264
|
export {
|
|
264
265
|
AgentCallDepthExceededError,
|
|
265
266
|
AgentConfigKeyNotFoundError,
|
|
@@ -334,6 +335,7 @@ export {
|
|
|
334
335
|
InvalidFileSignalError,
|
|
335
336
|
InvalidHookFlowError,
|
|
336
337
|
InvalidHttpRouteError,
|
|
338
|
+
InvalidHttpRouteResponseError,
|
|
337
339
|
InvalidInputError,
|
|
338
340
|
InvalidInstructionSourceError,
|
|
339
341
|
InvalidMethodError,
|
|
@@ -6,7 +6,10 @@ var MISCONFIGURATION_REMEDIES = {
|
|
|
6
6
|
// The startup checks: a server whose entries ask for protection nothing gives them does not start.
|
|
7
7
|
UNENFORCED_METADATA: "An entry declares a field only a plugin enforces (approval, featureFlag, ...) and no installed plugin that enforces it reaches the entry, so the server refuses to start. Install the plugin or remove the field; the server log names the entries.",
|
|
8
8
|
AUTH_CONFIGURATION_ERROR: "The auth or authorities configuration is invalid (for example, entries declare authorities and the server has no authorities option, or a rule checks nothing), so the server refuses to start. The server log names the entries.",
|
|
9
|
-
TOOL_ALIAS_CONFLICT: "A tool alias (`@Tool({ aliases })`) is also the name of a tool or the alias of another tool, so the server refuses to start. Give each alias to one tool; the server log names the conflicts."
|
|
9
|
+
TOOL_ALIAS_CONFLICT: "A tool alias (`@Tool({ aliases })`) is also the name of a tool or the alias of another tool, so the server refuses to start. Give each alias to one tool; the server log names the conflicts.",
|
|
10
|
+
DUPLICATE_PLUGIN: "A plugin that can be installed once per server is installed twice (in one plugins list, or by the server and an app, or by two apps), so the server refuses to start. Install it once; the server log names the plugin.",
|
|
11
|
+
DUPLICATE_PLUGIN_ENTRY: "One plugins list names a plugin twice, so the server refuses to start. List it once with all its options, or install the other configuration on another app; the server log names the plugin, the list and both entries.",
|
|
12
|
+
PLUGIN_CONFIGURED_TWICE: "A server option (such as `observability`) installs a plugin that the server plugins list names too, so the server refuses to start. Configure the plugin in one place; the server log names the option and the plugin."
|
|
10
13
|
};
|
|
11
14
|
function findMisconfiguration(error) {
|
|
12
15
|
let current = error;
|
|
@@ -22,6 +22,36 @@ To fix this issue:
|
|
|
22
22
|
${this.suggestion}`;
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
|
+
var DuplicatePluginError = class extends PublicMcpError {
|
|
26
|
+
constructor(pluginName, reason) {
|
|
27
|
+
super(
|
|
28
|
+
`Plugin "${pluginName}" can be installed once per server, and this server installs it twice. ${reason}`,
|
|
29
|
+
"DUPLICATE_PLUGIN",
|
|
30
|
+
500
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
var DuplicatePluginEntryError = class extends PublicMcpError {
|
|
35
|
+
constructor(pluginName, listName, firstEntry, secondEntry) {
|
|
36
|
+
super(
|
|
37
|
+
`Plugin "${pluginName}" is listed twice in ${listName} (entries ${firstEntry} and ${secondEntry}), and only one entry could be installed. List it once, with all its options in that entry, or install the other configuration on an @App of its own.`,
|
|
38
|
+
"DUPLICATE_PLUGIN_ENTRY",
|
|
39
|
+
500
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
var PluginConfiguredTwiceError = class extends PublicMcpError {
|
|
44
|
+
constructor(pluginClassName, serverOption) {
|
|
45
|
+
super(
|
|
46
|
+
`${pluginClassName} is configured twice: by @FrontMcp({ ${serverOption} }) and by an ${pluginClassName} entry in @FrontMcp({ plugins }). Configure it in one place: move the entry's options to ${serverOption} and remove the entry, or remove ${serverOption}.`,
|
|
47
|
+
"PLUGIN_CONFIGURED_TWICE",
|
|
48
|
+
500
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
25
52
|
export {
|
|
53
|
+
DuplicatePluginEntryError,
|
|
54
|
+
DuplicatePluginError,
|
|
55
|
+
PluginConfiguredTwiceError,
|
|
26
56
|
UnenforcedMetadataError
|
|
27
57
|
};
|
|
@@ -9,13 +9,14 @@ var ToolCredentialsRequiredError = class extends PublicMcpError {
|
|
|
9
9
|
providers;
|
|
10
10
|
/** Connect/authorize URL to (re)authorize the provider(s), if resolvable. */
|
|
11
11
|
authUrl;
|
|
12
|
+
/** Whether the caller has to sign in to this server before it can connect the provider(s). */
|
|
13
|
+
signInRequired;
|
|
12
14
|
constructor(params) {
|
|
13
|
-
|
|
14
|
-
const defaultMessage = `Tool "${params.toolId}" requires credentials for ${providerList} which are not connected for this session. ` + (params.authUrl ? `Connect via: ${params.authUrl}` : `Please authorize the required provider(s) and retry.`);
|
|
15
|
-
super(params.message || defaultMessage, "TOOL_CREDENTIALS_REQUIRED", 401);
|
|
15
|
+
super(params.message || defaultMessageOf(params), "TOOL_CREDENTIALS_REQUIRED", 401);
|
|
16
16
|
this.toolId = params.toolId;
|
|
17
17
|
this.providers = params.providers;
|
|
18
18
|
this.authUrl = params.authUrl;
|
|
19
|
+
this.signInRequired = params.signInRequired === true;
|
|
19
20
|
}
|
|
20
21
|
/**
|
|
21
22
|
* Convert to JSON-RPC error format per MCP specification.
|
|
@@ -23,7 +24,7 @@ var ToolCredentialsRequiredError = class extends PublicMcpError {
|
|
|
23
24
|
* @example
|
|
24
25
|
* {
|
|
25
26
|
* "code": -32001,
|
|
26
|
-
* "message": "Tool \"deploy_app\" requires credentials for github ...",
|
|
27
|
+
* "message": "Tool \"deploy_app\" requires credentials for github ... Connect github to continue: open the link in this error's data (authUrl).",
|
|
27
28
|
* "data": {
|
|
28
29
|
* "tool": "deploy_app",
|
|
29
30
|
* "providers": ["github"],
|
|
@@ -39,11 +40,23 @@ var ToolCredentialsRequiredError = class extends PublicMcpError {
|
|
|
39
40
|
data: {
|
|
40
41
|
tool: this.toolId,
|
|
41
42
|
providers: this.providers,
|
|
42
|
-
...this.authUrl ? { authUrl: this.authUrl, auth_url: this.authUrl } : {}
|
|
43
|
+
...this.authUrl ? { authUrl: this.authUrl, auth_url: this.authUrl } : {},
|
|
44
|
+
...this.signInRequired ? { signInRequired: true } : {}
|
|
43
45
|
}
|
|
44
46
|
};
|
|
45
47
|
}
|
|
46
48
|
};
|
|
49
|
+
function defaultMessageOf(params) {
|
|
50
|
+
const providerList = params.providers.join(", ");
|
|
51
|
+
if (params.signInRequired) {
|
|
52
|
+
return `Tool "${params.toolId}" requires credentials for ${providerList}, and this caller isn't signed in. Sign in to this server, then connect ${providerList}.`;
|
|
53
|
+
}
|
|
54
|
+
const notConnected = `Tool "${params.toolId}" requires credentials for ${providerList} which are not connected for this session.`;
|
|
55
|
+
if (params.authUrl) {
|
|
56
|
+
return `${notConnected} Connect ${providerList} to continue: open the link in this error's data (authUrl).`;
|
|
57
|
+
}
|
|
58
|
+
return `${notConnected} Please authorize the required provider(s) and retry.`;
|
|
59
|
+
}
|
|
47
60
|
export {
|
|
48
61
|
ToolCredentialsRequiredError
|
|
49
62
|
};
|
|
@@ -244,9 +244,7 @@ var FrontMcpInstance = class _FrontMcpInstance {
|
|
|
244
244
|
const { HealthService } = await import("../health/index.mjs");
|
|
245
245
|
const composite = new HealthService(healthConfig, this.config.info);
|
|
246
246
|
for (const scopeService of scopeServices) {
|
|
247
|
-
|
|
248
|
-
composite.registerProbe(probe);
|
|
249
|
-
}
|
|
247
|
+
composite.registerProbeSource(() => scopeService.getProbes());
|
|
250
248
|
}
|
|
251
249
|
const primaryScope = this.getPrimaryScope();
|
|
252
250
|
if (primaryScope) {
|
|
@@ -473,6 +471,9 @@ var FrontMcpInstance = class _FrontMcpInstance {
|
|
|
473
471
|
* `options.workerEnv` sets the platform bindings every call reads as `this.workerEnv` unless the call
|
|
474
472
|
* (`DirectCallOptions.workerEnv`) or client (`ConnectOptions.workerEnv`) passes its own (#706).
|
|
475
473
|
*
|
|
474
|
+
* The server never listens, so of `http` it takes only `forwardHeaders`: a call's `metadata.customHeaders` keeps
|
|
475
|
+
* the headers it names, besides `x-frontmcp-*`, as an HTTP request does (#1052).
|
|
476
|
+
*
|
|
476
477
|
* @example
|
|
477
478
|
* ```typescript
|
|
478
479
|
* import { FrontMcpInstance } from '@frontmcp/sdk';
|
|
@@ -496,8 +497,9 @@ var FrontMcpInstance = class _FrontMcpInstance {
|
|
|
496
497
|
const { workerEnv, ...config } = options;
|
|
497
498
|
const parsedConfig = frontMcpMetadataSchema.parse({
|
|
498
499
|
...config,
|
|
499
|
-
// Direct access never listens: no HTTP
|
|
500
|
-
|
|
500
|
+
// Direct access never listens: no HTTP host (a browser build has no Express), so of `http` only the
|
|
501
|
+
// headers in-process calls keep apply (#1052)
|
|
502
|
+
http: config.http?.forwardHeaders ? { forwardHeaders: config.http.forwardHeaders } : void 0,
|
|
501
503
|
serve: false
|
|
502
504
|
});
|
|
503
505
|
markDirectOnly(parsedConfig);
|
|
@@ -3,7 +3,7 @@ import { getRuntimeContext, sha256Hex } from "@frontmcp/utils";
|
|
|
3
3
|
import { createRemoteAppProbe, createTransportSessionProbe } from "./health.probes.mjs";
|
|
4
4
|
var processStartTime = Date.now();
|
|
5
5
|
var HealthService = class {
|
|
6
|
-
|
|
6
|
+
probeSources = [];
|
|
7
7
|
config;
|
|
8
8
|
serverInfo;
|
|
9
9
|
scopeView;
|
|
@@ -18,7 +18,13 @@ var HealthService = class {
|
|
|
18
18
|
* Register a health probe.
|
|
19
19
|
*/
|
|
20
20
|
registerProbe(probe) {
|
|
21
|
-
this.
|
|
21
|
+
this.probeSources.push(() => [probe]);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Register a list of probes that every check reads again, so a probe added to it or removed from it later counts.
|
|
25
|
+
*/
|
|
26
|
+
registerProbeSource(source) {
|
|
27
|
+
this.probeSources.push(source);
|
|
22
28
|
}
|
|
23
29
|
/**
|
|
24
30
|
* Auto-discover and register probes from scope infrastructure.
|
|
@@ -26,6 +32,7 @@ var HealthService = class {
|
|
|
26
32
|
* Walks the scope's stores and registries to create built-in probes:
|
|
27
33
|
* - Session store (if transport persistence is configured)
|
|
28
34
|
* - Remote MCP apps (via existing HealthCheckManager)
|
|
35
|
+
* - Probes plugins register on the scope, at any time
|
|
29
36
|
* - User-defined probes from config
|
|
30
37
|
*/
|
|
31
38
|
autoDiscoverProbes(scope) {
|
|
@@ -54,6 +61,7 @@ var HealthService = class {
|
|
|
54
61
|
}
|
|
55
62
|
});
|
|
56
63
|
}
|
|
64
|
+
this.registerProbeSource(() => scope.healthProbes ?? []);
|
|
57
65
|
const userProbes = this.config.probes ?? [];
|
|
58
66
|
for (const probe of userProbes) {
|
|
59
67
|
if (probe && typeof probe.check === "function" && typeof probe.name === "string") {
|
|
@@ -95,7 +103,7 @@ var HealthService = class {
|
|
|
95
103
|
const timeoutMs = this.config.readyz?.timeoutMs ?? 5e3;
|
|
96
104
|
const includeDetails = this.resolveIncludeDetails();
|
|
97
105
|
const results = await Promise.all(
|
|
98
|
-
this.
|
|
106
|
+
this.getProbes().map(async (probe) => {
|
|
99
107
|
const result = await this.runProbeWithTimeout(probe, timeoutMs);
|
|
100
108
|
return { name: probe.name, result };
|
|
101
109
|
})
|
|
@@ -120,13 +128,13 @@ var HealthService = class {
|
|
|
120
128
|
* Get the number of registered probes.
|
|
121
129
|
*/
|
|
122
130
|
getProbeCount() {
|
|
123
|
-
return this.
|
|
131
|
+
return this.getProbes().length;
|
|
124
132
|
}
|
|
125
133
|
/**
|
|
126
|
-
* Get
|
|
134
|
+
* Get the probes the next check runs (used for aggregation across scopes).
|
|
127
135
|
*/
|
|
128
136
|
getProbes() {
|
|
129
|
-
return this.
|
|
137
|
+
return this.probeSources.flatMap((source) => source());
|
|
130
138
|
}
|
|
131
139
|
/**
|
|
132
140
|
* Set the scope view for catalog computation (used for composite services).
|
|
@@ -18,13 +18,14 @@ import {
|
|
|
18
18
|
enforceIpFilter,
|
|
19
19
|
Flow,
|
|
20
20
|
FlowBase,
|
|
21
|
+
FlowControl,
|
|
21
22
|
FlowHooksOf,
|
|
22
23
|
httpInputSchema,
|
|
23
24
|
httpOutputSchema,
|
|
24
25
|
httpRespond,
|
|
25
26
|
isProxyTrusted
|
|
26
27
|
} from "../../common/index.mjs";
|
|
27
|
-
import { CrossOriginRequestError, PersonNotSignedInError } from "../../errors/index.mjs";
|
|
28
|
+
import { CrossOriginRequestError, InvalidHttpRouteResponseError, PersonNotSignedInError } from "../../errors/index.mjs";
|
|
28
29
|
import { FlowContextProviders } from "../../provider/flow-context-providers.mjs";
|
|
29
30
|
import { corsAllowedOrigins } from "../../server/security/resolve-allowed-hosts.mjs";
|
|
30
31
|
import { isSameOriginRequest } from "../../server/security/same-origin.mjs";
|
|
@@ -40,23 +41,22 @@ var httpRouteStateSchema = z.object({
|
|
|
40
41
|
var name = "http:route";
|
|
41
42
|
var { Stage } = FlowHooksOf(name);
|
|
42
43
|
var MUTATIONS = /* @__PURE__ */ new Set(["POST", "PUT", "PATCH", "DELETE"]);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
44
|
+
var RESPONSE_KINDS = new Set(
|
|
45
|
+
Object.keys({
|
|
46
|
+
redirect: true,
|
|
47
|
+
json: true,
|
|
48
|
+
text: true,
|
|
49
|
+
html: true,
|
|
50
|
+
binary: true,
|
|
51
|
+
image: true,
|
|
52
|
+
stream: true,
|
|
53
|
+
sse: true,
|
|
54
|
+
jsonrpc: true,
|
|
55
|
+
problem: true,
|
|
56
|
+
empty: true,
|
|
57
|
+
"web-response": true
|
|
58
|
+
})
|
|
59
|
+
);
|
|
60
60
|
var HttpRouteFlow = class extends FlowBase {
|
|
61
61
|
static canActivate(request, scope) {
|
|
62
62
|
return scope.httpRouteTable?.match(request) !== void 0;
|
|
@@ -104,7 +104,35 @@ var HttpRouteFlow = class extends FlowBase {
|
|
|
104
104
|
request: this.httpRequest,
|
|
105
105
|
person
|
|
106
106
|
});
|
|
107
|
-
this.respond(
|
|
107
|
+
this.respond(
|
|
108
|
+
route.sse ? this.openStream(route, route.sse, context) : this.toHttpOutput(route, await context.handle())
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* What `handle()` returned, as the response. A value with a response `kind` that is valid for that kind is a
|
|
113
|
+
* response, with the kind's defaults (a redirect without a `status` is a 302). One that is not valid and has a
|
|
114
|
+
* `status`, as every `httpRespond` output has, fails (#1053); other objects are data.
|
|
115
|
+
*/
|
|
116
|
+
toHttpOutput(route, result) {
|
|
117
|
+
if (result === void 0) return httpRespond.noContent();
|
|
118
|
+
if (typeof result === "string") {
|
|
119
|
+
return { kind: "text", status: 200, body: result, contentType: "text/plain; charset=utf-8" };
|
|
120
|
+
}
|
|
121
|
+
const kind = result.kind;
|
|
122
|
+
const parsed = typeof kind === "string" && RESPONSE_KINDS.has(kind) ? httpOutputSchema.safeParse(result) : void 0;
|
|
123
|
+
if (parsed?.success) return parsed.data;
|
|
124
|
+
if (parsed && "status" in result) {
|
|
125
|
+
const problems = parsed.error.issues.map((issue) => `${issue.path.join(".") || "kind"}: ${issue.message}`);
|
|
126
|
+
const error = new InvalidHttpRouteResponseError(route.method, route.path, String(kind), problems.join("; "));
|
|
127
|
+
this.scope.logger.error(error.message);
|
|
128
|
+
throw FlowControl.fail(error);
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
kind: "json",
|
|
132
|
+
status: 200,
|
|
133
|
+
body: result,
|
|
134
|
+
contentType: "application/json; charset=utf-8"
|
|
135
|
+
};
|
|
108
136
|
}
|
|
109
137
|
/** The person signed in for routes of `auth`: a session for a subject opens `'subject'` routes only. */
|
|
110
138
|
verifyPerson(auth) {
|