skybridge 0.0.0-dev.ee66a5b → 0.0.0-dev.eea47e9
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 +124 -124
- package/dist/cli/build-helpers.d.ts +10 -0
- package/dist/cli/build-helpers.js +93 -0
- package/dist/cli/build-helpers.js.map +1 -0
- package/dist/cli/build-helpers.test.d.ts +1 -0
- package/dist/cli/build-helpers.test.js +89 -0
- package/dist/cli/build-helpers.test.js.map +1 -0
- package/dist/cli/build-steps.d.ts +2 -0
- package/dist/cli/build-steps.js +68 -0
- package/dist/cli/build-steps.js.map +1 -0
- package/dist/cli/build-steps.test.d.ts +1 -0
- package/dist/cli/build-steps.test.js +52 -0
- package/dist/cli/build-steps.test.js.map +1 -0
- package/dist/cli/detect-port.d.ts +2 -2
- package/dist/cli/detect-port.js +9 -20
- package/dist/cli/detect-port.js.map +1 -1
- package/dist/cli/header.d.ts +1 -1
- package/dist/cli/resolve-views-dir.d.ts +1 -0
- package/dist/cli/resolve-views-dir.js +17 -0
- package/dist/cli/resolve-views-dir.js.map +1 -0
- package/dist/cli/run-plain.d.ts +18 -0
- package/dist/cli/run-plain.js +89 -0
- package/dist/cli/run-plain.js.map +1 -0
- package/dist/cli/use-execute-steps.d.ts +1 -1
- package/dist/cli/use-nodemon.d.ts +14 -0
- package/dist/cli/use-nodemon.js +71 -60
- package/dist/cli/use-nodemon.js.map +1 -1
- package/dist/cli/use-typescript-check.d.ts +8 -2
- package/dist/cli/use-typescript-check.js +71 -68
- package/dist/cli/use-typescript-check.js.map +1 -1
- package/dist/commands/build.d.ts +0 -3
- package/dist/commands/build.js +2 -73
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/create.d.ts +9 -0
- package/dist/commands/create.js +30 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/dev.d.ts +1 -0
- package/dist/commands/dev.js +48 -0
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/start.js +7 -1
- package/dist/commands/start.js.map +1 -1
- package/dist/server/asset-base-url-transform-plugin.d.ts +1 -0
- package/dist/server/asset-base-url-transform-plugin.js +16 -1
- package/dist/server/asset-base-url-transform-plugin.js.map +1 -1
- package/dist/server/asset-base-url-transform-plugin.test.js +51 -1
- package/dist/server/asset-base-url-transform-plugin.test.js.map +1 -1
- package/dist/server/auth/discovery.d.ts +32 -0
- package/dist/server/auth/discovery.js +56 -0
- package/dist/server/auth/discovery.js.map +1 -0
- package/dist/server/auth/discovery.test.d.ts +1 -0
- package/dist/server/auth/discovery.test.js +93 -0
- package/dist/server/auth/discovery.test.js.map +1 -0
- package/dist/server/auth/index.d.ts +18 -0
- package/dist/server/auth/index.js +2 -0
- package/dist/server/auth/index.js.map +1 -0
- package/dist/server/auth/providers/auth0.d.ts +18 -0
- package/dist/server/auth/providers/auth0.js +31 -0
- package/dist/server/auth/providers/auth0.js.map +1 -0
- package/dist/server/auth/providers/auth0.test.d.ts +1 -0
- package/dist/server/auth/providers/auth0.test.js +48 -0
- package/dist/server/auth/providers/auth0.test.js.map +1 -0
- package/dist/server/auth/providers/clerk.d.ts +14 -0
- package/dist/server/auth/providers/clerk.js +16 -0
- package/dist/server/auth/providers/clerk.js.map +1 -0
- package/dist/server/auth/providers/clerk.test.d.ts +1 -0
- package/dist/server/auth/providers/clerk.test.js +28 -0
- package/dist/server/auth/providers/clerk.test.js.map +1 -0
- package/dist/server/auth/providers/custom.d.ts +30 -0
- package/dist/server/auth/providers/custom.js +40 -0
- package/dist/server/auth/providers/custom.js.map +1 -0
- package/dist/server/auth/providers/custom.test.d.ts +1 -0
- package/dist/server/auth/providers/custom.test.js +128 -0
- package/dist/server/auth/providers/custom.test.js.map +1 -0
- package/dist/server/auth/providers/descope.d.ts +15 -0
- package/dist/server/auth/providers/descope.js +35 -0
- package/dist/server/auth/providers/descope.js.map +1 -0
- package/dist/server/auth/providers/descope.test.d.ts +1 -0
- package/dist/server/auth/providers/descope.test.js +39 -0
- package/dist/server/auth/providers/descope.test.js.map +1 -0
- package/dist/server/auth/providers/shared.d.ts +2 -0
- package/dist/server/auth/providers/shared.js +6 -0
- package/dist/server/auth/providers/shared.js.map +1 -0
- package/dist/server/auth/providers/shared.test.d.ts +1 -0
- package/dist/server/auth/providers/shared.test.js +10 -0
- package/dist/server/auth/providers/shared.test.js.map +1 -0
- package/dist/server/auth/providers/stytch.d.ts +12 -0
- package/dist/server/auth/providers/stytch.js +13 -0
- package/dist/server/auth/providers/stytch.js.map +1 -0
- package/dist/server/auth/providers/workos.d.ts +11 -0
- package/dist/server/auth/providers/workos.js +12 -0
- package/dist/server/auth/providers/workos.js.map +1 -0
- package/dist/server/auth/setup.d.ts +4 -0
- package/dist/server/auth/setup.js +51 -0
- package/dist/server/auth/setup.js.map +1 -0
- package/dist/server/auth/setup.test.d.ts +1 -0
- package/dist/server/auth/setup.test.js +185 -0
- package/dist/server/auth/setup.test.js.map +1 -0
- package/dist/server/auth/verify.d.ts +12 -0
- package/dist/server/auth/verify.js +38 -0
- package/dist/server/auth/verify.js.map +1 -0
- package/dist/server/auth/verify.test.d.ts +1 -0
- package/dist/server/auth/verify.test.js +100 -0
- package/dist/server/auth/verify.test.js.map +1 -0
- package/dist/server/auth.d.ts +20 -0
- package/dist/server/auth.js +28 -0
- package/dist/server/auth.js.map +1 -0
- package/dist/server/build-manifest.test.d.ts +1 -0
- package/dist/server/build-manifest.test.js +27 -0
- package/dist/server/build-manifest.test.js.map +1 -0
- package/dist/server/content-helpers.d.ts +40 -0
- package/dist/server/content-helpers.js +33 -0
- package/dist/server/content-helpers.js.map +1 -1
- package/dist/server/express.test.js +61 -0
- package/dist/server/express.test.js.map +1 -1
- package/dist/server/file-ref.d.ts +20 -0
- package/dist/server/file-ref.js +19 -0
- package/dist/server/file-ref.js.map +1 -1
- package/dist/server/index.d.ts +10 -2
- package/dist/server/index.js +8 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/middleware.d.ts +16 -3
- package/dist/server/middleware.js.map +1 -1
- package/dist/server/requestOrigin.d.ts +7 -0
- package/dist/server/requestOrigin.js +25 -0
- package/dist/server/requestOrigin.js.map +1 -0
- package/dist/server/server.d.ts +227 -7
- package/dist/server/server.js +325 -163
- package/dist/server/server.js.map +1 -1
- package/dist/server/view-name.test-d.d.ts +1 -0
- package/dist/server/view-name.test-d.js +8 -0
- package/dist/server/view-name.test-d.js.map +1 -0
- package/dist/server/view-resource-resolution.test.d.ts +6 -0
- package/dist/server/view-resource-resolution.test.js +171 -0
- package/dist/server/view-resource-resolution.test.js.map +1 -0
- package/dist/test/view.test.js +109 -96
- package/dist/test/view.test.js.map +1 -1
- package/dist/web/bridges/adaptor.d.ts +51 -0
- package/dist/web/bridges/adaptor.js +330 -0
- package/dist/web/bridges/adaptor.js.map +1 -0
- package/dist/web/bridges/adaptor.test.d.ts +1 -0
- package/dist/web/bridges/adaptor.test.js +208 -0
- package/dist/web/bridges/adaptor.test.js.map +1 -0
- package/dist/web/bridges/apps-sdk/bridge.d.ts +6 -1
- package/dist/web/bridges/apps-sdk/bridge.js +15 -3
- package/dist/web/bridges/apps-sdk/bridge.js.map +1 -1
- package/dist/web/bridges/apps-sdk/index.d.ts +0 -1
- package/dist/web/bridges/apps-sdk/index.js +0 -1
- package/dist/web/bridges/apps-sdk/index.js.map +1 -1
- package/dist/web/bridges/apps-sdk/use-apps-sdk-context.d.ts +11 -0
- package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js +11 -0
- package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js.map +1 -1
- package/dist/web/bridges/get-adaptor.d.ts +7 -0
- package/dist/web/bridges/get-adaptor.js +9 -7
- package/dist/web/bridges/get-adaptor.js.map +1 -1
- package/dist/web/bridges/get-adaptor.test.d.ts +1 -0
- package/dist/web/bridges/get-adaptor.test.js +32 -0
- package/dist/web/bridges/get-adaptor.test.js.map +1 -0
- package/dist/web/bridges/mcp-app/bridge.d.ts +15 -2
- package/dist/web/bridges/mcp-app/bridge.js +68 -4
- package/dist/web/bridges/mcp-app/bridge.js.map +1 -1
- package/dist/web/bridges/mcp-app/bridge.test.d.ts +1 -0
- package/dist/web/bridges/mcp-app/bridge.test.js +17 -0
- package/dist/web/bridges/mcp-app/bridge.test.js.map +1 -0
- package/dist/web/bridges/mcp-app/index.d.ts +0 -1
- package/dist/web/bridges/mcp-app/index.js +0 -1
- package/dist/web/bridges/mcp-app/index.js.map +1 -1
- package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +12 -0
- package/dist/web/bridges/mcp-app/use-mcp-app-context.js +12 -0
- package/dist/web/bridges/mcp-app/use-mcp-app-context.js.map +1 -1
- package/dist/web/bridges/mcp-app/view-tools.test.d.ts +1 -0
- package/dist/web/bridges/mcp-app/view-tools.test.js +143 -0
- package/dist/web/bridges/mcp-app/view-tools.test.js.map +1 -0
- package/dist/web/bridges/types.d.ts +98 -1
- package/dist/web/bridges/types.js +14 -1
- package/dist/web/bridges/types.js.map +1 -1
- package/dist/web/bridges/types.test.d.ts +1 -0
- package/dist/web/bridges/types.test.js +19 -0
- package/dist/web/bridges/types.test.js.map +1 -0
- package/dist/web/bridges/use-host-context.d.ts +5 -0
- package/dist/web/bridges/use-host-context.js +5 -0
- package/dist/web/bridges/use-host-context.js.map +1 -1
- package/dist/web/components/modal-provider.d.ts +1 -1
- package/dist/web/components/modal-provider.js +4 -3
- package/dist/web/components/modal-provider.js.map +1 -1
- package/dist/web/create-store.d.ts +26 -0
- package/dist/web/create-store.js +26 -0
- package/dist/web/create-store.js.map +1 -1
- package/dist/web/create-store.test.js +8 -5
- package/dist/web/create-store.test.js.map +1 -1
- package/dist/web/data-llm.d.ts +34 -1
- package/dist/web/data-llm.js +28 -0
- package/dist/web/data-llm.js.map +1 -1
- package/dist/web/data-llm.test.js +17 -5
- package/dist/web/data-llm.test.js.map +1 -1
- package/dist/web/generate-helpers.d.ts +2 -0
- package/dist/web/generate-helpers.js +2 -0
- package/dist/web/generate-helpers.js.map +1 -1
- package/dist/web/generate-helpers.test-d.js +4 -2
- package/dist/web/generate-helpers.test-d.js.map +1 -1
- package/dist/web/hooks/index.d.ts +2 -0
- package/dist/web/hooks/index.js +2 -0
- package/dist/web/hooks/index.js.map +1 -1
- package/dist/web/hooks/test/utils.d.ts +6 -2
- package/dist/web/hooks/test/utils.js +13 -2
- package/dist/web/hooks/test/utils.js.map +1 -1
- package/dist/web/hooks/use-call-tool.d.ts +45 -0
- package/dist/web/hooks/use-call-tool.js +28 -0
- package/dist/web/hooks/use-call-tool.js.map +1 -1
- package/dist/web/hooks/use-call-tool.test.js +62 -23
- package/dist/web/hooks/use-call-tool.test.js.map +1 -1
- package/dist/web/hooks/use-display-mode.d.ts +20 -0
- package/dist/web/hooks/use-display-mode.js +20 -0
- package/dist/web/hooks/use-display-mode.js.map +1 -1
- package/dist/web/hooks/use-display-mode.test.js +56 -20
- package/dist/web/hooks/use-display-mode.test.js.map +1 -1
- package/dist/web/hooks/use-download.d.ts +5 -0
- package/dist/web/hooks/use-download.js +8 -0
- package/dist/web/hooks/use-download.js.map +1 -0
- package/dist/web/hooks/use-download.test.d.ts +1 -0
- package/dist/web/hooks/use-download.test.js +103 -0
- package/dist/web/hooks/use-download.test.js.map +1 -0
- package/dist/web/hooks/use-files.d.ts +32 -0
- package/dist/web/hooks/use-files.js +32 -0
- package/dist/web/hooks/use-files.js.map +1 -1
- package/dist/web/hooks/use-files.test.js +10 -2
- package/dist/web/hooks/use-files.test.js.map +1 -1
- package/dist/web/hooks/use-layout.d.ts +2 -0
- package/dist/web/hooks/use-layout.js +2 -0
- package/dist/web/hooks/use-layout.js.map +1 -1
- package/dist/web/hooks/use-layout.test.js +59 -26
- package/dist/web/hooks/use-layout.test.js.map +1 -1
- package/dist/web/hooks/use-open-external.d.ts +17 -0
- package/dist/web/hooks/use-open-external.js +16 -0
- package/dist/web/hooks/use-open-external.js.map +1 -1
- package/dist/web/hooks/use-open-external.test.js +13 -3
- package/dist/web/hooks/use-open-external.test.js.map +1 -1
- package/dist/web/hooks/use-register-view-tool.d.ts +38 -0
- package/dist/web/hooks/use-register-view-tool.js +50 -0
- package/dist/web/hooks/use-register-view-tool.js.map +1 -0
- package/dist/web/hooks/use-request-close.d.ts +14 -0
- package/dist/web/hooks/use-request-close.js +13 -0
- package/dist/web/hooks/use-request-close.js.map +1 -1
- package/dist/web/hooks/use-request-close.test.js +35 -40
- package/dist/web/hooks/use-request-close.test.js.map +1 -1
- package/dist/web/hooks/use-request-modal.d.ts +16 -1
- package/dist/web/hooks/use-request-modal.js +16 -1
- package/dist/web/hooks/use-request-modal.js.map +1 -1
- package/dist/web/hooks/use-request-modal.test.js +10 -0
- package/dist/web/hooks/use-request-modal.test.js.map +1 -1
- package/dist/web/hooks/use-request-size.d.ts +17 -0
- package/dist/web/hooks/use-request-size.js +16 -0
- package/dist/web/hooks/use-request-size.js.map +1 -1
- package/dist/web/hooks/use-request-size.test.js +35 -53
- package/dist/web/hooks/use-request-size.test.js.map +1 -1
- package/dist/web/hooks/use-send-follow-up-message.d.ts +17 -0
- package/dist/web/hooks/use-send-follow-up-message.js +17 -0
- package/dist/web/hooks/use-send-follow-up-message.js.map +1 -1
- package/dist/web/hooks/use-set-open-in-app-url.d.ts +17 -0
- package/dist/web/hooks/use-set-open-in-app-url.js +17 -0
- package/dist/web/hooks/use-set-open-in-app-url.js.map +1 -1
- package/dist/web/hooks/use-set-open-in-app-url.test.js +28 -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 +53 -2
- package/dist/web/hooks/use-tool-info.js +30 -7
- package/dist/web/hooks/use-tool-info.js.map +1 -1
- package/dist/web/hooks/use-tool-info.test-d.js +11 -29
- package/dist/web/hooks/use-tool-info.test-d.js.map +1 -1
- package/dist/web/hooks/use-tool-info.test.js +42 -32
- package/dist/web/hooks/use-tool-info.test.js.map +1 -1
- package/dist/web/hooks/use-user.d.ts +2 -0
- package/dist/web/hooks/use-user.js +2 -0
- package/dist/web/hooks/use-user.js.map +1 -1
- package/dist/web/hooks/use-user.test.js +81 -35
- package/dist/web/hooks/use-user.test.js.map +1 -1
- package/dist/web/hooks/use-view-state.d.ts +21 -0
- package/dist/web/hooks/use-view-state.js.map +1 -1
- package/dist/web/hooks/use-view-state.test.js +6 -2
- package/dist/web/hooks/use-view-state.test.js.map +1 -1
- package/dist/web/mount-view.d.ts +19 -0
- package/dist/web/mount-view.js +19 -0
- package/dist/web/mount-view.js.map +1 -1
- package/dist/web/plugin/plugin.d.ts +28 -0
- package/dist/web/plugin/plugin.js +33 -1
- package/dist/web/plugin/plugin.js.map +1 -1
- package/dist/web/types.d.ts +4 -0
- package/dist/web/types.js.map +1 -1
- package/package.json +26 -19
- package/dist/web/bridges/apps-sdk/adaptor.d.ts +0 -26
- package/dist/web/bridges/apps-sdk/adaptor.js +0 -102
- package/dist/web/bridges/apps-sdk/adaptor.js.map +0 -1
- package/dist/web/bridges/mcp-app/adaptor.d.ts +0 -50
- package/dist/web/bridges/mcp-app/adaptor.js +0 -271
- package/dist/web/bridges/mcp-app/adaptor.js.map +0 -1
package/dist/server/server.d.ts
CHANGED
|
@@ -3,15 +3,33 @@ import { type ServerOptions } from "@modelcontextprotocol/sdk/server/index.js";
|
|
|
3
3
|
import { McpServer as McpServerBase } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
4
|
import type { AnySchema, SchemaOutput, ZodRawShapeCompat } from "@modelcontextprotocol/sdk/server/zod-compat.js";
|
|
5
5
|
import type { RequestHandlerExtra } from "@modelcontextprotocol/sdk/shared/protocol.js";
|
|
6
|
-
import type { ContentBlock, Implementation, ServerNotification, ServerRequest, ServerResult, ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
|
|
7
|
-
import { type ErrorRequestHandler, type Express, type RequestHandler } from "express";
|
|
6
|
+
import type { ContentBlock, Implementation, RequestMeta, ServerNotification, ServerRequest, ServerResult, ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
|
|
7
|
+
import express, { type ErrorRequestHandler, type Express, type RequestHandler } from "express";
|
|
8
|
+
import type { OAuthConfig } from "./auth/index.js";
|
|
8
9
|
import type { McpExtra, McpExtraFor, McpMethodString, McpMiddlewareFilter, McpMiddlewareFn, McpResultFor, McpTypedMiddlewareFn, McpWildcard } from "./middleware.js";
|
|
10
|
+
/**
|
|
11
|
+
* Type marker for a registered tool — carries its input, output, and response
|
|
12
|
+
* metadata shapes so views can infer types from `typeof server`.
|
|
13
|
+
*
|
|
14
|
+
* You normally never construct this by hand; it is produced by `registerTool`
|
|
15
|
+
* and consumed by helpers like {@link InferTools} and {@link generateHelpers}.
|
|
16
|
+
*/
|
|
9
17
|
export type ToolDef<TInput = unknown, TOutput = unknown, TResponseMetadata = unknown> = {
|
|
10
18
|
input: TInput;
|
|
11
19
|
output: TOutput;
|
|
12
20
|
responseMetadata: TResponseMetadata;
|
|
13
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated Views now always emit a single ext-apps resource; host targeting
|
|
24
|
+
* no longer applies. Retained for backwards compatibility; will be removed in a
|
|
25
|
+
* future major.
|
|
26
|
+
*/
|
|
14
27
|
export type ViewHostType = "apps-sdk" | "mcp-app";
|
|
28
|
+
/**
|
|
29
|
+
* Content Security Policy origins attached to a view's resource. Each list is
|
|
30
|
+
* passed through to the host's CSP for the view iframe; omit a field to inherit
|
|
31
|
+
* the host's default for that directive.
|
|
32
|
+
*/
|
|
15
33
|
export interface ViewCsp {
|
|
16
34
|
/** Origins for static assets (images, fonts, scripts, styles). */
|
|
17
35
|
resourceDomains?: string[];
|
|
@@ -24,26 +42,90 @@ export interface ViewCsp {
|
|
|
24
42
|
/** Origins allowed in `<base href>` tags (mcp-apps only). */
|
|
25
43
|
baseUriDomains?: string[];
|
|
26
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Registry of view component names. The Skybridge Vite plugin augments this
|
|
47
|
+
* interface in the generated `.skybridge/views.d.ts` with one key per view
|
|
48
|
+
* file, which narrows {@link ViewName} from `string` to the concrete union.
|
|
49
|
+
*/
|
|
27
50
|
export interface ViewNameRegistry {
|
|
28
51
|
}
|
|
29
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Resolve view component names from a registry: the union of its keys, or
|
|
54
|
+
* `string` when the registry is empty. The empty case happens before
|
|
55
|
+
* `.skybridge/views.d.ts` is generated; falling back to `string` keeps valid
|
|
56
|
+
* view names from erroring on a fresh checkout, and narrowing kicks in once
|
|
57
|
+
* the generated file augments the registry.
|
|
58
|
+
*/
|
|
59
|
+
export type ViewNameFor<Registry> = [keyof Registry & string] extends [never] ? string : keyof Registry & string;
|
|
60
|
+
/** Union of valid view component names. Narrowed by {@link ViewNameRegistry}. */
|
|
61
|
+
export type ViewName = ViewNameFor<ViewNameRegistry>;
|
|
62
|
+
/**
|
|
63
|
+
* Pass under `view` in a tool's `registerTool` config to render the tool's
|
|
64
|
+
* result through a Skybridge view instead of a plain text response.
|
|
65
|
+
*/
|
|
30
66
|
export interface ViewConfig {
|
|
67
|
+
/** Filename of the view module (without extension) — matches a file in your `viewsDir`. */
|
|
31
68
|
component: ViewName;
|
|
69
|
+
/** Human-readable label the host may show alongside the view. */
|
|
32
70
|
description?: string;
|
|
71
|
+
/**
|
|
72
|
+
* @deprecated No-op. Every view emits a single ext-apps resource regardless
|
|
73
|
+
* of this value. Will be removed in a future major.
|
|
74
|
+
*/
|
|
33
75
|
hosts?: ViewHostType[];
|
|
76
|
+
/** Request a visible border around the view (forwarded as `ui.prefersBorder`). */
|
|
34
77
|
prefersBorder?: boolean;
|
|
78
|
+
/** Override the iframe's served domain (advanced; forwarded as `ui.domain`). */
|
|
35
79
|
domain?: string;
|
|
80
|
+
/** Per-view CSP overrides — see {@link ViewCsp}. */
|
|
36
81
|
csp?: ViewCsp;
|
|
82
|
+
/** Free-form metadata forwarded on the view resource's `_meta`. */
|
|
37
83
|
_meta?: Record<string, unknown>;
|
|
38
84
|
}
|
|
85
|
+
export type SecurityScheme = {
|
|
86
|
+
type: "noauth";
|
|
87
|
+
} | {
|
|
88
|
+
type: "oauth2";
|
|
89
|
+
scopes?: string[];
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Options forwarded to the built-in `express.json()` body parser. Derived
|
|
93
|
+
* from Express's own types so the public API doesn't depend on `body-parser`.
|
|
94
|
+
*/
|
|
95
|
+
export type JsonOptions = NonNullable<Parameters<typeof express.json>[0]>;
|
|
96
|
+
/** Skybridge-specific server options, passed as the third `McpServer` constructor argument. */
|
|
97
|
+
export interface SkybridgeServerOptions {
|
|
98
|
+
/** Options for the built-in `express.json()` middleware, e.g. `{ limit: "10mb" }`. */
|
|
99
|
+
json?: JsonOptions;
|
|
100
|
+
/** Resource-server OAuth config. When set, mounts well-known metadata and bearer auth on `/mcp`. */
|
|
101
|
+
oauth?: OAuthConfig;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Well-known keys recognized by host runtimes when set on a tool's `_meta`.
|
|
105
|
+
* Use {@link ToolMeta} to also pass arbitrary custom metadata alongside these.
|
|
106
|
+
*
|
|
107
|
+
* @see https://developers.openai.com/apps-sdk/reference#tool-descriptor-parameters
|
|
108
|
+
*/
|
|
39
109
|
export interface KnownToolMeta {
|
|
110
|
+
/** Apps SDK: allow the rendered view to call this tool from inside its iframe. */
|
|
40
111
|
"openai/widgetAccessible"?: boolean;
|
|
112
|
+
/** Apps SDK: status text shown while the tool is running (e.g. `"Searching trips"`). */
|
|
41
113
|
"openai/toolInvocation/invoking"?: string;
|
|
114
|
+
/** Apps SDK: status text shown once the tool returns (e.g. `"Found 3 trips"`). */
|
|
42
115
|
"openai/toolInvocation/invoked"?: string;
|
|
116
|
+
/** Apps SDK: input parameters that hold file references — the host attaches uploaded files to them. */
|
|
43
117
|
"openai/fileParams"?: string[];
|
|
118
|
+
/** MCP Apps: control whether the tool is exposed to the model, the app, or both. */
|
|
44
119
|
ui?: Pick<McpUiToolMeta, "visibility">;
|
|
120
|
+
securitySchemes?: SecurityScheme[];
|
|
45
121
|
}
|
|
122
|
+
/** {@link KnownToolMeta} merged with arbitrary string-keyed metadata for custom flags. */
|
|
46
123
|
export type ToolMeta = KnownToolMeta & Record<string, unknown>;
|
|
124
|
+
/**
|
|
125
|
+
* Convenient return type for tool handlers — a plain string, a single
|
|
126
|
+
* {@link ContentBlock}, or an array. Skybridge normalizes it to the MCP
|
|
127
|
+
* `content: ContentBlock[]` shape before responding.
|
|
128
|
+
*/
|
|
47
129
|
export type HandlerContent = string | ContentBlock | ContentBlock[];
|
|
48
130
|
/**
|
|
49
131
|
* Type-level marker interface for cross-package type inference.
|
|
@@ -87,17 +169,73 @@ interface ToolConfig<TInput extends ZodRawShapeCompat | AnySchema> {
|
|
|
87
169
|
outputSchema?: ZodRawShapeCompat | AnySchema;
|
|
88
170
|
annotations?: ToolAnnotations;
|
|
89
171
|
view?: ViewConfig;
|
|
172
|
+
/**
|
|
173
|
+
* Declares which auth schemes this tool supports (e.g. `noauth`, `oauth2`).
|
|
174
|
+
* Lets clients label tools that require sign-in before calling, and pass
|
|
175
|
+
* the right scopes through the OAuth flow. Listing both `noauth` and
|
|
176
|
+
* `oauth2` signals that the tool works for anonymous callers and gives
|
|
177
|
+
* enhanced behavior to authenticated ones.
|
|
178
|
+
*/
|
|
179
|
+
securitySchemes?: SecurityScheme[];
|
|
90
180
|
_meta?: ToolMeta;
|
|
91
181
|
}
|
|
182
|
+
/**
|
|
183
|
+
* Optional client-supplied hints attached to `params._meta` on every tool call
|
|
184
|
+
* by the Apps SDK host. Hints only: never use for authorization, and tolerate
|
|
185
|
+
* absence.
|
|
186
|
+
* @see https://developers.openai.com/apps-sdk/reference#_meta-fields-the-client-provides
|
|
187
|
+
*/
|
|
188
|
+
export interface ClientHintsMeta {
|
|
189
|
+
/** Requested locale (BCP-47, e.g. `"en-US"`). */
|
|
190
|
+
"openai/locale"?: string;
|
|
191
|
+
/** Browser user-agent */
|
|
192
|
+
"openai/userAgent"?: string;
|
|
193
|
+
/** Coarse user location. May be partially populated. */
|
|
194
|
+
"openai/userLocation"?: {
|
|
195
|
+
city?: string;
|
|
196
|
+
region?: string;
|
|
197
|
+
country?: string;
|
|
198
|
+
timezone?: string;
|
|
199
|
+
longitude?: number;
|
|
200
|
+
latitude?: number;
|
|
201
|
+
};
|
|
202
|
+
/** Anonymized user id. */
|
|
203
|
+
"openai/subject"?: string;
|
|
204
|
+
/** Anonymized conversation id, stable within a ChatGPT session. */
|
|
205
|
+
"openai/session"?: string;
|
|
206
|
+
/** Anonymized organization id, when the user account is part of an organization. */
|
|
207
|
+
"openai/organization"?: string;
|
|
208
|
+
/** Stable id for the currently mounted widget instance. */
|
|
209
|
+
"openai/widgetSessionId"?: string;
|
|
210
|
+
}
|
|
211
|
+
type ToolHandlerExtra = Omit<RequestHandlerExtra<ServerRequest, ServerNotification>, "_meta"> & {
|
|
212
|
+
_meta?: RequestMeta & ClientHintsMeta;
|
|
213
|
+
};
|
|
92
214
|
type ToolHandler<TInput extends ZodRawShapeCompat, TReturn extends {
|
|
93
215
|
content?: HandlerContent;
|
|
94
216
|
} = {
|
|
95
217
|
content?: HandlerContent;
|
|
96
|
-
}> = (args: ShapeOutput<TInput>, extra:
|
|
218
|
+
}> = (args: ShapeOutput<TInput>, extra: ToolHandlerExtra) => TReturn | Promise<TReturn>;
|
|
219
|
+
/**
|
|
220
|
+
* Coerce a tool handler's return value into an MCP `content` array. Strings
|
|
221
|
+
* become a single `TextContent`; a single block is wrapped in an array;
|
|
222
|
+
* `undefined` produces `[]`. Mostly used internally — exported so consumers
|
|
223
|
+
* who build content lazily can apply the same normalization.
|
|
224
|
+
*/
|
|
97
225
|
export declare function normalizeContent(content: HandlerContent | undefined): ContentBlock[];
|
|
98
226
|
interface McpServerBaseOmitted extends Omit<McpServerBase, "registerTool" | "connect"> {
|
|
99
227
|
}
|
|
100
228
|
declare const McpServerBaseOmitted: new (...args: ConstructorParameters<typeof McpServerBase>) => McpServerBaseOmitted;
|
|
229
|
+
/**
|
|
230
|
+
* Prime the build-time Vite manifest before user code constructs its
|
|
231
|
+
* `McpServer`. Called from the generated `dist/__entry.js`; not part of the
|
|
232
|
+
* user-facing API.
|
|
233
|
+
*
|
|
234
|
+
* @internal
|
|
235
|
+
*/
|
|
236
|
+
export declare function __setBuildManifest(manifest: Record<string, {
|
|
237
|
+
file: string;
|
|
238
|
+
}>): void;
|
|
101
239
|
export declare class McpServer<TTools extends Record<string, ToolDef> = Record<never, ToolDef>> extends McpServerBaseOmitted {
|
|
102
240
|
readonly $types: McpServerTypes<TTools>;
|
|
103
241
|
/**
|
|
@@ -105,7 +243,9 @@ export declare class McpServer<TTools extends Record<string, ToolDef> = Record<n
|
|
|
105
243
|
* custom routes, middleware, or settings — e.g.
|
|
106
244
|
* `server.express.get("/health", ...)`.
|
|
107
245
|
*
|
|
108
|
-
* `express.json()` is pre-applied
|
|
246
|
+
* `express.json()` is pre-applied — tune it via the constructor's third
|
|
247
|
+
* argument, e.g. `new McpServer(info, {}, { json: { limit: "10mb" } })`.
|
|
248
|
+
* Register your handlers before `run()`;
|
|
109
249
|
* after `run()`, dev-mode middleware, the `/mcp` route, and the default
|
|
110
250
|
* error handler are appended in that order.
|
|
111
251
|
*
|
|
@@ -117,12 +257,41 @@ export declare class McpServer<TTools extends Record<string, ToolDef> = Record<n
|
|
|
117
257
|
private mcpMiddlewareEntries;
|
|
118
258
|
private mcpMiddlewareApplied;
|
|
119
259
|
private claimedViews;
|
|
260
|
+
private viewMetaBuilders;
|
|
261
|
+
/**
|
|
262
|
+
* Maps a view resource's query-less path to its canonical registered URI
|
|
263
|
+
* (the one carrying the `?v=` cache key). Lets `resources/read` resolve the
|
|
264
|
+
* underlying view no matter which version param the consumer sends, since
|
|
265
|
+
* the param is only a cache key, not part of the resource's identity.
|
|
266
|
+
*/
|
|
267
|
+
private viewUriByPath;
|
|
120
268
|
private viteManifest;
|
|
121
269
|
private readonly serverInfo;
|
|
122
270
|
private readonly serverOptions?;
|
|
123
|
-
constructor(serverInfo: Implementation, options?: ServerOptions);
|
|
271
|
+
constructor(serverInfo: Implementation, options?: ServerOptions, skybridgeOptions?: SkybridgeServerOptions);
|
|
272
|
+
/**
|
|
273
|
+
* Register Express middleware on the underlying app. Mirrors `app.use` —
|
|
274
|
+
* pass handlers directly or a path-prefixed handler list. Register before
|
|
275
|
+
* {@link McpServer.run}; ordering matches Express.
|
|
276
|
+
*
|
|
277
|
+
* Note: Alpic Cloud only routes traffic to `/mcp`. Custom paths work
|
|
278
|
+
* locally and on self-hosted deployments.
|
|
279
|
+
*/
|
|
124
280
|
use(...handlers: RequestHandler[]): this;
|
|
125
281
|
use(path: string, ...handlers: RequestHandler[]): this;
|
|
282
|
+
/**
|
|
283
|
+
* Register Express error-handling middleware to run after the built-in
|
|
284
|
+
* `/mcp` route (or your custom route). Use this to log or transform errors
|
|
285
|
+
* thrown by tool handlers before the default error handler responds.
|
|
286
|
+
*
|
|
287
|
+
* @example
|
|
288
|
+
* ```ts
|
|
289
|
+
* server.useOnError((err, _req, _res, next) => {
|
|
290
|
+
* logger.error(err);
|
|
291
|
+
* next(err);
|
|
292
|
+
* });
|
|
293
|
+
* ```
|
|
294
|
+
*/
|
|
126
295
|
useOnError(...handlers: ErrorRequestHandler[]): this;
|
|
127
296
|
useOnError(path: string, ...handlers: ErrorRequestHandler[]): this;
|
|
128
297
|
/** Register MCP protocol-level middleware (catch-all). */
|
|
@@ -157,6 +326,14 @@ export declare class McpServer<TTools extends Record<string, ToolDef> = Record<n
|
|
|
157
326
|
*/
|
|
158
327
|
mcpMiddleware(filter: McpMiddlewareFilter, handler: McpMiddlewareFn): this;
|
|
159
328
|
private applyMcpMiddleware;
|
|
329
|
+
/**
|
|
330
|
+
* Connect to an MCP transport (override of the SDK's `connect`). Use this
|
|
331
|
+
* when you're embedding Skybridge in a host that already manages its own
|
|
332
|
+
* transport (e.g. stdio for desktop apps); for HTTP, prefer {@link McpServer.run}
|
|
333
|
+
* which sets the transport up for you. Locks in any middleware registered
|
|
334
|
+
* via {@link McpServer.mcpMiddleware} — further calls to that method will
|
|
335
|
+
* throw afterwards.
|
|
336
|
+
*/
|
|
160
337
|
connect(transport: Parameters<typeof McpServerBase.prototype.connect>[0]): Promise<void>;
|
|
161
338
|
/**
|
|
162
339
|
* Per-request stateless connect. The SDK's `Protocol` only allows one
|
|
@@ -169,12 +346,26 @@ export declare class McpServer<TTools extends Record<string, ToolDef> = Record<n
|
|
|
169
346
|
* read side and fails fast on SDK field renames.
|
|
170
347
|
*/
|
|
171
348
|
connectStatelessTransport(transport: Parameters<typeof McpServerBase.prototype.connect>[0]): Promise<void>;
|
|
349
|
+
/**
|
|
350
|
+
* Start the HTTP server. Listens on `process.env.__PORT` (default `3000`),
|
|
351
|
+
* mounts the `/mcp` route, applies any custom Express middleware registered
|
|
352
|
+
* via {@link McpServer.use} / {@link McpServer.useOnError}, and locks in
|
|
353
|
+
* any MCP middleware registered via {@link McpServer.mcpMiddleware}.
|
|
354
|
+
*
|
|
355
|
+
* On Cloudflare Workers / workerd, returns an object exposing `fetch` so
|
|
356
|
+
* the runtime can bridge incoming requests to the Node HTTP server. On
|
|
357
|
+
* Vercel (`VERCEL === "1"`), returns the Express app directly so the
|
|
358
|
+
* serverless function entry can call it as a `(req, res)` handler. On
|
|
359
|
+
* Node, returns `undefined` once listening.
|
|
360
|
+
*/
|
|
172
361
|
run(): Promise<{
|
|
173
362
|
fetch: (...args: unknown[]) => unknown;
|
|
174
|
-
} | undefined>;
|
|
363
|
+
} | Express | undefined>;
|
|
175
364
|
private enforceOneToolPerView;
|
|
365
|
+
private resolveViewRequestContext;
|
|
176
366
|
private registerViewResources;
|
|
177
367
|
private registerViewResource;
|
|
368
|
+
private serveLegacyAppsSdkUrl;
|
|
178
369
|
private wrapHandler;
|
|
179
370
|
private computeViewVersionParam;
|
|
180
371
|
private lookupViewFile;
|
|
@@ -189,6 +380,35 @@ export declare class McpServer<TTools extends Record<string, ToolDef> = Record<n
|
|
|
189
380
|
file: string;
|
|
190
381
|
}>): this;
|
|
191
382
|
private readManifest;
|
|
383
|
+
/**
|
|
384
|
+
* Register a tool. Pass a `config` describing the tool (name, schemas,
|
|
385
|
+
* optional {@link ViewConfig}, optional {@link ToolMeta}) and a handler that
|
|
386
|
+
* returns the tool's result.
|
|
387
|
+
*
|
|
388
|
+
* Chain calls to build up a server: each call returns a new `McpServer`
|
|
389
|
+
* type that captures the tool's input/output/`_meta` shape so the
|
|
390
|
+
* resulting `typeof server` can drive {@link generateHelpers}.
|
|
391
|
+
*
|
|
392
|
+
* The handler's return shape determines the output types: the
|
|
393
|
+
* `structuredContent` field becomes the tool's typed output, and `_meta`
|
|
394
|
+
* becomes its `responseMetadata`. The `content` field is normalized through
|
|
395
|
+
* {@link normalizeContent}.
|
|
396
|
+
*
|
|
397
|
+
* @example
|
|
398
|
+
* ```ts
|
|
399
|
+
* server.registerTool({
|
|
400
|
+
* name: "search",
|
|
401
|
+
* inputSchema: { query: z.string() },
|
|
402
|
+
* outputSchema: { results: z.array(z.string()) },
|
|
403
|
+
* view: { component: "search" },
|
|
404
|
+
* }, async ({ query }) => ({
|
|
405
|
+
* content: `Found results for ${query}`,
|
|
406
|
+
* structuredContent: { results: [...] },
|
|
407
|
+
* }));
|
|
408
|
+
* ```
|
|
409
|
+
*
|
|
410
|
+
* @see https://docs.skybridge.tech/api-reference/register-tool
|
|
411
|
+
*/
|
|
192
412
|
registerTool<TName extends string, InputArgs extends ZodRawShapeCompat, TReturn extends {
|
|
193
413
|
content?: HandlerContent;
|
|
194
414
|
}>(config: ToolConfig<InputArgs> & {
|