skybridge 0.0.0-dev.91d35d2 → 0.0.0-dev.91f1004
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/README.md +9 -7
- package/dist/cli/build-helpers.d.ts +2 -2
- package/dist/cli/build-helpers.js +11 -8
- package/dist/cli/build-helpers.js.map +1 -1
- package/dist/cli/build-helpers.test.js +17 -4
- package/dist/cli/build-helpers.test.js.map +1 -1
- package/dist/cli/build-steps.js +4 -4
- package/dist/cli/build-steps.js.map +1 -1
- package/dist/cli/build-steps.test.js +3 -3
- package/dist/cli/build-steps.test.js.map +1 -1
- package/dist/cli/detect-port.js +0 -1
- package/dist/cli/detect-port.js.map +1 -1
- package/dist/cli/resolve-skybridge-config.d.ts +5 -0
- package/dist/cli/{resolve-views-dir.js → resolve-skybridge-config.js} +4 -3
- package/dist/cli/resolve-skybridge-config.js.map +1 -0
- package/dist/cli/run-plain.js +2 -1
- package/dist/cli/run-plain.js.map +1 -1
- package/dist/cli/use-execute-steps.d.ts +1 -1
- package/dist/cli/use-nodemon.d.ts +11 -1
- package/dist/cli/use-nodemon.js +30 -8
- package/dist/cli/use-nodemon.js.map +1 -1
- package/dist/cli/use-typescript-check.js +1 -1
- package/dist/cli/use-typescript-check.js.map +1 -1
- package/dist/commands/dev.js +6 -6
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/start.js +2 -2
- package/dist/commands/start.js.map +1 -1
- package/dist/context-warnings.d.ts +5 -0
- package/dist/context-warnings.js +31 -0
- package/dist/context-warnings.js.map +1 -0
- package/dist/context-warnings.test.js +28 -0
- package/dist/context-warnings.test.js.map +1 -0
- package/dist/server/app.d.ts +194 -0
- package/dist/server/app.js +266 -0
- package/dist/server/app.js.map +1 -0
- package/dist/server/app.test.js +97 -0
- package/dist/server/app.test.js.map +1 -0
- package/dist/server/auth/discovery.d.ts +2 -1
- package/dist/server/auth/discovery.js +2 -2
- package/dist/server/auth/discovery.js.map +1 -1
- package/dist/server/auth/index.d.ts +35 -5
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/auth/providers/auth0.d.ts +25 -3
- package/dist/server/auth/providers/auth0.js +13 -8
- package/dist/server/auth/providers/auth0.js.map +1 -1
- package/dist/server/auth/providers/auth0.test.js +5 -3
- package/dist/server/auth/providers/auth0.test.js.map +1 -1
- package/dist/server/auth/providers/authplane.d.ts +49 -0
- package/dist/server/auth/providers/authplane.js +57 -0
- package/dist/server/auth/providers/authplane.js.map +1 -0
- package/dist/server/auth/providers/authplane.test.js +143 -0
- package/dist/server/auth/providers/authplane.test.js.map +1 -0
- package/dist/server/auth/providers/clerk.d.ts +40 -3
- package/dist/server/auth/providers/clerk.js +4 -1
- package/dist/server/auth/providers/clerk.js.map +1 -1
- package/dist/server/auth/providers/clerk.test.js +5 -3
- package/dist/server/auth/providers/clerk.test.js.map +1 -1
- package/dist/server/auth/providers/custom.d.ts +17 -7
- package/dist/server/auth/providers/custom.js +29 -10
- package/dist/server/auth/providers/custom.js.map +1 -1
- package/dist/server/auth/providers/custom.test.js +57 -24
- package/dist/server/auth/providers/custom.test.js.map +1 -1
- package/dist/server/auth/providers/descope.d.ts +32 -3
- package/dist/server/auth/providers/descope.js +12 -3
- package/dist/server/auth/providers/descope.js.map +1 -1
- package/dist/server/auth/providers/descope.test.js +42 -19
- package/dist/server/auth/providers/descope.test.js.map +1 -1
- package/dist/server/auth/providers/stytch.d.ts +16 -3
- package/dist/server/auth/providers/stytch.js +4 -1
- package/dist/server/auth/providers/stytch.js.map +1 -1
- package/dist/server/auth/providers/verify-spy.d.ts +12 -0
- package/dist/server/auth/providers/verify-spy.js +21 -0
- package/dist/server/auth/providers/verify-spy.js.map +1 -0
- package/dist/server/auth/providers/workos.d.ts +25 -3
- package/dist/server/auth/providers/workos.js +4 -1
- package/dist/server/auth/providers/workos.js.map +1 -1
- package/dist/server/auth/security-schemes.d.ts +23 -0
- package/dist/server/auth/security-schemes.js +64 -0
- package/dist/server/auth/security-schemes.js.map +1 -0
- package/dist/server/auth/security-schemes.test.js +99 -0
- package/dist/server/auth/security-schemes.test.js.map +1 -0
- package/dist/server/auth/setup.d.ts +3 -1
- package/dist/server/auth/setup.js +66 -26
- package/dist/server/auth/setup.js.map +1 -1
- package/dist/server/auth/setup.test.js +349 -20
- package/dist/server/auth/setup.test.js.map +1 -1
- package/dist/server/auth/verify.d.ts +37 -3
- package/dist/server/auth/verify.js +27 -3
- package/dist/server/auth/verify.js.map +1 -1
- package/dist/server/auth/verify.test.js +49 -0
- package/dist/server/auth/verify.test.js.map +1 -1
- package/dist/server/auth-extra.test-d.js +130 -0
- package/dist/server/auth-extra.test-d.js.map +1 -0
- package/dist/server/auth.d.ts +43 -6
- package/dist/server/auth.js +4 -5
- package/dist/server/auth.js.map +1 -1
- package/dist/server/build-manifest.test.js +7 -6
- package/dist/server/build-manifest.test.js.map +1 -1
- package/dist/server/content-helpers.d.ts +1 -1
- package/dist/server/content-helpers.js.map +1 -1
- package/dist/server/express.d.ts +23 -3
- package/dist/server/express.js +38 -32
- package/dist/server/express.js.map +1 -1
- package/dist/server/express.test.js +220 -103
- package/dist/server/express.test.js.map +1 -1
- package/dist/server/file-ref.d.ts +1 -1
- package/dist/server/file-ref.js +1 -1
- package/dist/server/file-ref.js.map +1 -1
- package/dist/server/host.d.ts +2 -0
- package/dist/server/host.js +11 -0
- package/dist/server/host.js.map +1 -0
- package/dist/server/host.test.d.ts +1 -0
- package/dist/server/host.test.js +13 -0
- package/dist/server/host.test.js.map +1 -0
- package/dist/server/index.d.ts +14 -8
- package/dist/server/index.js +7 -2
- package/dist/server/index.js.map +1 -1
- package/dist/server/mcp-errors.test.d.ts +1 -0
- package/dist/server/mcp-errors.test.js +41 -0
- package/dist/server/mcp-errors.test.js.map +1 -0
- package/dist/server/middleware.d.ts +35 -10
- package/dist/server/middleware.js +33 -0
- package/dist/server/middleware.js.map +1 -1
- package/dist/server/middleware.test-d.js +1 -1
- package/dist/server/middleware.test-d.js.map +1 -1
- package/dist/server/middleware.test.js +242 -134
- package/dist/server/middleware.test.js.map +1 -1
- package/dist/server/register-tool.test.d.ts +1 -0
- package/dist/server/register-tool.test.js +27 -0
- package/dist/server/register-tool.test.js.map +1 -0
- package/dist/server/server.d.ts +116 -124
- package/dist/server/server.js +155 -282
- package/dist/server/server.js.map +1 -1
- package/dist/server/skills-integration.test.js +44 -21
- package/dist/server/skills-integration.test.js.map +1 -1
- package/dist/server/skills.d.ts +14 -18
- package/dist/server/skills.js +52 -59
- package/dist/server/skills.js.map +1 -1
- package/dist/server/skills.test.js +77 -44
- package/dist/server/skills.test.js.map +1 -1
- package/dist/server/templateHelper.d.ts +0 -3
- package/dist/server/templateHelper.js.map +1 -1
- package/dist/server/templates.generated.js +4 -8
- package/dist/server/templates.generated.js.map +1 -1
- package/dist/server/tool-extra.test.d.ts +1 -0
- package/dist/server/tool-extra.test.js +88 -0
- package/dist/server/tool-extra.test.js.map +1 -0
- package/dist/server/view-resource-resolution.test.js +18 -13
- package/dist/server/view-resource-resolution.test.js.map +1 -1
- package/dist/server/viewsDevServer.js +4 -1
- package/dist/server/viewsDevServer.js.map +1 -1
- package/dist/test/utils.d.ts +9 -11
- package/dist/test/utils.js +220 -201
- package/dist/test/utils.js.map +1 -1
- package/dist/test/view.test.js +44 -40
- package/dist/test/view.test.js.map +1 -1
- package/dist/views/index.d.ts +10 -0
- package/dist/views/index.js +3 -0
- package/dist/views/index.js.map +1 -0
- package/dist/{web/plugin → views}/scan-views.js +1 -1
- package/dist/views/scan-views.js.map +1 -0
- package/dist/views/scan-views.test.d.ts +1 -0
- package/dist/views/scan-views.test.js.map +1 -0
- package/dist/views/validate-view.d.ts +1 -0
- package/dist/{web/plugin → views}/validate-view.js +2 -2
- package/dist/views/validate-view.js.map +1 -0
- package/dist/views/validate-view.test.d.ts +1 -0
- package/dist/views/validate-view.test.js.map +1 -0
- package/dist/web/bridges/adaptor.js +14 -17
- package/dist/web/bridges/adaptor.js.map +1 -1
- package/dist/web/bridges/adaptor.test.js +24 -7
- package/dist/web/bridges/adaptor.test.js.map +1 -1
- package/dist/web/bridges/apps-sdk/use-apps-sdk-context.d.ts +1 -1
- package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js +1 -1
- package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js.map +1 -1
- package/dist/web/bridges/get-adaptor.test.js +2 -2
- package/dist/web/bridges/get-adaptor.test.js.map +1 -1
- package/dist/web/bridges/mcp-app/bridge.js +6 -4
- package/dist/web/bridges/mcp-app/bridge.js.map +1 -1
- package/dist/web/bridges/mcp-app/bridge.test.js +2 -2
- package/dist/web/bridges/mcp-app/bridge.test.js.map +1 -1
- package/dist/web/bridges/mcp-app/types.d.ts +2 -0
- package/dist/web/bridges/mcp-app/types.js.map +1 -1
- package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +1 -1
- package/dist/web/bridges/mcp-app/use-mcp-app-context.js +1 -1
- package/dist/web/bridges/mcp-app/use-mcp-app-context.js.map +1 -1
- package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js +1 -1
- package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js.map +1 -1
- package/dist/web/bridges/mcp-app/view-tools.test.js +1 -1
- package/dist/web/bridges/mcp-app/view-tools.test.js.map +1 -1
- package/dist/web/bridges/types.d.ts +17 -12
- package/dist/web/bridges/types.js.map +1 -1
- package/dist/web/create-store.test.js +2 -2
- package/dist/web/create-store.test.js.map +1 -1
- package/dist/web/data-llm.test.js +5 -4
- package/dist/web/data-llm.test.js.map +1 -1
- package/dist/web/generate-helpers.d.ts +22 -18
- package/dist/web/generate-helpers.js +19 -15
- package/dist/web/generate-helpers.js.map +1 -1
- package/dist/web/generate-helpers.test-d.js +3 -3
- package/dist/web/generate-helpers.test-d.js.map +1 -1
- package/dist/web/generate-helpers.test.js +2 -2
- package/dist/web/generate-helpers.test.js.map +1 -1
- package/dist/web/hooks/index.d.ts +2 -1
- package/dist/web/hooks/index.js +2 -1
- package/dist/web/hooks/index.js.map +1 -1
- package/dist/web/hooks/test/utils.d.ts +2 -1
- package/dist/web/hooks/test/utils.js +1 -1
- package/dist/web/hooks/test/utils.js.map +1 -1
- package/dist/web/hooks/use-call-tool.test.js +2 -2
- package/dist/web/hooks/use-call-tool.test.js.map +1 -1
- package/dist/web/hooks/use-display-mode.d.ts +1 -1
- package/dist/web/hooks/use-display-mode.js +1 -1
- package/dist/web/hooks/use-display-mode.js.map +1 -1
- package/dist/web/hooks/use-display-mode.test.js +1 -1
- package/dist/web/hooks/use-display-mode.test.js.map +1 -1
- package/dist/web/hooks/use-download.d.ts +1 -3
- package/dist/web/hooks/use-download.js +1 -2
- package/dist/web/hooks/use-download.js.map +1 -1
- package/dist/web/hooks/use-download.test.js +7 -7
- package/dist/web/hooks/use-download.test.js.map +1 -1
- package/dist/web/hooks/use-files.test.js +1 -1
- package/dist/web/hooks/use-files.test.js.map +1 -1
- package/dist/web/hooks/use-host.d.ts +22 -0
- package/dist/web/hooks/use-host.js +30 -0
- package/dist/web/hooks/use-host.js.map +1 -0
- package/dist/web/hooks/use-host.test.d.ts +1 -0
- package/dist/web/hooks/use-host.test.js +59 -0
- package/dist/web/hooks/use-host.test.js.map +1 -0
- package/dist/web/hooks/use-open-external.test.js +2 -2
- package/dist/web/hooks/use-open-external.test.js.map +1 -1
- package/dist/web/hooks/use-register-view-tool.d.ts +2 -3
- package/dist/web/hooks/use-register-view-tool.js.map +1 -1
- package/dist/web/hooks/use-request-close.test.js +1 -1
- package/dist/web/hooks/use-request-close.test.js.map +1 -1
- package/dist/web/hooks/use-request-modal.test.js +1 -1
- package/dist/web/hooks/use-request-modal.test.js.map +1 -1
- package/dist/web/hooks/use-request-size.d.ts +1 -1
- package/dist/web/hooks/use-request-size.js +1 -1
- package/dist/web/hooks/use-request-size.js.map +1 -1
- package/dist/web/hooks/use-request-size.test.js +1 -1
- package/dist/web/hooks/use-request-size.test.js.map +1 -1
- package/dist/web/hooks/use-set-open-in-app-url.test.js +2 -8
- package/dist/web/hooks/use-set-open-in-app-url.test.js.map +1 -1
- package/dist/web/hooks/use-tool-info.d.ts +1 -20
- package/dist/web/hooks/use-tool-info.js +0 -1
- package/dist/web/hooks/use-tool-info.js.map +1 -1
- package/dist/web/hooks/use-tool-info.test-d.js +0 -5
- package/dist/web/hooks/use-tool-info.test-d.js.map +1 -1
- package/dist/web/hooks/use-tool-info.test.js +2 -7
- package/dist/web/hooks/use-tool-info.test.js.map +1 -1
- package/dist/web/hooks/use-user.d.ts +3 -2
- package/dist/web/hooks/use-user.js +4 -3
- package/dist/web/hooks/use-user.js.map +1 -1
- package/dist/web/hooks/use-user.test.js +5 -3
- package/dist/web/hooks/use-user.test.js.map +1 -1
- package/dist/web/hooks/use-view-state.js +19 -9
- package/dist/web/hooks/use-view-state.js.map +1 -1
- package/dist/web/hooks/use-view-state.test.js +33 -2
- package/dist/web/hooks/use-view-state.test.js.map +1 -1
- package/dist/web/hooks/use-viewport.d.ts +20 -0
- package/dist/web/hooks/use-viewport.js +21 -0
- package/dist/web/hooks/use-viewport.js.map +1 -0
- package/dist/web/hooks/use-viewport.test.d.ts +1 -0
- package/dist/web/hooks/{use-layout.test.js → use-viewport.test.js} +12 -32
- package/dist/web/hooks/use-viewport.test.js.map +1 -0
- package/dist/web/mount-view.d.ts +3 -2
- package/dist/web/mount-view.js +5 -8
- package/dist/web/mount-view.js.map +1 -1
- package/package.json +17 -15
- package/dist/cli/resolve-views-dir.d.ts +0 -1
- package/dist/cli/resolve-views-dir.js.map +0 -1
- package/dist/web/hooks/use-layout.d.ts +0 -24
- package/dist/web/hooks/use-layout.js +0 -25
- package/dist/web/hooks/use-layout.js.map +0 -1
- package/dist/web/hooks/use-layout.test.js.map +0 -1
- package/dist/web/plugin/data-llm.test.js +0 -81
- package/dist/web/plugin/data-llm.test.js.map +0 -1
- package/dist/web/plugin/plugin.d.ts +0 -33
- package/dist/web/plugin/plugin.js +0 -188
- package/dist/web/plugin/plugin.js.map +0 -1
- package/dist/web/plugin/scan-views.js.map +0 -1
- package/dist/web/plugin/scan-views.test.js.map +0 -1
- package/dist/web/plugin/transform-data-llm.d.ts +0 -12
- package/dist/web/plugin/transform-data-llm.js +0 -96
- package/dist/web/plugin/transform-data-llm.js.map +0 -1
- package/dist/web/plugin/transform-data-llm.test.js +0 -81
- package/dist/web/plugin/transform-data-llm.test.js.map +0 -1
- package/dist/web/plugin/validate-view.d.ts +0 -1
- package/dist/web/plugin/validate-view.js.map +0 -1
- package/dist/web/plugin/validate-view.test.js.map +0 -1
- /package/dist/{web/hooks/use-layout.test.d.ts → context-warnings.test.d.ts} +0 -0
- /package/dist/{web/plugin/data-llm.test.d.ts → server/app.test.d.ts} +0 -0
- /package/dist/{web/plugin/transform-data-llm.test.d.ts → server/auth/providers/authplane.test.d.ts} +0 -0
- /package/dist/{web/plugin/validate-view.test.d.ts → server/auth/security-schemes.test.d.ts} +0 -0
- /package/dist/{web/plugin/scan-views.test.d.ts → server/auth-extra.test-d.d.ts} +0 -0
- /package/dist/{web/plugin → views}/scan-views.d.ts +0 -0
- /package/dist/{web/plugin → views}/scan-views.test.js +0 -0
- /package/dist/{web/plugin → views}/validate-view.test.js +0 -0
package/dist/server/server.d.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import type { McpUiToolMeta } from "@modelcontextprotocol/ext-apps";
|
|
2
|
-
import { type ServerOptions } from "@modelcontextprotocol/
|
|
3
|
-
import
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import express, { type ErrorRequestHandler, type Express, type RequestHandler } from "express";
|
|
8
|
-
import type { OAuthConfig } from "./auth/index.js";
|
|
9
|
-
import type { McpExtra, McpExtraFor, McpMethodString, McpMiddlewareFilter, McpMiddlewareFn, McpResultFor, McpTypedMiddlewareFn, McpWildcard } from "./middleware.js";
|
|
2
|
+
import { type ContentBlock, type Implementation, McpServer as McpServerBase, type RequestMeta, type ServerOptions, type ServerResult, type StandardSchemaV1, type StandardSchemaWithJSON, type ToolAnnotations } from "@modelcontextprotocol/server";
|
|
3
|
+
import type express from "express";
|
|
4
|
+
import type { ResourceMetadataUrlResolver } from "./auth/setup.js";
|
|
5
|
+
import type { ExtraClaims } from "./auth.js";
|
|
6
|
+
import type { McpExtra, McpExtraFor, McpMethodString, McpMiddlewareEntry, McpMiddlewareFilter, McpMiddlewareFn, McpResultFor, McpTypedMiddlewareFn, McpWildcard } from "./middleware.js";
|
|
10
7
|
import { type SkillsManifest } from "./skills.js";
|
|
11
8
|
/**
|
|
12
9
|
* Type marker for a registered tool — carries its input, output, and response
|
|
@@ -20,12 +17,6 @@ export type ToolDef<TInput = unknown, TOutput = unknown, TResponseMetadata = unk
|
|
|
20
17
|
output: TOutput;
|
|
21
18
|
responseMetadata: TResponseMetadata;
|
|
22
19
|
};
|
|
23
|
-
/**
|
|
24
|
-
* @deprecated Views now always emit a single ext-apps resource; host targeting
|
|
25
|
-
* no longer applies. Retained for backwards compatibility; will be removed in a
|
|
26
|
-
* future major.
|
|
27
|
-
*/
|
|
28
|
-
export type ViewHostType = "apps-sdk" | "mcp-app";
|
|
29
20
|
/**
|
|
30
21
|
* Content Security Policy origins attached to a view's resource. Each list is
|
|
31
22
|
* passed through to the host's CSP for the view iframe; omit a field to inherit
|
|
@@ -69,11 +60,6 @@ export interface ViewConfig {
|
|
|
69
60
|
component: ViewName;
|
|
70
61
|
/** Human-readable label the host may show alongside the view. */
|
|
71
62
|
description?: string;
|
|
72
|
-
/**
|
|
73
|
-
* @deprecated No-op. Every view emits a single ext-apps resource regardless
|
|
74
|
-
* of this value. Will be removed in a future major.
|
|
75
|
-
*/
|
|
76
|
-
hosts?: ViewHostType[];
|
|
77
63
|
/** Request a visible border around the view (forwarded as `ui.prefersBorder`). */
|
|
78
64
|
prefersBorder?: boolean;
|
|
79
65
|
/** Override the iframe's served domain (advanced; forwarded as `ui.domain`). */
|
|
@@ -89,20 +75,36 @@ export type SecurityScheme = {
|
|
|
89
75
|
type: "oauth2";
|
|
90
76
|
scopes?: string[];
|
|
91
77
|
};
|
|
78
|
+
/**
|
|
79
|
+
* Declarative per-tool auth. Enforced when the server has an `oauth` provider:
|
|
80
|
+
* anonymous or under-scoped calls are rejected before the handler runs. Omit
|
|
81
|
+
* `auth` entirely for the secure default (sign-in required, no specific scope).
|
|
82
|
+
*/
|
|
83
|
+
export type ToolAuth = {
|
|
84
|
+
/**
|
|
85
|
+
* When `true`, the tool is callable signed out; the token is still used when
|
|
86
|
+
* one is present. Omit (or `false`) to require sign-in.
|
|
87
|
+
*/
|
|
88
|
+
allowsAnonymous?: boolean;
|
|
89
|
+
/** OAuth scopes the caller's token must carry to invoke the tool. */
|
|
90
|
+
scopes?: string[];
|
|
91
|
+
};
|
|
92
92
|
/**
|
|
93
93
|
* Options forwarded to the built-in `express.json()` body parser. Derived
|
|
94
94
|
* from Express's own types so the public API doesn't depend on `body-parser`.
|
|
95
95
|
*/
|
|
96
96
|
export type JsonOptions = NonNullable<Parameters<typeof express.json>[0]>;
|
|
97
|
-
/**
|
|
97
|
+
/**
|
|
98
|
+
* The Skybridge-specific options an {@link McpServer} is built with. A
|
|
99
|
+
* {@link Skybridge} app derives them from its config; pass them directly only
|
|
100
|
+
* when constructing an `McpServer` by hand.
|
|
101
|
+
*/
|
|
98
102
|
export interface SkybridgeServerOptions {
|
|
99
|
-
/**
|
|
100
|
-
|
|
101
|
-
/** Resource-server OAuth config. When set, mounts well-known metadata and bearer auth on `/mcp`. */
|
|
102
|
-
oauth?: OAuthConfig;
|
|
103
|
+
/** Whether an OAuth provider guards `/mcp`; enables per-tool scheme enforcement. */
|
|
104
|
+
oauth?: boolean;
|
|
103
105
|
/**
|
|
104
|
-
* Serve Agent Skills from `src/skills` over MCP
|
|
105
|
-
*
|
|
106
|
+
* @experimental Serve Agent Skills from `src/skills` over MCP (SEP-2640).
|
|
107
|
+
* API may change.
|
|
106
108
|
*/
|
|
107
109
|
skills?: boolean;
|
|
108
110
|
}
|
|
@@ -123,7 +125,6 @@ export interface KnownToolMeta {
|
|
|
123
125
|
"openai/fileParams"?: string[];
|
|
124
126
|
/** MCP Apps: control whether the tool is exposed to the model, the app, or both. */
|
|
125
127
|
ui?: Pick<McpUiToolMeta, "visibility">;
|
|
126
|
-
securitySchemes?: SecurityScheme[];
|
|
127
128
|
}
|
|
128
129
|
/** {@link KnownToolMeta} merged with arbitrary string-keyed metadata for custom flags. */
|
|
129
130
|
export type ToolMeta = KnownToolMeta & Record<string, unknown>;
|
|
@@ -149,10 +150,10 @@ export interface McpServerTypes<TTools extends Record<string, ToolDef>> {
|
|
|
149
150
|
type Simplify<T> = {
|
|
150
151
|
[K in keyof T]: T[K];
|
|
151
152
|
};
|
|
152
|
-
type ShapeOutput<Shape extends
|
|
153
|
-
[K in keyof Shape as undefined extends
|
|
153
|
+
type ShapeOutput<Shape extends Record<string, StandardSchemaWithJSON>> = Simplify<{
|
|
154
|
+
[K in keyof Shape as undefined extends StandardSchemaV1.InferOutput<Shape[K]> ? never : K]: StandardSchemaV1.InferOutput<Shape[K]>;
|
|
154
155
|
} & {
|
|
155
|
-
[K in keyof Shape as undefined extends
|
|
156
|
+
[K in keyof Shape as undefined extends StandardSchemaV1.InferOutput<Shape[K]> ? K : never]?: StandardSchemaV1.InferOutput<Shape[K]>;
|
|
156
157
|
}>;
|
|
157
158
|
type ExtractStructuredContent<T> = T extends {
|
|
158
159
|
structuredContent: infer SC;
|
|
@@ -164,17 +165,28 @@ type ExtractMeta<T> = [Extract<T, {
|
|
|
164
165
|
}> extends {
|
|
165
166
|
_meta: infer M;
|
|
166
167
|
} ? Simplify<M> : unknown;
|
|
167
|
-
type AddTool<TTools, TName extends string, TInput extends
|
|
168
|
+
type AddTool<TTools, TName extends string, TInput extends Record<string, StandardSchemaWithJSON>, TOutput, TResponseMetadata = unknown, TAuthExtra extends ExtraClaims = ExtraClaims> = McpServer<TTools & {
|
|
168
169
|
[K in TName]: ToolDef<ShapeOutput<TInput>, TOutput, TResponseMetadata>;
|
|
169
|
-
}>;
|
|
170
|
-
interface
|
|
170
|
+
}, TAuthExtra>;
|
|
171
|
+
interface ToolConfigBase<TInput extends Record<string, StandardSchemaWithJSON> | StandardSchemaWithJSON> {
|
|
171
172
|
name: string;
|
|
172
173
|
title?: string;
|
|
173
174
|
description?: string;
|
|
174
175
|
inputSchema?: TInput;
|
|
175
|
-
outputSchema?:
|
|
176
|
+
outputSchema?: Record<string, StandardSchemaWithJSON> | StandardSchemaWithJSON;
|
|
176
177
|
annotations?: ToolAnnotations;
|
|
177
178
|
view?: ViewConfig;
|
|
179
|
+
_meta?: ToolMeta;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* The auth face of a tool config: either the high-level `auth` shorthand or the
|
|
183
|
+
* low-level `securitySchemes` escape hatch, never both.
|
|
184
|
+
*/
|
|
185
|
+
type ToolAuthConfig = {
|
|
186
|
+
auth?: ToolAuth;
|
|
187
|
+
securitySchemes?: never;
|
|
188
|
+
} | {
|
|
189
|
+
auth?: never;
|
|
178
190
|
/**
|
|
179
191
|
* Declares which auth schemes this tool supports (e.g. `noauth`, `oauth2`).
|
|
180
192
|
* Lets clients label tools that require sign-in before calling, and pass
|
|
@@ -183,8 +195,8 @@ interface ToolConfig<TInput extends ZodRawShapeCompat | AnySchema> {
|
|
|
183
195
|
* enhanced behavior to authenticated ones.
|
|
184
196
|
*/
|
|
185
197
|
securitySchemes?: SecurityScheme[];
|
|
186
|
-
|
|
187
|
-
|
|
198
|
+
};
|
|
199
|
+
type ToolConfig<TInput extends Record<string, StandardSchemaWithJSON> | StandardSchemaWithJSON> = ToolConfigBase<TInput> & ToolAuthConfig;
|
|
188
200
|
/**
|
|
189
201
|
* Optional client-supplied hints attached to `params._meta` on every tool call
|
|
190
202
|
* by the Apps SDK host. Hints only: never use for authorization, and tolerate
|
|
@@ -214,14 +226,16 @@ export interface ClientHintsMeta {
|
|
|
214
226
|
/** Stable id for the currently mounted widget instance. */
|
|
215
227
|
"openai/widgetSessionId"?: string;
|
|
216
228
|
}
|
|
217
|
-
type ToolHandlerExtra = Omit<
|
|
218
|
-
_meta
|
|
229
|
+
type ToolHandlerExtra<TAuthExtra extends ExtraClaims = ExtraClaims> = Omit<McpExtra<TAuthExtra>, "mcpReq"> & {
|
|
230
|
+
mcpReq: Omit<McpExtra<TAuthExtra>["mcpReq"], "_meta"> & {
|
|
231
|
+
_meta?: RequestMeta & ClientHintsMeta;
|
|
232
|
+
};
|
|
219
233
|
};
|
|
220
|
-
type ToolHandler<TInput extends
|
|
234
|
+
type ToolHandler<TInput extends Record<string, StandardSchemaWithJSON>, TReturn extends {
|
|
221
235
|
content?: HandlerContent;
|
|
222
236
|
} = {
|
|
223
237
|
content?: HandlerContent;
|
|
224
|
-
}> = (args: ShapeOutput<TInput>, extra: ToolHandlerExtra) => TReturn | Promise<TReturn>;
|
|
238
|
+
}, TAuthExtra extends ExtraClaims = ExtraClaims> = (args: ShapeOutput<TInput>, extra: ToolHandlerExtra<TAuthExtra>) => TReturn | Promise<TReturn>;
|
|
225
239
|
/**
|
|
226
240
|
* Coerce a tool handler's return value into an MCP `content` array. Strings
|
|
227
241
|
* become a single `TextContent`; a single block is wrapped in an array;
|
|
@@ -242,28 +256,39 @@ declare const McpServerBaseOmitted: new (...args: ConstructorParameters<typeof M
|
|
|
242
256
|
export declare function __setBuildManifest(manifest: Record<string, {
|
|
243
257
|
file: string;
|
|
244
258
|
}>): void;
|
|
245
|
-
/** @internal Primes the build-time skills snapshot; called by `dist/__entry.js`. */
|
|
246
259
|
export declare function __setSkillsManifest(manifest: SkillsManifest): void;
|
|
247
|
-
|
|
260
|
+
/**
|
|
261
|
+
* Typed registration sugar over the MCP SDK's `McpServer`: a tool registry
|
|
262
|
+
* that carries input/output/meta shapes, view resources, per-tool security
|
|
263
|
+
* schemes, and prompt/resource registration. A {@link Skybridge} app builds
|
|
264
|
+
* one of these per request and hands it to your `handler`; chain
|
|
265
|
+
* {@link McpServer.registerTool} calls on it and return the result.
|
|
266
|
+
*
|
|
267
|
+
* The `TTools` generic accumulates each registered tool's input/output/meta
|
|
268
|
+
* shape, so `typeof app` carries enough information for view-side helpers
|
|
269
|
+
* like {@link generateHelpers} to produce fully-typed hooks.
|
|
270
|
+
*
|
|
271
|
+
* @typeParam TTools - Accumulated tool registry. Filled in by `registerTool`
|
|
272
|
+
* chaining; you almost never set this manually.
|
|
273
|
+
*
|
|
274
|
+
* @example
|
|
275
|
+
* ```ts
|
|
276
|
+
* export const app = new Skybridge({
|
|
277
|
+
* name: "my-app",
|
|
278
|
+
* version: "1.0.0",
|
|
279
|
+
* handler: (server) =>
|
|
280
|
+
* server.registerTool({
|
|
281
|
+
* name: "search",
|
|
282
|
+
* inputSchema: { query: z.string() },
|
|
283
|
+
* view: { component: "search" },
|
|
284
|
+
* }, async ({ query }) => ({ content: `Results for ${query}` })),
|
|
285
|
+
* });
|
|
286
|
+
* ```
|
|
287
|
+
*
|
|
288
|
+
* @see https://docs.skybridge.tech/api-reference/mcp-server
|
|
289
|
+
*/
|
|
290
|
+
export declare class McpServer<TTools extends Record<string, ToolDef> = Record<never, ToolDef>, TAuthExtra extends ExtraClaims = ExtraClaims> extends McpServerBaseOmitted {
|
|
248
291
|
readonly $types: McpServerTypes<TTools>;
|
|
249
|
-
/**
|
|
250
|
-
* The underlying Express app. Use this to extend the HTTP server with
|
|
251
|
-
* custom routes, middleware, or settings — e.g.
|
|
252
|
-
* `server.express.get("/health", ...)`.
|
|
253
|
-
*
|
|
254
|
-
* `express.json()` is pre-applied — tune it via the constructor's third
|
|
255
|
-
* argument, e.g. `new McpServer(info, {}, { json: { limit: "10mb" } })`.
|
|
256
|
-
* Register your handlers before `run()`;
|
|
257
|
-
* after `run()`, dev-mode middleware, the `/mcp` route, and the default
|
|
258
|
-
* error handler are appended in that order.
|
|
259
|
-
*
|
|
260
|
-
* Note: Alpic Cloud only routes traffic to `/mcp` — custom routes work
|
|
261
|
-
* locally and on self-hosted deployments.
|
|
262
|
-
*/
|
|
263
|
-
readonly express: Express;
|
|
264
|
-
private customErrorMiddleware;
|
|
265
|
-
private mcpMiddlewareEntries;
|
|
266
|
-
private mcpMiddlewareApplied;
|
|
267
292
|
private claimedViews;
|
|
268
293
|
private viewMetaBuilders;
|
|
269
294
|
/**
|
|
@@ -274,42 +299,34 @@ export declare class McpServer<TTools extends Record<string, ToolDef> = Record<n
|
|
|
274
299
|
*/
|
|
275
300
|
private viewUriByPath;
|
|
276
301
|
private viteManifest;
|
|
277
|
-
private
|
|
278
|
-
private
|
|
302
|
+
private oauthEnabled;
|
|
303
|
+
private resolveResourceMetadataUrl?;
|
|
304
|
+
private readonly toolSecuritySchemes;
|
|
305
|
+
private readonly userMiddlewareEntries;
|
|
279
306
|
constructor(serverInfo: Implementation, options?: ServerOptions, skybridgeOptions?: SkybridgeServerOptions);
|
|
280
|
-
private setupSkills;
|
|
281
307
|
/**
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
*
|
|
308
|
+
* The per-tool security schemes collected during registration, keyed by tool
|
|
309
|
+
* name. Read by the OAuth layer to decide whether anonymous requests are
|
|
310
|
+
* allowed and which schemes gate a given `tools/call`.
|
|
285
311
|
*
|
|
286
|
-
*
|
|
287
|
-
* locally and on self-hosted deployments.
|
|
312
|
+
* @internal
|
|
288
313
|
*/
|
|
289
|
-
|
|
290
|
-
use(path: string, ...handlers: RequestHandler[]): this;
|
|
314
|
+
get securitySchemesByTool(): ReadonlyMap<string, SecurityScheme[] | undefined>;
|
|
291
315
|
/**
|
|
292
|
-
*
|
|
293
|
-
*
|
|
294
|
-
* thrown by tool handlers before the default error handler responds.
|
|
316
|
+
* Inject the resolver the app uses to build the protected-resource metadata
|
|
317
|
+
* URL, so tool handlers can emit in-band auth challenges.
|
|
295
318
|
*
|
|
296
|
-
* @
|
|
297
|
-
* ```ts
|
|
298
|
-
* server.useOnError((err, _req, _res, next) => {
|
|
299
|
-
* logger.error(err);
|
|
300
|
-
* next(err);
|
|
301
|
-
* });
|
|
302
|
-
* ```
|
|
319
|
+
* @internal
|
|
303
320
|
*/
|
|
304
|
-
|
|
305
|
-
|
|
321
|
+
setResourceMetadataUrlResolver(resolve: ResourceMetadataUrlResolver): this;
|
|
322
|
+
private setupSkills;
|
|
306
323
|
/** Register MCP protocol-level middleware (catch-all). */
|
|
307
|
-
mcpMiddleware(handler: McpMiddlewareFn): this;
|
|
324
|
+
mcpMiddleware(handler: McpMiddlewareFn<TAuthExtra>): this;
|
|
308
325
|
/** Register MCP protocol-level middleware for all requests (`extra` is `McpExtra`). */
|
|
309
326
|
mcpMiddleware(filter: "request", handler: (request: {
|
|
310
327
|
method: string;
|
|
311
328
|
params: Record<string, unknown>;
|
|
312
|
-
}, extra: McpExtra
|
|
329
|
+
}, extra: McpExtra<TAuthExtra>, next: () => Promise<ServerResult>) => Promise<unknown> | unknown): this;
|
|
313
330
|
/** Register MCP protocol-level middleware for all notifications (`extra` is `undefined`). */
|
|
314
331
|
mcpMiddleware(filter: "notification", handler: (request: {
|
|
315
332
|
method: string;
|
|
@@ -319,7 +336,7 @@ export declare class McpServer<TTools extends Record<string, ToolDef> = Record<n
|
|
|
319
336
|
* Register MCP protocol-level middleware for an exact method.
|
|
320
337
|
* Narrows `params`, `extra`, and `next()` result based on the method string.
|
|
321
338
|
*/
|
|
322
|
-
mcpMiddleware<M extends McpMethodString>(filter: M, handler: McpTypedMiddlewareFn<M>): this;
|
|
339
|
+
mcpMiddleware<M extends McpMethodString>(filter: M, handler: McpTypedMiddlewareFn<M, TAuthExtra>): this;
|
|
323
340
|
/**
|
|
324
341
|
* Register MCP protocol-level middleware for a wildcard pattern (e.g. `"tools/*"`).
|
|
325
342
|
* `next()` returns the union of result types for matching methods.
|
|
@@ -327,55 +344,28 @@ export declare class McpServer<TTools extends Record<string, ToolDef> = Record<n
|
|
|
327
344
|
mcpMiddleware<W extends McpWildcard>(filter: W, handler: (request: {
|
|
328
345
|
method: string;
|
|
329
346
|
params: Record<string, unknown>;
|
|
330
|
-
}, extra: McpExtraFor<W>, next: () => Promise<McpResultFor<W>>) => Promise<unknown> | unknown): this;
|
|
347
|
+
}, extra: McpExtraFor<W, TAuthExtra>, next: () => Promise<McpResultFor<W>>) => Promise<unknown> | unknown): this;
|
|
331
348
|
/**
|
|
332
349
|
* Register MCP protocol-level middleware with a method filter.
|
|
333
350
|
* Filter can be an exact method (`"tools/call"`), wildcard (`"tools/*"`),
|
|
334
351
|
* category (`"request"` | `"notification"`), or an array of those.
|
|
335
352
|
*/
|
|
336
|
-
mcpMiddleware(filter: McpMiddlewareFilter, handler: McpMiddlewareFn): this;
|
|
337
|
-
private applyMcpMiddleware;
|
|
353
|
+
mcpMiddleware(filter: McpMiddlewareFilter, handler: McpMiddlewareFn<TAuthExtra>): this;
|
|
338
354
|
/**
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
342
|
-
*
|
|
343
|
-
* via {@link McpServer.mcpMiddleware} — further calls to that method will
|
|
344
|
-
* throw afterwards.
|
|
345
|
-
*/
|
|
346
|
-
connect(transport: Parameters<typeof McpServerBase.prototype.connect>[0]): Promise<void>;
|
|
347
|
-
/**
|
|
348
|
-
* Per-request stateless connect. The SDK's `Protocol` only allows one
|
|
349
|
-
* transport per instance, so we can't reuse this `McpServer` across
|
|
350
|
-
* concurrent requests. The SDK's idiomatic fix is a `() => McpServer`
|
|
351
|
-
* factory, but that would break Skybridge's singleton API — so instead
|
|
352
|
-
* we build a fresh underlying `Server` per request and share the main
|
|
353
|
-
* server's handler maps by reference. The cast is unavoidable: there's
|
|
354
|
-
* no public API to inject handler maps. `getHandlerMaps` validates the
|
|
355
|
-
* read side and fails fast on SDK field renames.
|
|
356
|
-
*/
|
|
357
|
-
connectStatelessTransport(transport: Parameters<typeof McpServerBase.prototype.connect>[0]): Promise<void>;
|
|
358
|
-
/**
|
|
359
|
-
* Start the HTTP server. Listens on `process.env.__PORT` (default `3000`),
|
|
360
|
-
* mounts the `/mcp` route, applies any custom Express middleware registered
|
|
361
|
-
* via {@link McpServer.use} / {@link McpServer.useOnError}, and locks in
|
|
362
|
-
* any MCP middleware registered via {@link McpServer.mcpMiddleware}.
|
|
355
|
+
* This instance's protocol-level middleware: the framework's own entries
|
|
356
|
+
* (view `_meta` on `resources/list`, version-agnostic view resolution on
|
|
357
|
+
* `resources/read`, the top-level `securitySchemes` mirror on `tools/list`)
|
|
358
|
+
* followed by the ones registered via {@link McpServer.mcpMiddleware}.
|
|
363
359
|
*
|
|
364
|
-
*
|
|
365
|
-
* the runtime can bridge incoming requests to the Node HTTP server. On
|
|
366
|
-
* Vercel (`VERCEL === "1"`), returns the Express app directly so the
|
|
367
|
-
* serverless function entry can call it as a `(req, res)` handler. On
|
|
368
|
-
* Node, returns `undefined` once listening.
|
|
360
|
+
* @internal
|
|
369
361
|
*/
|
|
370
|
-
|
|
371
|
-
fetch: (...args: unknown[]) => unknown;
|
|
372
|
-
} | Express | undefined>;
|
|
362
|
+
protocolMiddlewareEntries(): McpMiddlewareEntry[];
|
|
373
363
|
private enforceOneToolPerView;
|
|
374
364
|
private resolveViewRequestContext;
|
|
375
365
|
private registerViewResources;
|
|
376
366
|
private registerViewResource;
|
|
377
367
|
private serveLegacyAppsSdkUrl;
|
|
378
|
-
private
|
|
368
|
+
private decorateToolHandler;
|
|
379
369
|
private computeViewVersionParam;
|
|
380
370
|
private lookupViewFile;
|
|
381
371
|
private lookupDistFile;
|
|
@@ -418,11 +408,13 @@ export declare class McpServer<TTools extends Record<string, ToolDef> = Record<n
|
|
|
418
408
|
*
|
|
419
409
|
* @see https://docs.skybridge.tech/api-reference/register-tool
|
|
420
410
|
*/
|
|
421
|
-
registerTool<TName extends string, InputArgs extends
|
|
411
|
+
registerTool<TName extends string, InputArgs extends Record<string, StandardSchemaWithJSON>, TReturn extends {
|
|
422
412
|
content?: HandlerContent;
|
|
423
413
|
}>(config: ToolConfig<InputArgs> & {
|
|
424
414
|
name: TName;
|
|
425
|
-
}, cb: ToolHandler<InputArgs, TReturn>): AddTool<TTools, TName, InputArgs, ExtractStructuredContent<TReturn>, ExtractMeta<TReturn
|
|
426
|
-
registerTool<InputArgs extends
|
|
415
|
+
}, cb: ToolHandler<InputArgs, TReturn, TAuthExtra>): AddTool<TTools, TName, InputArgs, ExtractStructuredContent<TReturn>, ExtractMeta<TReturn>, TAuthExtra>;
|
|
416
|
+
registerTool<InputArgs extends Record<string, StandardSchemaWithJSON>>(config: ToolConfig<InputArgs>, cb: ToolHandler<InputArgs, {
|
|
417
|
+
content?: HandlerContent;
|
|
418
|
+
}, TAuthExtra>): this;
|
|
427
419
|
}
|
|
428
420
|
export {};
|