@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.
Files changed (223) hide show
  1. package/app/instances/app.esm.instance.d.ts.map +1 -1
  2. package/app/instances/empty-app-registries.d.ts +1 -0
  3. package/app/instances/empty-app-registries.d.ts.map +1 -1
  4. package/auth/flows/oauth.callback.flow.d.ts +5 -0
  5. package/auth/flows/oauth.callback.flow.d.ts.map +1 -1
  6. package/auth/flows/oauth.connect.flow.d.ts +4 -2
  7. package/auth/flows/oauth.connect.flow.d.ts.map +1 -1
  8. package/auth/vault/auth-providers.providers.d.ts +7 -16
  9. package/auth/vault/auth-providers.providers.d.ts.map +1 -1
  10. package/auth/vault/index.d.ts +1 -2
  11. package/auth/vault/index.d.ts.map +1 -1
  12. package/auth/vault/unconfigured-auth-providers.d.ts +4 -0
  13. package/auth/vault/unconfigured-auth-providers.d.ts.map +1 -0
  14. package/browser/app/instances/app.esm.instance.mjs +2 -0
  15. package/browser/app/instances/empty-app-registries.mjs +2 -0
  16. package/browser/auth/flows/oauth.callback.flow.mjs +26 -1
  17. package/browser/auth/flows/oauth.connect.flow.mjs +31 -24
  18. package/browser/auth/vault/auth-providers.providers.mjs +96 -0
  19. package/browser/auth/vault/credential-cache.mjs +5 -0
  20. package/browser/auth/vault/unconfigured-auth-providers.mjs +21 -0
  21. package/browser/common/entries/scope.entry.mjs +35 -0
  22. package/browser/common/interfaces/execution-context.interface.mjs +5 -0
  23. package/browser/common/interfaces/server.interface.mjs +2 -0
  24. package/browser/common/metadata/front-mcp.metadata.mjs +3 -0
  25. package/browser/common/metadata/plugin.metadata.mjs +2 -1
  26. package/browser/common/schemas/http-output.schema.mjs +12 -1
  27. package/browser/common/tokens/front-mcp.tokens.mjs +1 -0
  28. package/browser/common/tokens/plugin.tokens.mjs +2 -1
  29. package/browser/common/types/options/skills-http/schema.mjs +13 -0
  30. package/browser/direct/direct-client.mjs +10 -1
  31. package/browser/direct/token-auth-info.mjs +33 -0
  32. package/browser/elicitation/helpers/elicit.helper.mjs +10 -7
  33. package/browser/errors/http-route.errors.mjs +9 -0
  34. package/browser/errors/index.mjs +3 -1
  35. package/browser/errors/misconfiguration.mjs +4 -1
  36. package/browser/errors/plugin.errors.mjs +30 -0
  37. package/browser/errors/tool-credentials-required.error.mjs +18 -5
  38. package/browser/front-mcp/front-mcp.mjs +7 -5
  39. package/browser/health/health.service.mjs +14 -6
  40. package/browser/http-route/flows/http.route.flow.mjs +47 -19
  41. package/browser/index.cjs +3581 -2501
  42. package/browser/index.mjs +20 -4
  43. package/browser/job/enclave/browser-enclave-core.mjs +9 -0
  44. package/browser/job/enclave/job-enclave.bridge.mjs +3 -20
  45. package/browser/notification/notification.service.mjs +5 -5
  46. package/browser/plugin/plugin.registry.mjs +56 -3
  47. package/browser/provider/provider.registry.mjs +2 -0
  48. package/browser/resource/flows/resources-list.flow.mjs +31 -1
  49. package/browser/scope/dev-events-observability.mjs +9 -5
  50. package/browser/scope/scope.instance.mjs +15 -6
  51. package/browser/server/server.validation.mjs +3 -6
  52. package/browser/skill/decision/decisions-api.decider.mjs +62 -0
  53. package/browser/skill/decision/skill-decision.ranker.mjs +96 -0
  54. package/browser/skill/errors/skill-bundle-not-loaded.error.mjs +21 -0
  55. package/browser/skill/flows/load-skill.flow.mjs +21 -12
  56. package/browser/skill/flows/search-skills.flow.mjs +10 -2
  57. package/browser/skill/index.mjs +6 -0
  58. package/browser/skill/providers/memory-skill.provider.mjs +41 -135
  59. package/browser/skill/sep-2640/resources/skill-index.resource.mjs +2 -0
  60. package/browser/skill/sep-2640/resources/skill-md.resource.mjs +3 -3
  61. package/browser/skill/sep-2640/sep-2640.builders.mjs +24 -2
  62. package/browser/skill/sep-2640/sep-2640.per-skill.mjs +3 -4
  63. package/browser/skill/sep-2640/sep-2640.resource-helpers.mjs +14 -2
  64. package/browser/skill/skill-catalog-source.mjs +55 -0
  65. package/browser/skill/skill-instructions.helper.mjs +25 -7
  66. package/browser/skill/skill-search-text.mjs +166 -0
  67. package/browser/skill/skill.registry.mjs +64 -3
  68. package/browser/subsystems.mjs +14 -1
  69. package/browser/surface/index.mjs +6 -0
  70. package/browser/surface/list-change-batch.mjs +51 -0
  71. package/browser/surface/live-surface.mjs +2 -2
  72. package/browser/tool/flows/call-tool.flow.mjs +18 -4
  73. package/browser/tool/flows/tool-credentials.gate.mjs +60 -10
  74. package/browser/tool/tool.registry.mjs +9 -2
  75. package/browser/transport/mcp-20260728/mrtr.mjs +13 -6
  76. package/browser/transport/mcp-20260728/subscriptions.mjs +6 -6
  77. package/browser/transport/mcp-handlers/skills-list-request.handler.mjs +19 -7
  78. package/browser/transport/mcp-handlers/skills-mcp.types.mjs +8 -4
  79. package/browser/transport/relay/relay-http.mjs +2 -1
  80. package/browser/transport/web-fetch-handler.mjs +6 -8
  81. package/browser/transport/web-response.renderer.mjs +6 -2
  82. package/browser/utils/http-location.utils.mjs +8 -0
  83. package/common/decorators/tool.decorator.d.ts +2 -1
  84. package/common/decorators/tool.decorator.d.ts.map +1 -1
  85. package/common/entries/scope.entry.d.ts +20 -0
  86. package/common/entries/scope.entry.d.ts.map +1 -1
  87. package/common/interfaces/execution-context.interface.d.ts +3 -1
  88. package/common/interfaces/execution-context.interface.d.ts.map +1 -1
  89. package/common/interfaces/server.interface.d.ts +2 -0
  90. package/common/interfaces/server.interface.d.ts.map +1 -1
  91. package/common/interfaces/skill.interface.d.ts +5 -0
  92. package/common/interfaces/skill.interface.d.ts.map +1 -1
  93. package/common/metadata/app.metadata.d.ts +1 -1
  94. package/common/metadata/front-mcp.metadata.d.ts +394 -92
  95. package/common/metadata/front-mcp.metadata.d.ts.map +1 -1
  96. package/common/metadata/plugin.metadata.d.ts +8 -0
  97. package/common/metadata/plugin.metadata.d.ts.map +1 -1
  98. package/common/schemas/http-output.schema.d.ts.map +1 -1
  99. package/common/tokens/front-mcp.tokens.d.ts.map +1 -1
  100. package/common/tokens/plugin.tokens.d.ts +1 -0
  101. package/common/tokens/plugin.tokens.d.ts.map +1 -1
  102. package/common/types/options/elicitation/schema.d.ts +1 -1
  103. package/common/types/options/redis/schema.d.ts +3 -3
  104. package/common/types/options/redis/schema.d.ts.map +1 -1
  105. package/common/types/options/skills-http/interfaces.d.ts +16 -0
  106. package/common/types/options/skills-http/interfaces.d.ts.map +1 -1
  107. package/common/types/options/skills-http/schema.d.ts +13 -2
  108. package/common/types/options/skills-http/schema.d.ts.map +1 -1
  109. package/common/types/options/transport/schema.d.ts +4 -4
  110. package/context/frontmcp-context.d.ts +1 -1
  111. package/context/frontmcp-context.d.ts.map +1 -1
  112. package/direct/client.types.d.ts +60 -21
  113. package/direct/client.types.d.ts.map +1 -1
  114. package/direct/create.types.d.ts +6 -1
  115. package/direct/create.types.d.ts.map +1 -1
  116. package/direct/index.d.ts +1 -1
  117. package/direct/index.d.ts.map +1 -1
  118. package/direct/token-auth-info.d.ts +9 -0
  119. package/direct/token-auth-info.d.ts.map +1 -0
  120. package/elicitation/helpers/elicit.helper.d.ts +5 -0
  121. package/elicitation/helpers/elicit.helper.d.ts.map +1 -1
  122. package/errors/error-handler.d.ts +1 -0
  123. package/errors/error-handler.d.ts.map +1 -1
  124. package/errors/http-route.errors.d.ts +4 -0
  125. package/errors/http-route.errors.d.ts.map +1 -1
  126. package/errors/index.d.ts +1 -1
  127. package/errors/index.d.ts.map +1 -1
  128. package/errors/mcp.error.d.ts +2 -0
  129. package/errors/mcp.error.d.ts.map +1 -1
  130. package/errors/misconfiguration.d.ts.map +1 -1
  131. package/errors/plugin.errors.d.ts +12 -0
  132. package/errors/plugin.errors.d.ts.map +1 -1
  133. package/errors/tool-credentials-required.error.d.ts +10 -2
  134. package/errors/tool-credentials-required.error.d.ts.map +1 -1
  135. package/esm/index.mjs +39 -31
  136. package/front-mcp/front-mcp.d.ts +3 -0
  137. package/front-mcp/front-mcp.d.ts.map +1 -1
  138. package/health/health.service.d.ts +10 -3
  139. package/health/health.service.d.ts.map +1 -1
  140. package/http-route/flows/http.route.flow.d.ts +6 -0
  141. package/http-route/flows/http.route.flow.d.ts.map +1 -1
  142. package/index.d.ts +10 -10
  143. package/index.d.ts.map +1 -1
  144. package/index.js +46 -38
  145. package/job/enclave/browser-enclave-core.d.ts +3 -0
  146. package/job/enclave/browser-enclave-core.d.ts.map +1 -0
  147. package/job/enclave/enclave-core.d.ts +3 -0
  148. package/job/enclave/enclave-core.d.ts.map +1 -0
  149. package/job/enclave/job-enclave.bridge.d.ts +1 -9
  150. package/job/enclave/job-enclave.bridge.d.ts.map +1 -1
  151. package/package.json +16 -11
  152. package/plugin/plugin.registry.d.ts +5 -1
  153. package/plugin/plugin.registry.d.ts.map +1 -1
  154. package/provider/provider.registry.d.ts.map +1 -1
  155. package/resource/flows/resources-list.flow.d.ts +3 -1
  156. package/resource/flows/resources-list.flow.d.ts.map +1 -1
  157. package/scope/dev-events-observability.d.ts +2 -0
  158. package/scope/dev-events-observability.d.ts.map +1 -1
  159. package/scope/scope.instance.d.ts.map +1 -1
  160. package/server/adapters/utf8-json.parser.d.ts +2 -0
  161. package/server/adapters/utf8-json.parser.d.ts.map +1 -1
  162. package/server/server.validation.d.ts.map +1 -1
  163. package/skill/decision/decisions-api.decider.d.ts +26 -0
  164. package/skill/decision/decisions-api.decider.d.ts.map +1 -0
  165. package/skill/decision/index.d.ts +4 -0
  166. package/skill/decision/index.d.ts.map +1 -0
  167. package/skill/decision/skill-decision.ranker.d.ts +28 -0
  168. package/skill/decision/skill-decision.ranker.d.ts.map +1 -0
  169. package/skill/decision/skill-decision.types.d.ts +63 -0
  170. package/skill/decision/skill-decision.types.d.ts.map +1 -0
  171. package/skill/errors/index.d.ts +1 -0
  172. package/skill/errors/index.d.ts.map +1 -1
  173. package/skill/errors/skill-bundle-not-loaded.error.d.ts +16 -0
  174. package/skill/errors/skill-bundle-not-loaded.error.d.ts.map +1 -0
  175. package/skill/flows/load-skill.flow.d.ts +4 -2
  176. package/skill/flows/load-skill.flow.d.ts.map +1 -1
  177. package/skill/flows/search-skills.flow.d.ts +5 -1
  178. package/skill/flows/search-skills.flow.d.ts.map +1 -1
  179. package/skill/index.d.ts +6 -0
  180. package/skill/index.d.ts.map +1 -1
  181. package/skill/providers/memory-skill.provider.d.ts +10 -12
  182. package/skill/providers/memory-skill.provider.d.ts.map +1 -1
  183. package/skill/sep-2640/resources/skill-index.resource.d.ts.map +1 -1
  184. package/skill/sep-2640/sep-2640.builders.d.ts +7 -2
  185. package/skill/sep-2640/sep-2640.builders.d.ts.map +1 -1
  186. package/skill/sep-2640/sep-2640.per-skill.d.ts.map +1 -1
  187. package/skill/sep-2640/sep-2640.resource-helpers.d.ts +7 -1
  188. package/skill/sep-2640/sep-2640.resource-helpers.d.ts.map +1 -1
  189. package/skill/skill-catalog-source.d.ts +69 -0
  190. package/skill/skill-catalog-source.d.ts.map +1 -0
  191. package/skill/skill-instructions.helper.d.ts +15 -0
  192. package/skill/skill-instructions.helper.d.ts.map +1 -1
  193. package/skill/skill-search-text.d.ts +60 -0
  194. package/skill/skill-search-text.d.ts.map +1 -0
  195. package/skill/skill-storage.interface.d.ts +5 -0
  196. package/skill/skill-storage.interface.d.ts.map +1 -1
  197. package/skill/skill.registry.d.ts +29 -0
  198. package/skill/skill.registry.d.ts.map +1 -1
  199. package/subsystems.d.ts +1 -1
  200. package/subsystems.d.ts.map +1 -1
  201. package/surface/index.d.ts +1 -0
  202. package/surface/index.d.ts.map +1 -1
  203. package/surface/list-change-batch.d.ts +28 -0
  204. package/surface/list-change-batch.d.ts.map +1 -0
  205. package/tool/flows/call-tool.flow.d.ts +5 -2
  206. package/tool/flows/call-tool.flow.d.ts.map +1 -1
  207. package/tool/flows/tool-credentials.gate.d.ts +26 -0
  208. package/tool/flows/tool-credentials.gate.d.ts.map +1 -1
  209. package/tool/tool.registry.d.ts +2 -0
  210. package/tool/tool.registry.d.ts.map +1 -1
  211. package/transport/mcp-20260728/mrtr.d.ts +6 -2
  212. package/transport/mcp-20260728/mrtr.d.ts.map +1 -1
  213. package/transport/mcp-20260728/subscriptions.d.ts.map +1 -1
  214. package/transport/mcp-handlers/index.d.ts +1 -1
  215. package/transport/mcp-handlers/skills-list-request.handler.d.ts.map +1 -1
  216. package/transport/mcp-handlers/skills-mcp.types.d.ts +4 -1
  217. package/transport/mcp-handlers/skills-mcp.types.d.ts.map +1 -1
  218. package/transport/relay/relay-http.d.ts.map +1 -1
  219. package/transport/web-response.renderer.d.ts.map +1 -1
  220. package/utils/http-location.utils.d.ts +8 -0
  221. package/utils/http-location.utils.d.ts.map +1 -0
  222. package/auth/vault/auth-providers.context-extension.d.ts +0 -68
  223. 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
- return this.mcpClient.request(
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
- message,
36
- requestedSchema: toJSONSchema(zodSchema),
37
- ...elicitOptions?.mode ? { mode: elicitOptions.mode } : {},
38
- ...elicitOptions?.url ? { url: elicitOptions.url } : {},
39
- ...elicitOptions?.elicitationId ? { elicitationId: elicitOptions.elicitationId } : {}
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,
@@ -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
- const providerList = params.providers.join(", ");
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
- for (const probe of scopeService.getProbes()) {
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 config and no HTTP host (a browser build has no Express)
500
- http: void 0,
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
- probes = [];
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.probes.push(probe);
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.probes.map(async (probe) => {
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.probes.length;
131
+ return this.getProbes().length;
124
132
  }
125
133
  /**
126
- * Get all registered probes (used for aggregation across scopes).
134
+ * Get the probes the next check runs (used for aggregation across scopes).
127
135
  */
128
136
  getProbes() {
129
- return this.probes;
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
- function isResponse(result) {
44
- const kind = result.kind;
45
- return kind !== "next" && kind !== "consumed" && httpOutputSchema.safeParse(result).success;
46
- }
47
- function toHttpOutput(result) {
48
- if (result === void 0) return httpRespond.noContent();
49
- if (typeof result === "string") {
50
- return { kind: "text", status: 200, body: result, contentType: "text/plain; charset=utf-8" };
51
- }
52
- if (isResponse(result)) return result;
53
- return {
54
- kind: "json",
55
- status: 200,
56
- body: result,
57
- contentType: "application/json; charset=utf-8"
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(route.sse ? this.openStream(route, route.sse, context) : toHttpOutput(await context.handle()));
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) {