@mcp-b/global 1.5.0 → 1.6.1
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 +334 -1553
- package/dist/index.d.ts +30 -81
- package/dist/index.d.ts.map +1 -1
- package/dist/index.iife.js +6 -17
- package/dist/index.js +110 -1835
- package/dist/index.js.map +1 -1
- package/package.json +11 -17
- package/dist/testing.d.ts +0 -71
- package/dist/testing.d.ts.map +0 -1
- package/dist/testing.js +0 -48
- package/dist/testing.js.map +0 -1
- package/dist/types-DemXxUoc.d.ts +0 -1036
- package/dist/types-DemXxUoc.d.ts.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,91 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { z } from "zod";
|
|
1
|
+
import { IframeChildTransportOptions, TabServerTransportOptions } from "@mcp-b/transports";
|
|
3
2
|
|
|
4
|
-
//#region src/
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
interface TransportConfiguration {
|
|
5
|
+
tabServer?: Partial<TabServerTransportOptions> | false;
|
|
6
|
+
iframeServer?: Partial<IframeChildTransportOptions> | false;
|
|
7
|
+
}
|
|
8
|
+
type NativeModelContextBehavior = 'preserve' | 'patch';
|
|
9
|
+
interface WebModelContextInitOptions {
|
|
10
|
+
transport?: TransportConfiguration;
|
|
11
|
+
autoInitialize?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Behavior when navigator.modelContext already exists.
|
|
14
|
+
* - 'preserve' (default): wrap native with BrowserMcpServer, mirroring
|
|
15
|
+
* core operations to the native object while extending with prompts,
|
|
16
|
+
* resources, and other MCP capabilities.
|
|
17
|
+
* - 'patch': same wrapping behavior (kept for backward compatibility).
|
|
18
|
+
*/
|
|
19
|
+
nativeModelContextBehavior?: NativeModelContextBehavior;
|
|
20
|
+
/**
|
|
21
|
+
* Forwarded to @mcp-b/webmcp-polyfill when polyfill installation is needed.
|
|
22
|
+
* - true or 'if-missing' (default): install modelContextTesting only when missing.
|
|
23
|
+
* - 'always': replace existing modelContextTesting.
|
|
24
|
+
* - false: do not install modelContextTesting.
|
|
25
|
+
*/
|
|
26
|
+
installTestingShim?: boolean | 'always' | 'if-missing';
|
|
27
|
+
}
|
|
5
28
|
declare global {
|
|
6
29
|
interface Window {
|
|
7
30
|
__webModelContextOptions?: WebModelContextInitOptions;
|
|
8
31
|
}
|
|
9
32
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
* Automatically detects and uses native Chromium implementation if available.
|
|
14
|
-
*
|
|
15
|
-
* @param {WebModelContextInitOptions} [options] - Configuration options
|
|
16
|
-
* @throws {Error} If initialization fails
|
|
17
|
-
* @example
|
|
18
|
-
* ```typescript
|
|
19
|
-
* import { initializeWebModelContext } from '@mcp-b/global';
|
|
20
|
-
*
|
|
21
|
-
* initializeWebModelContext({
|
|
22
|
-
* transport: {
|
|
23
|
-
* tabServer: {
|
|
24
|
-
* allowedOrigins: ['https://example.com']
|
|
25
|
-
* }
|
|
26
|
-
* }
|
|
27
|
-
* });
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
33
|
+
//# sourceMappingURL=types.d.ts.map
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/global.d.ts
|
|
30
36
|
declare function initializeWebModelContext(options?: WebModelContextInitOptions): void;
|
|
31
|
-
/**
|
|
32
|
-
* Cleans up the Web Model Context API.
|
|
33
|
-
* Closes all MCP servers and removes API from window.navigator.
|
|
34
|
-
* Useful for testing and hot module replacement.
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* ```typescript
|
|
38
|
-
* import { cleanupWebModelContext } from '@mcp-b/global';
|
|
39
|
-
*
|
|
40
|
-
* cleanupWebModelContext();
|
|
41
|
-
* ```
|
|
42
|
-
*/
|
|
43
37
|
declare function cleanupWebModelContext(): void;
|
|
44
38
|
//#endregion
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* @license
|
|
48
|
-
* Copyright 2025 Google LLC
|
|
49
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
50
|
-
*/
|
|
51
|
-
/**
|
|
52
|
-
* Logger interface with standard log levels
|
|
53
|
-
*
|
|
54
|
-
* All methods accept the same argument patterns as their console.* equivalents,
|
|
55
|
-
* supporting format strings, object inspection, and multiple arguments.
|
|
56
|
-
*/
|
|
57
|
-
interface Logger {
|
|
58
|
-
/** Debug-level logging (disabled by default, enable via WEBMCP_DEBUG) */
|
|
59
|
-
debug(message?: unknown, ...optionalParams: unknown[]): void;
|
|
60
|
-
/** Info-level logging (disabled by default, enable via WEBMCP_DEBUG) */
|
|
61
|
-
info(message?: unknown, ...optionalParams: unknown[]): void;
|
|
62
|
-
/** Warning-level logging (enabled by default, not gated by WEBMCP_DEBUG) */
|
|
63
|
-
warn(message?: unknown, ...optionalParams: unknown[]): void;
|
|
64
|
-
/** Error-level logging (enabled by default, not gated by WEBMCP_DEBUG) */
|
|
65
|
-
error(message?: unknown, ...optionalParams: unknown[]): void;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Create a namespaced logger
|
|
69
|
-
*
|
|
70
|
-
* Uses .bind() to prepend namespace prefixes to console methods without manual
|
|
71
|
-
* string concatenation. Debug enablement is determined at logger creation time
|
|
72
|
-
* for performance - changes to localStorage after creation won't affect existing
|
|
73
|
-
* loggers. Refresh the page to apply new WEBMCP_DEBUG settings.
|
|
74
|
-
*
|
|
75
|
-
* @param namespace - Namespace for the logger (e.g., 'WebModelContext', 'NativeAdapter')
|
|
76
|
-
* @returns Logger instance with debug, info, warn, error methods
|
|
77
|
-
*
|
|
78
|
-
* @example
|
|
79
|
-
* ```typescript
|
|
80
|
-
* const logger = createLogger('WebModelContext');
|
|
81
|
-
* logger.debug('Tool registered:', toolName); // Only shown if WEBMCP_DEBUG includes 'WebModelContext'
|
|
82
|
-
* logger.error('Execution failed:', error); // Always enabled
|
|
83
|
-
* ```
|
|
84
|
-
*/
|
|
85
|
-
declare function createLogger(namespace: string): Logger;
|
|
86
|
-
//#endregion
|
|
87
|
-
//#region src/validation.d.ts
|
|
88
|
-
declare function zodToJsonSchema(schema: ZodSchemaObject): InputSchema;
|
|
89
|
-
//#endregion
|
|
90
|
-
export { CallToolResult, CreateMessageRequest, CreateMessageResult, ElicitRequest, ElicitResult, ElicitationFormParams, ElicitationParams, ElicitationResult, ElicitationUrlParams, InputSchema, InternalModelContext, InterruptionMetadata, MCPBridge, ModelContext, ModelContextInput, ModelContextTesting, NavigationMetadata, Prompt, PromptDescriptor, PromptMessage, RegistrationHandle, Resource, ResourceContents, ResourceDescriptor, ResourceTemplate, ResourceTemplateInfo, SamplingRequestParams, SamplingResult, ToolAnnotations, ToolCallEvent, ToolDescriptor, ToolInfo, ToolListItem, ToolResponse, TransportConfiguration, ValidatedPromptDescriptor, ValidatedResourceDescriptor, ValidatedToolDescriptor, WebModelContextInitOptions, ZodSchemaObject, cleanupWebModelContext, createLogger, initializeWebModelContext, zodToJsonSchema };
|
|
39
|
+
export { type NativeModelContextBehavior, type TransportConfiguration, type WebModelContextInitOptions, cleanupWebModelContext, initializeWebModelContext };
|
|
91
40
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/global.ts"],"sourcesContent":[],"mappings":";;;UAEiB,sBAAA;cACH,QAAQ;EADL,YAAA,CAAA,EAEA,OAFA,CAEQ,2BAFc,CAAA,GAAA,KAAA;;AACzB,KAIF,0BAAA,GAJE,UAAA,GAAA,OAAA;AACW,UAKR,0BAAA,CALQ;EAAR,SAAA,CAAA,EAMH,sBANG;EAAO,cAAA,CAAA,EAAA,OAAA;EAGZ;AAEZ;AAkBC;;;;;+BAR8B;;;AC4K/B;AAwCA;;;;;;;+BDxM+B;;;;;;iBCgKf,yBAAA,WAAoC;iBAwCpC,sBAAA,CAAA"}
|