@mcp-b/global 0.0.0-beta-20260109203913 → 0.0.0
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 +37 -0
- package/dist/index.d.ts +43 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.iife.js +4 -30
- package/dist/index.js +155 -119
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1011,6 +1011,43 @@ if ("modelContext" in navigator) {
|
|
|
1011
1011
|
|
|
1012
1012
|
## 🐛 Debugging
|
|
1013
1013
|
|
|
1014
|
+
### Enable Debug Logging
|
|
1015
|
+
|
|
1016
|
+
The @mcp-b/global library includes a lightweight logging system that can be enabled in the browser console. By default, the console is kept clean (only errors and warnings are shown). You can enable detailed debug logging when troubleshooting:
|
|
1017
|
+
|
|
1018
|
+
```javascript
|
|
1019
|
+
// Enable all debug logging
|
|
1020
|
+
localStorage.setItem('WEBMCP_DEBUG', '*');
|
|
1021
|
+
|
|
1022
|
+
// Enable specific namespaces
|
|
1023
|
+
localStorage.setItem('WEBMCP_DEBUG', 'WebModelContext');
|
|
1024
|
+
localStorage.setItem('WEBMCP_DEBUG', 'NativeAdapter,MCPBridge');
|
|
1025
|
+
|
|
1026
|
+
// Refresh the page to apply changes
|
|
1027
|
+
location.reload();
|
|
1028
|
+
```
|
|
1029
|
+
|
|
1030
|
+
To disable debug logging:
|
|
1031
|
+
|
|
1032
|
+
```javascript
|
|
1033
|
+
localStorage.removeItem('WEBMCP_DEBUG');
|
|
1034
|
+
location.reload();
|
|
1035
|
+
```
|
|
1036
|
+
|
|
1037
|
+
**Available Namespaces:**
|
|
1038
|
+
- `WebModelContext` - Main polyfill implementation
|
|
1039
|
+
- `NativeAdapter` - Native Chromium API adapter
|
|
1040
|
+
- `MCPBridge` - MCP server and transport setup
|
|
1041
|
+
- `ModelContextTesting` - Testing API operations
|
|
1042
|
+
|
|
1043
|
+
**Log Levels:**
|
|
1044
|
+
- **Error** (always shown): Critical failures and exceptions
|
|
1045
|
+
- **Warn** (always shown): Compatibility warnings and potential issues
|
|
1046
|
+
- **Info** (debug mode only): Initialization and setup progress
|
|
1047
|
+
- **Debug** (debug mode only): Detailed operation traces
|
|
1048
|
+
|
|
1049
|
+
### Access Internal Bridge
|
|
1050
|
+
|
|
1014
1051
|
In development mode, access the internal bridge:
|
|
1015
1052
|
|
|
1016
1053
|
```javascript
|
package/dist/index.d.ts
CHANGED
|
@@ -1047,6 +1047,48 @@ declare function initializeWebModelContext(options?: WebModelContextInitOptions)
|
|
|
1047
1047
|
*/
|
|
1048
1048
|
declare function cleanupWebModelContext(): void;
|
|
1049
1049
|
//#endregion
|
|
1050
|
+
//#region src/logger.d.ts
|
|
1051
|
+
/**
|
|
1052
|
+
* @license
|
|
1053
|
+
* Copyright 2025 Google LLC
|
|
1054
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
1055
|
+
*/
|
|
1056
|
+
/**
|
|
1057
|
+
* Logger interface with standard log levels
|
|
1058
|
+
*
|
|
1059
|
+
* All methods accept the same argument patterns as their console.* equivalents,
|
|
1060
|
+
* supporting format strings, object inspection, and multiple arguments.
|
|
1061
|
+
*/
|
|
1062
|
+
interface Logger {
|
|
1063
|
+
/** Debug-level logging (disabled by default, enable via WEBMCP_DEBUG) */
|
|
1064
|
+
debug(message?: unknown, ...optionalParams: unknown[]): void;
|
|
1065
|
+
/** Info-level logging (disabled by default, enable via WEBMCP_DEBUG) */
|
|
1066
|
+
info(message?: unknown, ...optionalParams: unknown[]): void;
|
|
1067
|
+
/** Warning-level logging (enabled by default, not gated by WEBMCP_DEBUG) */
|
|
1068
|
+
warn(message?: unknown, ...optionalParams: unknown[]): void;
|
|
1069
|
+
/** Error-level logging (enabled by default, not gated by WEBMCP_DEBUG) */
|
|
1070
|
+
error(message?: unknown, ...optionalParams: unknown[]): void;
|
|
1071
|
+
}
|
|
1072
|
+
/**
|
|
1073
|
+
* Create a namespaced logger
|
|
1074
|
+
*
|
|
1075
|
+
* Uses .bind() to prepend namespace prefixes to console methods without manual
|
|
1076
|
+
* string concatenation. Debug enablement is determined at logger creation time
|
|
1077
|
+
* for performance - changes to localStorage after creation won't affect existing
|
|
1078
|
+
* loggers. Refresh the page to apply new WEBMCP_DEBUG settings.
|
|
1079
|
+
*
|
|
1080
|
+
* @param namespace - Namespace for the logger (e.g., 'WebModelContext', 'NativeAdapter')
|
|
1081
|
+
* @returns Logger instance with debug, info, warn, error methods
|
|
1082
|
+
*
|
|
1083
|
+
* @example
|
|
1084
|
+
* ```typescript
|
|
1085
|
+
* const logger = createLogger('WebModelContext');
|
|
1086
|
+
* logger.debug('Tool registered:', toolName); // Only shown if WEBMCP_DEBUG includes 'WebModelContext'
|
|
1087
|
+
* logger.error('Execution failed:', error); // Always enabled
|
|
1088
|
+
* ```
|
|
1089
|
+
*/
|
|
1090
|
+
declare function createLogger(namespace: string): Logger;
|
|
1091
|
+
//#endregion
|
|
1050
1092
|
//#region src/validation.d.ts
|
|
1051
1093
|
/**
|
|
1052
1094
|
* Convert Zod schema object to JSON Schema
|
|
@@ -1057,5 +1099,5 @@ declare function cleanupWebModelContext(): void;
|
|
|
1057
1099
|
*/
|
|
1058
1100
|
declare function zodToJsonSchema(schema: Record<string, z.ZodTypeAny>): InputSchema;
|
|
1059
1101
|
//#endregion
|
|
1060
|
-
export { type CallToolResult, type CreateMessageRequest, type CreateMessageResult, type ElicitRequest, type ElicitResult, ElicitationFormParams, ElicitationParams, ElicitationResult, ElicitationUrlParams, InputSchema, InternalModelContext, InterruptionMetadata, MCPBridge, ModelContext, ModelContextInput, ModelContextTesting, NavigationMetadata, type Prompt, PromptDescriptor, type PromptMessage, RegistrationHandle, type Resource, type ResourceContents, ResourceDescriptor, type ResourceTemplate, ResourceTemplateInfo, SamplingRequestParams, SamplingResult, type ToolAnnotations, ToolCallEvent, ToolDescriptor, ToolInfo, ToolListItem, ToolResponse, TransportConfiguration, ValidatedPromptDescriptor, ValidatedResourceDescriptor, ValidatedToolDescriptor, WebModelContextInitOptions, ZodSchemaObject, cleanupWebModelContext, initializeWebModelContext, zodToJsonSchema };
|
|
1102
|
+
export { type CallToolResult, type CreateMessageRequest, type CreateMessageResult, type ElicitRequest, type ElicitResult, ElicitationFormParams, ElicitationParams, ElicitationResult, ElicitationUrlParams, InputSchema, InternalModelContext, InterruptionMetadata, MCPBridge, ModelContext, ModelContextInput, ModelContextTesting, NavigationMetadata, type Prompt, PromptDescriptor, type PromptMessage, RegistrationHandle, type Resource, type ResourceContents, ResourceDescriptor, type ResourceTemplate, ResourceTemplateInfo, SamplingRequestParams, SamplingResult, type ToolAnnotations, ToolCallEvent, ToolDescriptor, ToolInfo, ToolListItem, ToolResponse, TransportConfiguration, ValidatedPromptDescriptor, ValidatedResourceDescriptor, ValidatedToolDescriptor, WebModelContextInitOptions, ZodSchemaObject, cleanupWebModelContext, createLogger, initializeWebModelContext, zodToJsonSchema };
|
|
1061
1103
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/global.ts","../src/validation.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAkoBA;;;;;;;;;;;;;;AAoCA;;;;;AAOmB,UA7jBF,WAAA,CA6jBE;EAAO;EAWT,IAAA,EAAA,MAAA;EAMF;EAEE,UAAA,CAAA,EA5kBF,MA4kBE,CAAA,MAAA,EAAA;IAED;IAAe,IAAA,EAAA,MAAA;IAOd;IAeA,WAAA,CAAA,EAAA,MAAkB;IAalB;IAOT,CAAA,GAAA,EAAA,MAAA,CAAA,EAAA,OAAA;EALI,CAAA,CAAA;EAkBI;EASH,QAAA,CAAA,EAAA,MAAA,EAAA;EAAM;EAOF,CAAA,GAAA,EAAA,MAAA,CAAA,EAAA,OAAc;AAc/B;AA+BA;AAeA;AAKA;AAeA;;;;;AAuBA;;;;;AAqBA;;;AAgB2C,KAhwB/B,eA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