skybridge 0.0.0-dev.8e84184 → 0.0.0-dev.8ead776
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 +17 -14
- package/dist/cli/build-helpers.d.ts +3 -2
- package/dist/cli/build-helpers.js +24 -10
- package/dist/cli/build-helpers.js.map +1 -1
- package/dist/cli/build-helpers.test.js +48 -5
- package/dist/cli/build-helpers.test.js.map +1 -1
- package/dist/cli/build-steps.js +10 -5
- 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/header.d.ts +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.d.ts +18 -0
- package/dist/cli/run-plain.js +90 -0
- package/dist/cli/run-plain.js.map +1 -0
- package/dist/cli/telemetry.js +2 -0
- package/dist/cli/telemetry.js.map +1 -1
- package/dist/cli/use-nodemon.d.ts +25 -1
- package/dist/cli/use-nodemon.js +96 -63
- 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 +70 -67
- package/dist/cli/use-typescript-check.js.map +1 -1
- package/dist/commands/dev.d.ts +1 -0
- package/dist/commands/dev.js +38 -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 +24 -6
- package/dist/server/auth/providers/custom.js +33 -11
- package/dist/server/auth/providers/custom.js.map +1 -1
- package/dist/server/auth/providers/custom.test.js +71 -17
- 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 +13 -2
- package/dist/server/auth/providers/descope.js.map +1 -1
- package/dist/server/auth/providers/descope.test.js +42 -17
- 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 +28 -5
- package/dist/server/auth/providers/workos.js +6 -2
- 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 +42 -6
- package/dist/server/auth/verify.js +27 -3
- package/dist/server/auth/verify.js.map +1 -1
- package/dist/server/auth/verify.test.js +65 -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 +16 -9
- package/dist/server/index.js +9 -3
- 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 +133 -0
- package/dist/server/register-tool.test.js.map +1 -0
- package/dist/server/server.d.ts +283 -128
- package/dist/server/server.js +295 -274
- package/dist/server/server.js.map +1 -1
- package/dist/server/skills-integration.test.d.ts +1 -0
- package/dist/server/skills-integration.test.js +86 -0
- package/dist/server/skills-integration.test.js.map +1 -0
- package/dist/server/skills.d.ts +27 -0
- package/dist/server/skills.js +188 -0
- package/dist/server/skills.js.map +1 -0
- package/dist/server/skills.test.d.ts +1 -0
- package/dist/server/skills.test.js +243 -0
- package/dist/server/skills.test.js.map +1 -0
- 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.d.ts +13 -3
- package/dist/web/bridges/adaptor.js +182 -16
- package/dist/web/bridges/adaptor.js.map +1 -1
- package/dist/web/bridges/adaptor.test.js +78 -11
- package/dist/web/bridges/adaptor.test.js.map +1 -1
- package/dist/web/bridges/apps-sdk/bridge.js +1 -1
- package/dist/web/bridges/apps-sdk/bridge.js.map +1 -1
- package/dist/web/bridges/apps-sdk/use-apps-sdk-context.d.ts +4 -4
- package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js +4 -4
- 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.d.ts +1 -1
- package/dist/web/bridges/mcp-app/bridge.js +15 -6
- 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 +19 -2
- package/dist/web/bridges/mcp-app/types.js.map +1 -1
- package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +2 -2
- 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 +77 -16
- package/dist/web/bridges/types.js +1 -1
- package/dist/web/bridges/types.js.map +1 -1
- package/dist/web/components/modal-provider.d.ts +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.d.ts +1 -1
- package/dist/web/data-llm.js +3 -2
- package/dist/web/data-llm.js.map +1 -1
- package/dist/web/data-llm.test.js +17 -2
- package/dist/web/data-llm.test.js.map +1 -1
- package/dist/web/generate-helpers.d.ts +23 -19
- package/dist/web/generate-helpers.js +21 -17
- 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 +6 -1
- package/dist/web/hooks/index.js +6 -1
- package/dist/web/hooks/index.js.map +1 -1
- package/dist/web/hooks/openai-extensions.test.d.ts +1 -0
- package/dist/web/hooks/openai-extensions.test.js +107 -0
- package/dist/web/hooks/openai-extensions.test.js.map +1 -0
- 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.d.ts +2 -2
- package/dist/web/hooks/use-call-tool.js +15 -10
- package/dist/web/hooks/use-call-tool.js.map +1 -1
- package/dist/web/hooks/use-call-tool.test.js +15 -4
- package/dist/web/hooks/use-call-tool.test.js.map +1 -1
- package/dist/web/hooks/use-deep-link.d.ts +22 -0
- package/dist/web/hooks/use-deep-link.js +34 -0
- package/dist/web/hooks/use-deep-link.js.map +1 -0
- 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-file-resource.d.ts +37 -0
- package/dist/web/hooks/use-file-resource.js +101 -0
- package/dist/web/hooks/use-file-resource.js.map +1 -0
- package/dist/web/hooks/use-file-resource.test.d.ts +1 -0
- package/dist/web/hooks/use-file-resource.test.js +65 -0
- package/dist/web/hooks/use-file-resource.test.js.map +1 -0
- 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 +44 -0
- package/dist/web/hooks/use-host.js +45 -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-model-context.d.ts +44 -0
- package/dist/web/hooks/use-model-context.js +63 -0
- package/dist/web/hooks/use-model-context.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-open-file.d.ts +20 -0
- package/dist/web/hooks/use-open-file.js +25 -0
- package/dist/web/hooks/use-open-file.js.map +1 -0
- package/dist/web/hooks/use-register-view-tool.d.ts +3 -4
- package/dist/web/hooks/use-register-view-tool.js +1 -1
- 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-send-follow-up-message.d.ts +8 -2
- package/dist/web/hooks/use-send-follow-up-message.js +6 -0
- package/dist/web/hooks/use-send-follow-up-message.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 +32 -29
- 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 -189
- 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,11 @@
|
|
|
1
1
|
import type { McpUiToolMeta } from "@modelcontextprotocol/ext-apps";
|
|
2
|
-
import { type ServerOptions } from "@modelcontextprotocol/
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import
|
|
8
|
-
import type
|
|
9
|
-
import type { McpExtra, McpExtraFor, McpMethodString, McpMiddlewareFilter, McpMiddlewareFn, McpResultFor, McpTypedMiddlewareFn, McpWildcard } from "./middleware.js";
|
|
2
|
+
import { type ContentBlock, type Icon, type Implementation, McpServer as McpServerBase, type RequestMeta, type ResourceLink, type ServerOptions, type ServerResult, type StandardSchemaV1, type StandardSchemaWithJSON, type ToolAnnotations } from "@modelcontextprotocol/server";
|
|
3
|
+
import type express from "express";
|
|
4
|
+
import { z } from "zod/v4";
|
|
5
|
+
import type { ResourceMetadataUrlResolver } from "./auth/setup.js";
|
|
6
|
+
import type { ExtraClaims } from "./auth.js";
|
|
7
|
+
import type { McpExtra, McpExtraFor, McpMethodString, McpMiddlewareEntry, McpMiddlewareFilter, McpMiddlewareFn, McpResultFor, McpTypedMiddlewareFn, McpWildcard } from "./middleware.js";
|
|
8
|
+
import { type SkillsManifest } from "./skills.js";
|
|
10
9
|
/**
|
|
11
10
|
* Type marker for a registered tool — carries its input, output, and response
|
|
12
11
|
* metadata shapes so views can infer types from `typeof server`.
|
|
@@ -19,12 +18,6 @@ export type ToolDef<TInput = unknown, TOutput = unknown, TResponseMetadata = unk
|
|
|
19
18
|
output: TOutput;
|
|
20
19
|
responseMetadata: TResponseMetadata;
|
|
21
20
|
};
|
|
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
|
-
*/
|
|
27
|
-
export type ViewHostType = "apps-sdk" | "mcp-app";
|
|
28
21
|
/**
|
|
29
22
|
* Content Security Policy origins attached to a view's resource. Each list is
|
|
30
23
|
* passed through to the host's CSP for the view iframe; omit a field to inherit
|
|
@@ -35,7 +28,7 @@ export interface ViewCsp {
|
|
|
35
28
|
resourceDomains?: string[];
|
|
36
29
|
/** Origins the view may contact via fetch/XHR. */
|
|
37
30
|
connectDomains?: string[];
|
|
38
|
-
/** Origins allowed for iframe embeds (opts into stricter
|
|
31
|
+
/** Origins allowed for iframe embeds (opts into stricter plugin review). */
|
|
39
32
|
frameDomains?: string[];
|
|
40
33
|
/** Origins that can receive openExternal redirects without the safe-link modal. */
|
|
41
34
|
redirectDomains?: string[];
|
|
@@ -68,11 +61,6 @@ export interface ViewConfig {
|
|
|
68
61
|
component: ViewName;
|
|
69
62
|
/** Human-readable label the host may show alongside the view. */
|
|
70
63
|
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
|
-
*/
|
|
75
|
-
hosts?: ViewHostType[];
|
|
76
64
|
/** Request a visible border around the view (forwarded as `ui.prefersBorder`). */
|
|
77
65
|
prefersBorder?: boolean;
|
|
78
66
|
/** Override the iframe's served domain (advanced; forwarded as `ui.domain`). */
|
|
@@ -88,36 +76,115 @@ export type SecurityScheme = {
|
|
|
88
76
|
type: "oauth2";
|
|
89
77
|
scopes?: string[];
|
|
90
78
|
};
|
|
79
|
+
/** A display mode ChatGPT can render a view in. ChatGPT doesn't support `pip`. */
|
|
80
|
+
export type OpenAIDisplayMode = "inline" | "fullscreen";
|
|
81
|
+
/** A sidebar shortcut that calls another tool of the same server. */
|
|
82
|
+
export interface OpenAIQuickAction {
|
|
83
|
+
title: string;
|
|
84
|
+
icons: [Icon, ...Icon[]];
|
|
85
|
+
target: {
|
|
86
|
+
type: "tool";
|
|
87
|
+
name: string;
|
|
88
|
+
arguments?: Record<string, unknown>;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* A place in ChatGPT where users can open the tool's view without the model.
|
|
93
|
+
*
|
|
94
|
+
* - `global`: an entry in the sidebar, opened fullscreen.
|
|
95
|
+
* - `thread`: a tab in a conversation's side panel.
|
|
96
|
+
* - `file`: a viewer for files with these extensions, such as `".stl"`.
|
|
97
|
+
* ChatGPT calls the tool with `{ file: { name, resourceUri } }`.
|
|
98
|
+
* - `settings`: an entry in the plugin settings.
|
|
99
|
+
*
|
|
100
|
+
* ChatGPT calls the tool with `{}` for global and thread entrypoints, so the
|
|
101
|
+
* tool must not require any input.
|
|
102
|
+
*/
|
|
103
|
+
export type OpenAIEntrypoint = {
|
|
104
|
+
type: "global";
|
|
105
|
+
quickAction?: OpenAIQuickAction;
|
|
106
|
+
} | {
|
|
107
|
+
type: "thread";
|
|
108
|
+
} | {
|
|
109
|
+
type: "file";
|
|
110
|
+
extensions: string[];
|
|
111
|
+
} | {
|
|
112
|
+
type: "settings";
|
|
113
|
+
searchTerms?: string[];
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* ChatGPT-only tool options, emitted as `_meta["openai/ui"]` on the tool and
|
|
117
|
+
* on its view resource. Every field is optional: ChatGPT applies the defaults
|
|
118
|
+
* of the OpenAI MCP extensions spec when one is omitted. Requires `view`.
|
|
119
|
+
*
|
|
120
|
+
* @see https://github.com/openai/mcp-extensions/blob/main/docs/spec.md
|
|
121
|
+
*/
|
|
122
|
+
export interface OpenAIToolConfig {
|
|
123
|
+
/** Places where users can open the view directly. */
|
|
124
|
+
entrypoints?: OpenAIEntrypoint[];
|
|
125
|
+
/**
|
|
126
|
+
* Display modes the view supports, read before the view loads. Defaults to
|
|
127
|
+
* `[preferredDisplayMode]` when that is set, otherwise to both modes.
|
|
128
|
+
*/
|
|
129
|
+
availableDisplayModes?: OpenAIDisplayMode[];
|
|
130
|
+
/**
|
|
131
|
+
* Display mode the view prefers to open in. Setting it alone makes it the
|
|
132
|
+
* only available mode, so also set `availableDisplayModes` to keep the other.
|
|
133
|
+
*/
|
|
134
|
+
preferredDisplayMode?: OpenAIDisplayMode;
|
|
135
|
+
/** Display mode the view opens in first when the model calls the tool. */
|
|
136
|
+
preferredModelDisplayMode?: OpenAIDisplayMode;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Declarative per-tool auth. Enforced when the server has an `oauth` provider:
|
|
140
|
+
* anonymous or under-scoped calls are rejected before the handler runs. Omit
|
|
141
|
+
* `auth` entirely for the secure default (sign-in required, no specific scope).
|
|
142
|
+
*/
|
|
143
|
+
export type ToolAuth = {
|
|
144
|
+
/**
|
|
145
|
+
* When `true`, the tool is callable signed out; the token is still used when
|
|
146
|
+
* one is present. Omit (or `false`) to require sign-in.
|
|
147
|
+
*/
|
|
148
|
+
allowsAnonymous?: boolean;
|
|
149
|
+
/** OAuth scopes the caller's token must carry to invoke the tool. */
|
|
150
|
+
scopes?: string[];
|
|
151
|
+
};
|
|
91
152
|
/**
|
|
92
153
|
* Options forwarded to the built-in `express.json()` body parser. Derived
|
|
93
154
|
* from Express's own types so the public API doesn't depend on `body-parser`.
|
|
94
155
|
*/
|
|
95
156
|
export type JsonOptions = NonNullable<Parameters<typeof express.json>[0]>;
|
|
96
|
-
/**
|
|
157
|
+
/**
|
|
158
|
+
* The Skybridge-specific options an {@link McpServer} is built with. A
|
|
159
|
+
* {@link Skybridge} app derives them from its config; pass them directly only
|
|
160
|
+
* when constructing an `McpServer` by hand.
|
|
161
|
+
*/
|
|
97
162
|
export interface SkybridgeServerOptions {
|
|
98
|
-
/**
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
|
|
163
|
+
/** Whether an OAuth provider guards `/mcp`; enables per-tool scheme enforcement. */
|
|
164
|
+
oauth?: boolean;
|
|
165
|
+
/**
|
|
166
|
+
* @experimental Serve Agent Skills from `src/skills` over MCP (SEP-2640).
|
|
167
|
+
* API may change.
|
|
168
|
+
*/
|
|
169
|
+
skills?: boolean;
|
|
102
170
|
}
|
|
103
171
|
/**
|
|
104
172
|
* Well-known keys recognized by host runtimes when set on a tool's `_meta`.
|
|
105
173
|
* Use {@link ToolMeta} to also pass arbitrary custom metadata alongside these.
|
|
106
174
|
*
|
|
107
|
-
* @see https://developers.openai.com/
|
|
175
|
+
* @see https://developers.openai.com/plugins/reference#tool-descriptor-parameters
|
|
108
176
|
*/
|
|
109
177
|
export interface KnownToolMeta {
|
|
110
|
-
/**
|
|
178
|
+
/** ChatGPT: allow the rendered view to call this tool from inside its iframe. */
|
|
111
179
|
"openai/widgetAccessible"?: boolean;
|
|
112
|
-
/**
|
|
180
|
+
/** ChatGPT: status text shown while the tool is running (e.g. `"Searching trips"`). */
|
|
113
181
|
"openai/toolInvocation/invoking"?: string;
|
|
114
|
-
/**
|
|
182
|
+
/** ChatGPT: status text shown once the tool returns (e.g. `"Found 3 trips"`). */
|
|
115
183
|
"openai/toolInvocation/invoked"?: string;
|
|
116
|
-
/**
|
|
184
|
+
/** ChatGPT: input parameters that hold file references — the host attaches uploaded files to them. */
|
|
117
185
|
"openai/fileParams"?: string[];
|
|
118
186
|
/** MCP Apps: control whether the tool is exposed to the model, the app, or both. */
|
|
119
187
|
ui?: Pick<McpUiToolMeta, "visibility">;
|
|
120
|
-
securitySchemes?: SecurityScheme[];
|
|
121
188
|
}
|
|
122
189
|
/** {@link KnownToolMeta} merged with arbitrary string-keyed metadata for custom flags. */
|
|
123
190
|
export type ToolMeta = KnownToolMeta & Record<string, unknown>;
|
|
@@ -143,10 +210,10 @@ export interface McpServerTypes<TTools extends Record<string, ToolDef>> {
|
|
|
143
210
|
type Simplify<T> = {
|
|
144
211
|
[K in keyof T]: T[K];
|
|
145
212
|
};
|
|
146
|
-
type ShapeOutput<Shape extends
|
|
147
|
-
[K in keyof Shape as undefined extends
|
|
213
|
+
type ShapeOutput<Shape extends Record<string, StandardSchemaWithJSON>> = Simplify<{
|
|
214
|
+
[K in keyof Shape as undefined extends StandardSchemaV1.InferOutput<Shape[K]> ? never : K]: StandardSchemaV1.InferOutput<Shape[K]>;
|
|
148
215
|
} & {
|
|
149
|
-
[K in keyof Shape as undefined extends
|
|
216
|
+
[K in keyof Shape as undefined extends StandardSchemaV1.InferOutput<Shape[K]> ? K : never]?: StandardSchemaV1.InferOutput<Shape[K]>;
|
|
150
217
|
}>;
|
|
151
218
|
type ExtractStructuredContent<T> = T extends {
|
|
152
219
|
structuredContent: infer SC;
|
|
@@ -158,17 +225,36 @@ type ExtractMeta<T> = [Extract<T, {
|
|
|
158
225
|
}> extends {
|
|
159
226
|
_meta: infer M;
|
|
160
227
|
} ? Simplify<M> : unknown;
|
|
161
|
-
type AddTool<TTools, TName extends string, TInput extends
|
|
228
|
+
type AddTool<TTools, TName extends string, TInput extends Record<string, StandardSchemaWithJSON>, TOutput, TResponseMetadata = unknown, TAuthExtra extends ExtraClaims = ExtraClaims> = McpServer<TTools & {
|
|
162
229
|
[K in TName]: ToolDef<ShapeOutput<TInput>, TOutput, TResponseMetadata>;
|
|
163
|
-
}>;
|
|
164
|
-
interface
|
|
230
|
+
}, TAuthExtra>;
|
|
231
|
+
interface ToolConfigBase<TInput extends Record<string, StandardSchemaWithJSON> | StandardSchemaWithJSON> {
|
|
165
232
|
name: string;
|
|
166
233
|
title?: string;
|
|
167
234
|
description?: string;
|
|
168
235
|
inputSchema?: TInput;
|
|
169
|
-
outputSchema?:
|
|
236
|
+
outputSchema?: Record<string, StandardSchemaWithJSON> | StandardSchemaWithJSON;
|
|
170
237
|
annotations?: ToolAnnotations;
|
|
238
|
+
/**
|
|
239
|
+
* Icons for the tool, a standard MCP field. Hosts choose whether and where
|
|
240
|
+
* to show them. ChatGPT asks for them on every entrypoint tool, as a
|
|
241
|
+
* monochrome SVG on a 20x20 viewport that uses `currentColor`.
|
|
242
|
+
*/
|
|
243
|
+
icons?: Icon[];
|
|
171
244
|
view?: ViewConfig;
|
|
245
|
+
/** ChatGPT-only options. See {@link OpenAIToolConfig}. */
|
|
246
|
+
openai?: OpenAIToolConfig;
|
|
247
|
+
_meta?: ToolMeta;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* The auth face of a tool config: either the high-level `auth` shorthand or the
|
|
251
|
+
* low-level `securitySchemes` escape hatch, never both.
|
|
252
|
+
*/
|
|
253
|
+
type ToolAuthConfig = {
|
|
254
|
+
auth?: ToolAuth;
|
|
255
|
+
securitySchemes?: never;
|
|
256
|
+
} | {
|
|
257
|
+
auth?: never;
|
|
172
258
|
/**
|
|
173
259
|
* Declares which auth schemes this tool supports (e.g. `noauth`, `oauth2`).
|
|
174
260
|
* Lets clients label tools that require sign-in before calling, and pass
|
|
@@ -177,13 +263,29 @@ interface ToolConfig<TInput extends ZodRawShapeCompat | AnySchema> {
|
|
|
177
263
|
* enhanced behavior to authenticated ones.
|
|
178
264
|
*/
|
|
179
265
|
securitySchemes?: SecurityScheme[];
|
|
180
|
-
|
|
181
|
-
|
|
266
|
+
};
|
|
267
|
+
type ToolConfig<TInput extends Record<string, StandardSchemaWithJSON> | StandardSchemaWithJSON> = ToolConfigBase<TInput> & ToolAuthConfig;
|
|
268
|
+
declare const fileEntrypointInput: {
|
|
269
|
+
file: z.ZodObject<{
|
|
270
|
+
name: z.ZodString;
|
|
271
|
+
resourceUri: z.ZodString;
|
|
272
|
+
}, z.core.$strip>;
|
|
273
|
+
};
|
|
274
|
+
type FileEntrypointInput = typeof fileEntrypointInput;
|
|
275
|
+
/** A ChatGPT file viewer, registered with `server.registerFileViewer`. */
|
|
276
|
+
export type OpenAIFileViewerConfig<TName extends string = string> = Omit<ToolConfigBase<FileEntrypointInput>, "inputSchema" | "openai" | "view"> & ToolAuthConfig & {
|
|
277
|
+
name: TName;
|
|
278
|
+
/** File extensions the viewer opens, each starting with `.`. */
|
|
279
|
+
extensions: string[];
|
|
280
|
+
view: ViewConfig;
|
|
281
|
+
/** Display modes. The file entrypoint is set from `extensions`. */
|
|
282
|
+
openai?: Omit<OpenAIToolConfig, "entrypoints">;
|
|
283
|
+
};
|
|
182
284
|
/**
|
|
183
285
|
* Optional client-supplied hints attached to `params._meta` on every tool call
|
|
184
|
-
* by the
|
|
286
|
+
* by the ChatGPT host. Hints only: never use for authorization, and tolerate
|
|
185
287
|
* absence.
|
|
186
|
-
* @see https://developers.openai.com/
|
|
288
|
+
* @see https://developers.openai.com/plugins/reference#_meta-fields-the-client-provides
|
|
187
289
|
*/
|
|
188
290
|
export interface ClientHintsMeta {
|
|
189
291
|
/** Requested locale (BCP-47, e.g. `"en-US"`). */
|
|
@@ -207,15 +309,40 @@ export interface ClientHintsMeta {
|
|
|
207
309
|
"openai/organization"?: string;
|
|
208
310
|
/** Stable id for the currently mounted widget instance. */
|
|
209
311
|
"openai/widgetSessionId"?: string;
|
|
312
|
+
/**
|
|
313
|
+
* Set by ChatGPT desktop on tool calls from a view opened through a file
|
|
314
|
+
* entrypoint. `path` is the absolute path of the opened file. Any MCP client
|
|
315
|
+
* can send this key: never use it for authorization, and resolve the path
|
|
316
|
+
* and keep it inside an allowed directory before touching the filesystem.
|
|
317
|
+
*/
|
|
318
|
+
"openai/resource"?: {
|
|
319
|
+
path?: string;
|
|
320
|
+
};
|
|
210
321
|
}
|
|
211
|
-
type ToolHandlerExtra = Omit<
|
|
212
|
-
_meta
|
|
322
|
+
type ToolHandlerExtra<TAuthExtra extends ExtraClaims = ExtraClaims> = Omit<McpExtra<TAuthExtra>, "mcpReq"> & {
|
|
323
|
+
mcpReq: Omit<McpExtra<TAuthExtra>["mcpReq"], "_meta"> & {
|
|
324
|
+
_meta?: RequestMeta & ClientHintsMeta;
|
|
325
|
+
};
|
|
213
326
|
};
|
|
214
|
-
|
|
327
|
+
/** Composer at-mention search, registered with `server.registerMentions`. */
|
|
328
|
+
export interface OpenAIMentionsConfig<TAuthExtra extends ExtraClaims = ExtraClaims> {
|
|
329
|
+
/** Name of the tool ChatGPT calls for each search. */
|
|
330
|
+
name: string;
|
|
331
|
+
description?: string;
|
|
332
|
+
/** Returns the items matching the typed text, which may be empty. */
|
|
333
|
+
handler: (params: {
|
|
334
|
+
query: string;
|
|
335
|
+
}, extra: ToolHandlerExtra<TAuthExtra>) => Promise<{
|
|
336
|
+
items: ResourceLink[];
|
|
337
|
+
}> | {
|
|
338
|
+
items: ResourceLink[];
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
type ToolHandler<TInput extends Record<string, StandardSchemaWithJSON>, TReturn extends {
|
|
215
342
|
content?: HandlerContent;
|
|
216
343
|
} = {
|
|
217
344
|
content?: HandlerContent;
|
|
218
|
-
}> = (args: ShapeOutput<TInput>, extra: ToolHandlerExtra) => TReturn | Promise<TReturn>;
|
|
345
|
+
}, TAuthExtra extends ExtraClaims = ExtraClaims> = (args: ShapeOutput<TInput>, extra: ToolHandlerExtra<TAuthExtra>) => TReturn | Promise<TReturn>;
|
|
219
346
|
/**
|
|
220
347
|
* Coerce a tool handler's return value into an MCP `content` array. Strings
|
|
221
348
|
* become a single `TextContent`; a single block is wrapped in an array;
|
|
@@ -236,26 +363,39 @@ declare const McpServerBaseOmitted: new (...args: ConstructorParameters<typeof M
|
|
|
236
363
|
export declare function __setBuildManifest(manifest: Record<string, {
|
|
237
364
|
file: string;
|
|
238
365
|
}>): void;
|
|
239
|
-
export declare
|
|
366
|
+
export declare function __setSkillsManifest(manifest: SkillsManifest): void;
|
|
367
|
+
/**
|
|
368
|
+
* Typed registration sugar over the MCP SDK's `McpServer`: a tool registry
|
|
369
|
+
* that carries input/output/meta shapes, view resources, per-tool security
|
|
370
|
+
* schemes, and prompt/resource registration. A {@link Skybridge} app builds
|
|
371
|
+
* one of these per request and hands it to your `handler`; chain
|
|
372
|
+
* {@link McpServer.registerTool} calls on it and return the result.
|
|
373
|
+
*
|
|
374
|
+
* The `TTools` generic accumulates each registered tool's input/output/meta
|
|
375
|
+
* shape, so `typeof app` carries enough information for view-side helpers
|
|
376
|
+
* like {@link generateHelpers} to produce fully-typed hooks.
|
|
377
|
+
*
|
|
378
|
+
* @typeParam TTools - Accumulated tool registry. Filled in by `registerTool`
|
|
379
|
+
* chaining; you almost never set this manually.
|
|
380
|
+
*
|
|
381
|
+
* @example
|
|
382
|
+
* ```ts
|
|
383
|
+
* export const app = new Skybridge({
|
|
384
|
+
* name: "my-app",
|
|
385
|
+
* version: "1.0.0",
|
|
386
|
+
* handler: (server) =>
|
|
387
|
+
* server.registerTool({
|
|
388
|
+
* name: "search",
|
|
389
|
+
* inputSchema: { query: z.string() },
|
|
390
|
+
* view: { component: "search" },
|
|
391
|
+
* }, async ({ query }) => ({ content: `Results for ${query}` })),
|
|
392
|
+
* });
|
|
393
|
+
* ```
|
|
394
|
+
*
|
|
395
|
+
* @see https://docs.skybridge.tech/api-reference/mcp-server
|
|
396
|
+
*/
|
|
397
|
+
export declare class McpServer<TTools extends Record<string, ToolDef> = Record<never, ToolDef>, TAuthExtra extends ExtraClaims = ExtraClaims> extends McpServerBaseOmitted {
|
|
240
398
|
readonly $types: McpServerTypes<TTools>;
|
|
241
|
-
/**
|
|
242
|
-
* The underlying Express app. Use this to extend the HTTP server with
|
|
243
|
-
* custom routes, middleware, or settings — e.g.
|
|
244
|
-
* `server.express.get("/health", ...)`.
|
|
245
|
-
*
|
|
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()`;
|
|
249
|
-
* after `run()`, dev-mode middleware, the `/mcp` route, and the default
|
|
250
|
-
* error handler are appended in that order.
|
|
251
|
-
*
|
|
252
|
-
* Note: Alpic Cloud only routes traffic to `/mcp` — custom routes work
|
|
253
|
-
* locally and on self-hosted deployments.
|
|
254
|
-
*/
|
|
255
|
-
readonly express: Express;
|
|
256
|
-
private customErrorMiddleware;
|
|
257
|
-
private mcpMiddlewareEntries;
|
|
258
|
-
private mcpMiddlewareApplied;
|
|
259
399
|
private claimedViews;
|
|
260
400
|
private viewMetaBuilders;
|
|
261
401
|
/**
|
|
@@ -266,41 +406,34 @@ export declare class McpServer<TTools extends Record<string, ToolDef> = Record<n
|
|
|
266
406
|
*/
|
|
267
407
|
private viewUriByPath;
|
|
268
408
|
private viteManifest;
|
|
269
|
-
private
|
|
270
|
-
private
|
|
409
|
+
private oauthEnabled;
|
|
410
|
+
private resolveResourceMetadataUrl?;
|
|
411
|
+
private readonly toolSecuritySchemes;
|
|
412
|
+
private readonly userMiddlewareEntries;
|
|
271
413
|
constructor(serverInfo: Implementation, options?: ServerOptions, skybridgeOptions?: SkybridgeServerOptions);
|
|
272
414
|
/**
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
415
|
+
* The per-tool security schemes collected during registration, keyed by tool
|
|
416
|
+
* name. Read by the OAuth layer to decide whether anonymous requests are
|
|
417
|
+
* allowed and which schemes gate a given `tools/call`.
|
|
276
418
|
*
|
|
277
|
-
*
|
|
278
|
-
* locally and on self-hosted deployments.
|
|
419
|
+
* @internal
|
|
279
420
|
*/
|
|
280
|
-
|
|
281
|
-
use(path: string, ...handlers: RequestHandler[]): this;
|
|
421
|
+
get securitySchemesByTool(): ReadonlyMap<string, SecurityScheme[] | undefined>;
|
|
282
422
|
/**
|
|
283
|
-
*
|
|
284
|
-
*
|
|
285
|
-
* thrown by tool handlers before the default error handler responds.
|
|
423
|
+
* Inject the resolver the app uses to build the protected-resource metadata
|
|
424
|
+
* URL, so tool handlers can emit in-band auth challenges.
|
|
286
425
|
*
|
|
287
|
-
* @
|
|
288
|
-
* ```ts
|
|
289
|
-
* server.useOnError((err, _req, _res, next) => {
|
|
290
|
-
* logger.error(err);
|
|
291
|
-
* next(err);
|
|
292
|
-
* });
|
|
293
|
-
* ```
|
|
426
|
+
* @internal
|
|
294
427
|
*/
|
|
295
|
-
|
|
296
|
-
|
|
428
|
+
setResourceMetadataUrlResolver(resolve: ResourceMetadataUrlResolver): this;
|
|
429
|
+
private setupSkills;
|
|
297
430
|
/** Register MCP protocol-level middleware (catch-all). */
|
|
298
|
-
mcpMiddleware(handler: McpMiddlewareFn): this;
|
|
431
|
+
mcpMiddleware(handler: McpMiddlewareFn<TAuthExtra>): this;
|
|
299
432
|
/** Register MCP protocol-level middleware for all requests (`extra` is `McpExtra`). */
|
|
300
433
|
mcpMiddleware(filter: "request", handler: (request: {
|
|
301
434
|
method: string;
|
|
302
435
|
params: Record<string, unknown>;
|
|
303
|
-
}, extra: McpExtra
|
|
436
|
+
}, extra: McpExtra<TAuthExtra>, next: () => Promise<ServerResult>) => Promise<unknown> | unknown): this;
|
|
304
437
|
/** Register MCP protocol-level middleware for all notifications (`extra` is `undefined`). */
|
|
305
438
|
mcpMiddleware(filter: "notification", handler: (request: {
|
|
306
439
|
method: string;
|
|
@@ -310,7 +443,7 @@ export declare class McpServer<TTools extends Record<string, ToolDef> = Record<n
|
|
|
310
443
|
* Register MCP protocol-level middleware for an exact method.
|
|
311
444
|
* Narrows `params`, `extra`, and `next()` result based on the method string.
|
|
312
445
|
*/
|
|
313
|
-
mcpMiddleware<M extends McpMethodString>(filter: M, handler: McpTypedMiddlewareFn<M>): this;
|
|
446
|
+
mcpMiddleware<M extends McpMethodString>(filter: M, handler: McpTypedMiddlewareFn<M, TAuthExtra>): this;
|
|
314
447
|
/**
|
|
315
448
|
* Register MCP protocol-level middleware for a wildcard pattern (e.g. `"tools/*"`).
|
|
316
449
|
* `next()` returns the union of result types for matching methods.
|
|
@@ -318,55 +451,28 @@ export declare class McpServer<TTools extends Record<string, ToolDef> = Record<n
|
|
|
318
451
|
mcpMiddleware<W extends McpWildcard>(filter: W, handler: (request: {
|
|
319
452
|
method: string;
|
|
320
453
|
params: Record<string, unknown>;
|
|
321
|
-
}, extra: McpExtraFor<W>, next: () => Promise<McpResultFor<W>>) => Promise<unknown> | unknown): this;
|
|
454
|
+
}, extra: McpExtraFor<W, TAuthExtra>, next: () => Promise<McpResultFor<W>>) => Promise<unknown> | unknown): this;
|
|
322
455
|
/**
|
|
323
456
|
* Register MCP protocol-level middleware with a method filter.
|
|
324
457
|
* Filter can be an exact method (`"tools/call"`), wildcard (`"tools/*"`),
|
|
325
458
|
* category (`"request"` | `"notification"`), or an array of those.
|
|
326
459
|
*/
|
|
327
|
-
mcpMiddleware(filter: McpMiddlewareFilter, handler: McpMiddlewareFn): this;
|
|
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
|
-
*/
|
|
337
|
-
connect(transport: Parameters<typeof McpServerBase.prototype.connect>[0]): Promise<void>;
|
|
460
|
+
mcpMiddleware(filter: McpMiddlewareFilter, handler: McpMiddlewareFn<TAuthExtra>): this;
|
|
338
461
|
/**
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
342
|
-
*
|
|
343
|
-
* we build a fresh underlying `Server` per request and share the main
|
|
344
|
-
* server's handler maps by reference. The cast is unavoidable: there's
|
|
345
|
-
* no public API to inject handler maps. `getHandlerMaps` validates the
|
|
346
|
-
* read side and fails fast on SDK field renames.
|
|
347
|
-
*/
|
|
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}.
|
|
462
|
+
* This instance's protocol-level middleware: the framework's own entries
|
|
463
|
+
* (view `_meta` on `resources/list`, version-agnostic view resolution on
|
|
464
|
+
* `resources/read`, the top-level `securitySchemes` mirror on `tools/list`)
|
|
465
|
+
* followed by the ones registered via {@link McpServer.mcpMiddleware}.
|
|
354
466
|
*
|
|
355
|
-
*
|
|
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.
|
|
467
|
+
* @internal
|
|
360
468
|
*/
|
|
361
|
-
|
|
362
|
-
fetch: (...args: unknown[]) => unknown;
|
|
363
|
-
} | Express | undefined>;
|
|
469
|
+
protocolMiddlewareEntries(): McpMiddlewareEntry[];
|
|
364
470
|
private enforceOneToolPerView;
|
|
365
471
|
private resolveViewRequestContext;
|
|
366
472
|
private registerViewResources;
|
|
367
473
|
private registerViewResource;
|
|
368
474
|
private serveLegacyAppsSdkUrl;
|
|
369
|
-
private
|
|
475
|
+
private decorateToolHandler;
|
|
370
476
|
private computeViewVersionParam;
|
|
371
477
|
private lookupViewFile;
|
|
372
478
|
private lookupDistFile;
|
|
@@ -380,6 +486,53 @@ export declare class McpServer<TTools extends Record<string, ToolDef> = Record<n
|
|
|
380
486
|
file: string;
|
|
381
487
|
}>): this;
|
|
382
488
|
private readManifest;
|
|
489
|
+
/**
|
|
490
|
+
* Register a ChatGPT file viewer, from the OpenAI MCP extensions: a tool
|
|
491
|
+
* with a file entrypoint for `extensions` and a view. ChatGPT desktop calls
|
|
492
|
+
* it with the file the user opened, as `{ file: { name, resourceUri } }`.
|
|
493
|
+
* Read and save the file from the view with `useFileResource`.
|
|
494
|
+
*
|
|
495
|
+
* @example
|
|
496
|
+
* ```ts
|
|
497
|
+
* server.registerFileViewer(
|
|
498
|
+
* {
|
|
499
|
+
* name: "part-viewer",
|
|
500
|
+
* title: "Part Viewer",
|
|
501
|
+
* extensions: [".stl", ".step"],
|
|
502
|
+
* view: { component: "part-viewer" },
|
|
503
|
+
* },
|
|
504
|
+
* async ({ file }) => ({ structuredContent: { name: file.name } }),
|
|
505
|
+
* );
|
|
506
|
+
* ```
|
|
507
|
+
*
|
|
508
|
+
* @see https://docs.skybridge.tech/api-reference/register-file-viewer
|
|
509
|
+
*/
|
|
510
|
+
registerFileViewer<TName extends string, TReturn extends {
|
|
511
|
+
content?: HandlerContent;
|
|
512
|
+
}>(config: OpenAIFileViewerConfig<TName>, cb: ToolHandler<FileEntrypointInput, TReturn, TAuthExtra>): AddTool<TTools, TName, FileEntrypointInput, ExtractStructuredContent<TReturn>, ExtractMeta<TReturn>, TAuthExtra>;
|
|
513
|
+
/**
|
|
514
|
+
* Register the composer at-mention search for ChatGPT, from the OpenAI MCP
|
|
515
|
+
* extensions. When the user types `@` and your app name, ChatGPT calls
|
|
516
|
+
* `handler` with the typed text and lists the returned resource links.
|
|
517
|
+
* Skybridge registers it as a tool hidden from the model.
|
|
518
|
+
*
|
|
519
|
+
* @example
|
|
520
|
+
* ```ts
|
|
521
|
+
* server.registerMentions({
|
|
522
|
+
* name: "search_parts",
|
|
523
|
+
* handler: async ({ query }) => ({
|
|
524
|
+
* items: findParts(query).map((part) => ({
|
|
525
|
+
* type: "resource_link",
|
|
526
|
+
* uri: `parts://${part.id}`,
|
|
527
|
+
* name: part.name,
|
|
528
|
+
* })),
|
|
529
|
+
* }),
|
|
530
|
+
* });
|
|
531
|
+
* ```
|
|
532
|
+
*
|
|
533
|
+
* @see https://docs.skybridge.tech/api-reference/register-mentions
|
|
534
|
+
*/
|
|
535
|
+
registerMentions(config: OpenAIMentionsConfig<TAuthExtra>): this;
|
|
383
536
|
/**
|
|
384
537
|
* Register a tool. Pass a `config` describing the tool (name, schemas,
|
|
385
538
|
* optional {@link ViewConfig}, optional {@link ToolMeta}) and a handler that
|
|
@@ -409,11 +562,13 @@ export declare class McpServer<TTools extends Record<string, ToolDef> = Record<n
|
|
|
409
562
|
*
|
|
410
563
|
* @see https://docs.skybridge.tech/api-reference/register-tool
|
|
411
564
|
*/
|
|
412
|
-
registerTool<TName extends string, InputArgs extends
|
|
565
|
+
registerTool<TName extends string, InputArgs extends Record<string, StandardSchemaWithJSON>, TReturn extends {
|
|
413
566
|
content?: HandlerContent;
|
|
414
567
|
}>(config: ToolConfig<InputArgs> & {
|
|
415
568
|
name: TName;
|
|
416
|
-
}, cb: ToolHandler<InputArgs, TReturn>): AddTool<TTools, TName, InputArgs, ExtractStructuredContent<TReturn>, ExtractMeta<TReturn
|
|
417
|
-
registerTool<InputArgs extends
|
|
569
|
+
}, cb: ToolHandler<InputArgs, TReturn, TAuthExtra>): AddTool<TTools, TName, InputArgs, ExtractStructuredContent<TReturn>, ExtractMeta<TReturn>, TAuthExtra>;
|
|
570
|
+
registerTool<InputArgs extends Record<string, StandardSchemaWithJSON>>(config: ToolConfig<InputArgs>, cb: ToolHandler<InputArgs, {
|
|
571
|
+
content?: HandlerContent;
|
|
572
|
+
}, TAuthExtra>): this;
|
|
418
573
|
}
|
|
419
574
|
export {};
|