@bleedingdev/modern-js-mcp-apps 0.0.0-stage → 3.11.3-ultramodern.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +68 -2
- package/dist/cjs/cli.cjs +471 -0
- package/dist/cjs/server-plugin.cjs +79 -0
- package/dist/cjs/server.cjs +317 -0
- package/dist/esm/mf-entry.mjs +75 -0
- package/dist/esm/react.mjs +80 -0
- package/dist/esm-node/3~0.mjs +81 -0
- package/dist/esm-node/cli.mjs +360 -0
- package/dist/esm-node/server-plugin.mjs +31 -0
- package/dist/esm-node/server.mjs +216 -0
- package/dist/types/cli/build.d.ts +23 -0
- package/dist/types/cli/index.d.ts +16 -0
- package/dist/types/cli/server-plugin.d.ts +6 -0
- package/dist/types/manifest.d.ts +38 -0
- package/dist/types/server/context.d.ts +2 -0
- package/dist/types/server/index.d.ts +34 -0
- package/dist/types/server/resources.d.ts +12 -0
- package/dist/types/ui/mf-entry.d.ts +1 -0
- package/dist/types/ui/mf.d.ts +10 -0
- package/dist/types/ui/react.d.ts +25 -0
- package/dist/types/ui/state.d.ts +13 -0
- package/package.json +109 -4
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { McpUiResourceMeta } from '@modelcontextprotocol/ext-apps';
|
|
2
|
+
export type UiMetadata = McpUiResourceMeta;
|
|
3
|
+
export interface McpViewsConfig extends UiMetadata {
|
|
4
|
+
/** Default deployed MF remote for expose views. Individual views may override it. */
|
|
5
|
+
remote?: string;
|
|
6
|
+
/** A component path, an expose of this application, or an expose of a deployed remote. */
|
|
7
|
+
views: Record<string, string | {
|
|
8
|
+
expose: string;
|
|
9
|
+
remote?: string;
|
|
10
|
+
}>;
|
|
11
|
+
}
|
|
12
|
+
export interface UiManifest {
|
|
13
|
+
version: 1;
|
|
14
|
+
assetBase: string;
|
|
15
|
+
remotes: Record<string, {
|
|
16
|
+
entry: string;
|
|
17
|
+
shell: string;
|
|
18
|
+
}>;
|
|
19
|
+
views: Record<string, ({
|
|
20
|
+
html: string;
|
|
21
|
+
} | {
|
|
22
|
+
remote: string;
|
|
23
|
+
expose: string;
|
|
24
|
+
}) & {
|
|
25
|
+
ui: UiMetadata;
|
|
26
|
+
}>;
|
|
27
|
+
}
|
|
28
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
29
|
+
export declare function validateUiMetadata(value: unknown): asserts value is UiMetadata;
|
|
30
|
+
export declare function validateViewsConfig(value: unknown): asserts value is McpViewsConfig;
|
|
31
|
+
/**
|
|
32
|
+
* A deployed MF remote must be a manifest URL. The MF runtime finds the
|
|
33
|
+
* container through the manifest only for `.json` entries. Any other entry
|
|
34
|
+
* would need the remote's real MF name.
|
|
35
|
+
*/
|
|
36
|
+
export declare function assertRemoteManifest(remote: string): void;
|
|
37
|
+
export declare function assertHttpUrl(source: string): URL;
|
|
38
|
+
export declare function validateUiManifest(value: unknown): asserts value is UiManifest;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
2
|
+
export type { UiManifest, UiMetadata } from '../manifest.js';
|
|
3
|
+
export type { RegisterUiOptions } from './resources.js';
|
|
4
|
+
export { registerUiResources } from './resources.js';
|
|
5
|
+
export type McpServerFactory = (request: Request) => McpServer | Promise<McpServer>;
|
|
6
|
+
export interface FetchHandlerOptions {
|
|
7
|
+
allowedOrigins?: string[];
|
|
8
|
+
onError?: (error: Error) => void;
|
|
9
|
+
}
|
|
10
|
+
/** The parts of the Hono request context used by BFF handlers. */
|
|
11
|
+
export interface HonoLikeContext {
|
|
12
|
+
req: {
|
|
13
|
+
raw: Request;
|
|
14
|
+
};
|
|
15
|
+
get(key: 'locals'): Record<string, unknown> | undefined;
|
|
16
|
+
}
|
|
17
|
+
export interface BffHandlerOptions extends FetchHandlerOptions {
|
|
18
|
+
/** Returns the current Hono context. Defaults to `useHonoContext` from `@modern-js/server-runtime`. */
|
|
19
|
+
useContext?: () => HonoLikeContext;
|
|
20
|
+
}
|
|
21
|
+
/** Stateless HTTP adapter. Tool registration and validation belong to the SDK. */
|
|
22
|
+
export declare function createFetchHandler(createServer: McpServerFactory, options?: FetchHandlerOptions): (request: Request) => Promise<Response>;
|
|
23
|
+
/** Export these functions from api/lambda/mcp.ts to expose /api/mcp. */
|
|
24
|
+
export declare function createBffHandlers(createServer: McpServerFactory, options?: BffHandlerOptions): {
|
|
25
|
+
POST: (input: {
|
|
26
|
+
data?: unknown;
|
|
27
|
+
}) => Promise<Response>;
|
|
28
|
+
GET: (input: {
|
|
29
|
+
data?: unknown;
|
|
30
|
+
}) => Promise<Response>;
|
|
31
|
+
DELETE: (input: {
|
|
32
|
+
data?: unknown;
|
|
33
|
+
}) => Promise<Response>;
|
|
34
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
2
|
+
export interface RegisterUiOptions {
|
|
3
|
+
request?: Request;
|
|
4
|
+
/** Runtime mode. Standalone services default to production. */
|
|
5
|
+
mode?: 'development' | 'production';
|
|
6
|
+
/** Manifest file path or HTTP(S) URL. Provided by the Modern.js server plugin or explicitly by the caller. */
|
|
7
|
+
manifest?: string | URL;
|
|
8
|
+
/** Public deployment root, including any path prefix. */
|
|
9
|
+
assetBase?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function requestOrigin(request: Request): string;
|
|
12
|
+
export declare function registerUiResources(server: Pick<McpServer, 'registerResource'>, options?: RegisterUiOptions): Promise<Record<string, string>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as JsxDevRuntime from 'react/jsx-dev-runtime';
|
|
2
|
+
export interface MfViewConfig {
|
|
3
|
+
name: string;
|
|
4
|
+
entry: string;
|
|
5
|
+
expose: string;
|
|
6
|
+
/** The view name, reported to the host as the app name like local cards. */
|
|
7
|
+
view: string;
|
|
8
|
+
}
|
|
9
|
+
/** Executed in the application build, so the shell and exposes share its React. */
|
|
10
|
+
export declare function createMfView(config: MfViewConfig): () => JsxDevRuntime.JSX.Element;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { App } from '@modelcontextprotocol/ext-apps';
|
|
2
|
+
import { type UseAppOptions } from '@modelcontextprotocol/ext-apps/react';
|
|
3
|
+
import { type ComponentType } from 'react';
|
|
4
|
+
export type { App } from '@modelcontextprotocol/ext-apps';
|
|
5
|
+
export { useApp, useDocumentTheme, useHostFonts, useHostStyles, useHostStyleVariables, } from '@modelcontextprotocol/ext-apps/react';
|
|
6
|
+
export type McpCapabilities = NonNullable<UseAppOptions['capabilities']>;
|
|
7
|
+
export type McpViewProps<T extends object = Record<string, unknown>> = Omit<T, 'mcpApp'> & {
|
|
8
|
+
mcpApp: App;
|
|
9
|
+
};
|
|
10
|
+
export declare function useMcpApp(options: Omit<UseAppOptions, 'onAppCreated'>): {
|
|
11
|
+
app: App | null;
|
|
12
|
+
isConnected: boolean;
|
|
13
|
+
error: Error | null;
|
|
14
|
+
result?: import("@modelcontextprotocol/server").CallToolResult;
|
|
15
|
+
cancelled: boolean;
|
|
16
|
+
viewProps: Record<string, unknown>;
|
|
17
|
+
};
|
|
18
|
+
export declare function createMcpView<P extends object>(View: ComponentType<P>, appInfo: {
|
|
19
|
+
name: string;
|
|
20
|
+
version: string;
|
|
21
|
+
}, capabilities?: McpCapabilities): () => import("react").DetailedReactHTMLElement<{
|
|
22
|
+
role: "alert";
|
|
23
|
+
}, HTMLElement> | import("react").DetailedReactHTMLElement<{
|
|
24
|
+
role: "status";
|
|
25
|
+
}, HTMLElement> | import("react").ReactElement<P, string | import("react").JSXElementConstructor<any>> | null;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CallToolResult } from '@modelcontextprotocol/server';
|
|
2
|
+
export interface ViewState {
|
|
3
|
+
result?: CallToolResult;
|
|
4
|
+
cancelled: boolean;
|
|
5
|
+
}
|
|
6
|
+
export type ViewEvent = {
|
|
7
|
+
type: 'input' | 'cancelled' | 'teardown';
|
|
8
|
+
} | {
|
|
9
|
+
type: 'result';
|
|
10
|
+
result: CallToolResult;
|
|
11
|
+
};
|
|
12
|
+
export declare function reduceViewState(_state: ViewState, event: ViewEvent): ViewState;
|
|
13
|
+
export declare function resultProps(result?: CallToolResult): Record<string, unknown>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,111 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bleedingdev/modern-js-mcp-apps",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "3.11.3-ultramodern.2",
|
|
4
|
+
"description": "Build, serve and render MCP Apps in Modern.js applications",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://github.com/ultramodernjs/ultramodern.js#readme",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/ultramodernjs/ultramodern.js.git",
|
|
10
|
+
"directory": "packages/toolkit/mcp-apps"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"sideEffects": [
|
|
17
|
+
"./src/ui/mf-entry.ts",
|
|
18
|
+
"./dist/esm/mf-entry.mjs"
|
|
19
|
+
],
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=20"
|
|
22
|
+
},
|
|
23
|
+
"exports": {
|
|
24
|
+
"./cli": {
|
|
25
|
+
"types": "./dist/types/cli/index.d.ts",
|
|
26
|
+
"import": "./dist/esm-node/cli.mjs",
|
|
27
|
+
"require": "./dist/cjs/cli.cjs"
|
|
28
|
+
},
|
|
29
|
+
"./server-plugin": {
|
|
30
|
+
"types": "./dist/types/cli/server-plugin.d.ts",
|
|
31
|
+
"import": "./dist/esm-node/server-plugin.mjs",
|
|
32
|
+
"require": "./dist/cjs/server-plugin.cjs"
|
|
33
|
+
},
|
|
34
|
+
"./server": {
|
|
35
|
+
"types": "./dist/types/server/index.d.ts",
|
|
36
|
+
"import": "./dist/esm-node/server.mjs",
|
|
37
|
+
"require": "./dist/cjs/server.cjs"
|
|
38
|
+
},
|
|
39
|
+
"./react": {
|
|
40
|
+
"types": "./dist/types/ui/react.d.ts",
|
|
41
|
+
"import": "./dist/esm/react.mjs",
|
|
42
|
+
"default": "./dist/esm/react.mjs"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@rsbuild/core": "2.3.2"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"@modelcontextprotocol/ext-apps": "^2.0.4",
|
|
50
|
+
"@modelcontextprotocol/server": "^2.3.1",
|
|
51
|
+
"@modern-js/server-runtime": "3.11.3-ultramodern.2",
|
|
52
|
+
"@module-federation/enhanced": "npm:@bleedingdev/mf-enhanced@2.9.3",
|
|
53
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
54
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
55
|
+
},
|
|
56
|
+
"peerDependenciesMeta": {
|
|
57
|
+
"@modern-js/server-runtime": {
|
|
58
|
+
"optional": true
|
|
59
|
+
},
|
|
60
|
+
"@module-federation/enhanced": {
|
|
61
|
+
"optional": true
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"@modelcontextprotocol/client": "2.3.1",
|
|
66
|
+
"@modelcontextprotocol/ext-apps": "2.0.4",
|
|
67
|
+
"@modelcontextprotocol/server": "2.3.1",
|
|
68
|
+
"@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.11.3-ultramodern.2",
|
|
69
|
+
"@modern-js/server-runtime": "npm:@bleedingdev/modern-js-server-runtime@3.11.3-ultramodern.2",
|
|
70
|
+
"@module-federation/enhanced": "npm:@bleedingdev/mf-enhanced@2.9.3",
|
|
71
|
+
"@rslib/core": "1.0.3",
|
|
72
|
+
"@scripts/rstest-config": "2.66.7",
|
|
73
|
+
"@types/node": "^26.6.5",
|
|
74
|
+
"@types/react": "^19.3.0",
|
|
75
|
+
"@types/react-dom": "^19.3.0",
|
|
76
|
+
"react": "^19.3.1",
|
|
77
|
+
"react-dom": "^19.3.1",
|
|
78
|
+
"typescript": "7.0.2",
|
|
79
|
+
"zod": "^4.2.0"
|
|
80
|
+
},
|
|
81
|
+
"publishConfig": {
|
|
82
|
+
"access": "public"
|
|
83
|
+
},
|
|
84
|
+
"typesVersions": {
|
|
85
|
+
"*": {
|
|
86
|
+
"cli": [
|
|
87
|
+
"./dist/types/cli/index.d.ts"
|
|
88
|
+
],
|
|
89
|
+
"server-plugin": [
|
|
90
|
+
"./dist/types/cli/server-plugin.d.ts"
|
|
91
|
+
],
|
|
92
|
+
"server": [
|
|
93
|
+
"./dist/types/server/index.d.ts"
|
|
94
|
+
],
|
|
95
|
+
"react": [
|
|
96
|
+
"./dist/types/ui/react.d.ts"
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
"scripts": {
|
|
101
|
+
"build": "rslib build",
|
|
102
|
+
"test": "rstest",
|
|
103
|
+
"typecheck": "node ../../../scripts/with-effect-tsrs.mjs --project tsconfig.json --noEmit"
|
|
104
|
+
},
|
|
105
|
+
"bugs": {
|
|
106
|
+
"url": "https://github.com/ultramodernjs/ultramodern.js/issues"
|
|
107
|
+
},
|
|
108
|
+
"ultramodern": {
|
|
109
|
+
"sourceName": "@modern-js/mcp-apps"
|
|
110
|
+
}
|
|
111
|
+
}
|