@univerjs-pro/mcp 0.10.7 → 0.10.8

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.
@@ -15,7 +15,6 @@ export declare enum MCPConnectionStatus {
15
15
  */
16
16
  export declare enum MCPConnectionError {
17
17
  NONE = "NONE",
18
- MISSING_API_KEY = "MISSING_API_KEY",
19
18
  INVALID_API_KEY = "INVALID_API_KEY",
20
19
  SESSION_ID_OCCUPIED = "SESSION_ID_OCCUPIED",
21
20
  NETWORK_ERROR = "NETWORK_ERROR",
@@ -36,14 +35,11 @@ export interface IUniverMCPConfig {
36
35
  */
37
36
  mcpServerUrl?: string;
38
37
  /**
39
- * @deprecated
40
- * API key. Do NOT configure apiKey directly in code—this is dangerous and insecure. The API key should only be set by the user in the UI and stored securely (e.g., in localStorage).
38
+ * Session ID for the connection. Can be a string or a function that returns a string or a Promise that resolves to a string.
39
+ * Default is 'default', if sessionId is occupied, client will try to reconnect with a random sessionId.
40
+ * Note: Each session ID can only be used by one client at a time. If a session ID is already in use, the server will reject the connection.
41
41
  */
42
- apiKey?: string;
43
- /**
44
- * Univer session ID. Default is 'default'. Currently not configurable.
45
- */
46
- sessionId?: string;
42
+ sessionId?: string | (() => string) | (() => Promise<string>);
47
43
  /**
48
44
  * Maximum number of reconnection attempts. Default is 10.
49
45
  */
@@ -52,5 +48,16 @@ export interface IUniverMCPConfig {
52
48
  * Reconnection interval in milliseconds. Default is 6000.
53
49
  */
54
50
  retryInterval?: number;
51
+ /**
52
+ * @experimental
53
+ * Enable dynamic tool execution feature. Default is false.
54
+ * Warning: Enabling this feature may have security implications. Ensure that the MCP server is trusted before enabling this feature.
55
+ */
56
+ enableDynamicToolExecution?: boolean;
57
+ }
58
+ export declare const defaultPluginConfig: Required<Omit<IUniverMCPConfig, 'sessionId'>>;
59
+ export interface IUniverMCPConfigInternal extends IUniverMCPConfig {
60
+ customHeaders?: {
61
+ [key: string]: string;
62
+ };
55
63
  }
56
- export declare const defaultPluginConfig: Required<IUniverMCPConfig>;
@@ -1,5 +1,5 @@
1
- import { Disposable, IConfigService, ILogService } from '@univerjs/core';
2
- import { HTTPService, ISocketService } from '@univerjs/network';
1
+ import { Disposable, IConfigService, ILogService, Injector } from '@univerjs/core';
2
+ import { HTTPService } from '@univerjs/network';
3
3
  import { MCPUIEventService } from '../services/mcp-ui-event.service';
4
4
  import { MCPConnectionError, MCPConnectionStatus } from './config.schema';
5
5
  /**
@@ -27,22 +27,26 @@ export interface IMCPMessage {
27
27
  * - Error handling and reporting
28
28
  */
29
29
  export declare class MCPConnectionController extends Disposable {
30
+ readonly _injector: Injector;
30
31
  private readonly _configService;
31
32
  private readonly _logService;
32
33
  private readonly _httpService;
33
- private readonly _socketService;
34
34
  private readonly _mcpUIEventService;
35
35
  private _socket;
36
36
  private _retryCount;
37
37
  private _connectionStatus;
38
38
  private _connectionError;
39
+ private _sessionId;
39
40
  private _retryTimer;
40
41
  private _destroy$;
42
+ enableAutoConnect: boolean;
43
+ private _isUserConfiguredSessionId;
41
44
  readonly connectionStatus$: import('rxjs').Observable<MCPConnectionStatus>;
42
45
  readonly connectionError$: import('rxjs').Observable<MCPConnectionError>;
46
+ readonly sessionId$: import('rxjs').Observable<string>;
43
47
  private readonly _message$;
44
48
  readonly message$: import('rxjs').Observable<IMCPMessage>;
45
- constructor(_configService: IConfigService, _logService: ILogService, _httpService: HTTPService, _socketService: ISocketService, _mcpUIEventService: MCPUIEventService);
49
+ constructor(_injector: Injector, _configService: IConfigService, _logService: ILogService, _httpService: HTTPService, _mcpUIEventService: MCPUIEventService);
46
50
  /**
47
51
  * Get current connection status
48
52
  */
@@ -79,6 +83,13 @@ export declare class MCPConnectionController extends Disposable {
79
83
  * Perform connection to MCP server
80
84
  */
81
85
  private _connect;
86
+ /**
87
+ * Resolve sessionId from configuration, supporting string, function, and async function
88
+ */
89
+ private _resolveSessionId;
90
+ __setCustomHeaders(headers: {
91
+ [key: string]: string;
92
+ }): void;
82
93
  /**
83
94
  * Get session ticket from authentication API
84
95
  */
@@ -7,4 +7,5 @@ export declare class UniverMCPPlugin extends Plugin {
7
7
  static pluginName: string;
8
8
  constructor(_config: IUniverMCPConfig | undefined, _injector: Injector, _configService: IConfigService);
9
9
  onStarting(): void;
10
+ onReady(): void;
10
11
  }
package/lib/umd/facade.js CHANGED
@@ -1 +1 @@
1
- (function(_0x455475,_0x23cd71){var _0x2c3bfa=_0x4368,_0x57d537=_0x455475();while(!![]){try{var _0x32e74b=-parseInt(_0x2c3bfa(0x186))/0x1+-parseInt(_0x2c3bfa(0x184))/0x2*(-parseInt(_0x2c3bfa(0x187))/0x3)+-parseInt(_0x2c3bfa(0x17e))/0x4*(parseInt(_0x2c3bfa(0x183))/0x5)+-parseInt(_0x2c3bfa(0x185))/0x6+-parseInt(_0x2c3bfa(0x179))/0x7+parseInt(_0x2c3bfa(0x178))/0x8*(-parseInt(_0x2c3bfa(0x17d))/0x9)+parseInt(_0x2c3bfa(0x17c))/0xa*(parseInt(_0x2c3bfa(0x18b))/0xb);if(_0x32e74b===_0x23cd71)break;else _0x57d537['push'](_0x57d537['shift']());}catch(_0x413344){_0x57d537['push'](_0x57d537['shift']());}}}(_0xdaa7,0x5c9bd),function(_0x1960e7,_0x16a167){var _0x53c720=_0x4368;typeof exports==_0x53c720(0x17f)&&typeof module<'u'?_0x16a167(require('@univerjs-pro/mcp'),require('@univerjs/core/facade')):typeof define==_0x53c720(0x17b)&&define['amd']?define(['@univerjs-pro/mcp',_0x53c720(0x182)],_0x16a167):(_0x1960e7=typeof globalThis<'u'?globalThis:_0x1960e7||self,_0x16a167(_0x1960e7[_0x53c720(0x17a)],_0x1960e7[_0x53c720(0x189)]));}(this,function(_0x5081e2,_0x2bba44){'use strict';var _0x2e5327=_0x4368;class _0x1ac428 extends _0x2bba44[_0x2e5327(0x176)]{['validateMCPToolCall'](_0x4002fb,_0x279702){var _0x185776=_0x2e5327;return this[_0x185776(0x175)][_0x185776(0x180)](_0x5081e2[_0x185776(0x181)])['validateToolCall'](_0x4002fb,_0x279702);}[_0x2e5327(0x177)](){var _0x5b20bf=_0x2e5327;return this[_0x5b20bf(0x175)]['get'](_0x5081e2[_0x5b20bf(0x181)])['getAllTools']();}['callMCPTool'](_0x415fd9,_0x46cf9c){var _0x1ce572=_0x2e5327;return this[_0x1ce572(0x175)][_0x1ce572(0x180)](_0x5081e2[_0x1ce572(0x181)])[_0x1ce572(0x18a)](_0x415fd9,_0x46cf9c);}}_0x2bba44[_0x2e5327(0x176)][_0x2e5327(0x188)](_0x1ac428);}));function _0x4368(_0x50f17c,_0x47a5d3){var _0xdaa70a=_0xdaa7();return _0x4368=function(_0x436890,_0x5c5cd7){_0x436890=_0x436890-0x175;var _0x1624b8=_0xdaa70a[_0x436890];return _0x1624b8;},_0x4368(_0x50f17c,_0x47a5d3);}function _0xdaa7(){var _0x42481f=['executeTool','6281nbjrQp','_injector','FUniver','getAllMCPTools','16mGeKka','3773889UHOqgu','UniverProMcp','function','34430nONuWr','2188476WyIRxt','1620616aRJamU','object','get','IMCPToolRegistry','@univerjs/core/facade','5jLYLLR','914348cNxdhN','2873718IUbsge','134240SBcowH','3ElNsWP','extend','UniverCoreFacade'];_0xdaa7=function(){return _0x42481f;};return _0xdaa7();}
1
+ function _0x3574(_0x21c890,_0x118a0c){var _0x3e1a15=_0x3e1a();return _0x3574=function(_0x357486,_0x1f648d){_0x357486=_0x357486-0x13b;var _0x36af00=_0x3e1a15[_0x357486];return _0x36af00;},_0x3574(_0x21c890,_0x118a0c);}function _0x3e1a(){var _0x388eb9=['extend','amd','3039048xkoamD','5696404lNLCSO','validateToolCall','2651230uquYNl','getAllMCPTools','1752960BtmxNu','6vMKEvF','2218NOHXEm','2793200ygtBQS','executeTool','15182955agZqqb','callMCPTool','@univerjs/core/facade','FUniver','object','UniverProMcp','getAllTools','@univerjs-pro/mcp','1DQxcKr','_injector','function','get','UniverCoreFacade'];_0x3e1a=function(){return _0x388eb9;};return _0x3e1a();}(function(_0x59e762,_0x464325){var _0x544892=_0x3574,_0x46ee43=_0x59e762();while(!![]){try{var _0x3dc82a=parseInt(_0x544892(0x140))/0x1*(-parseInt(_0x544892(0x14e))/0x2)+-parseInt(_0x544892(0x14c))/0x3+-parseInt(_0x544892(0x14f))/0x4+parseInt(_0x544892(0x14a))/0x5+parseInt(_0x544892(0x14d))/0x6*(-parseInt(_0x544892(0x148))/0x7)+parseInt(_0x544892(0x147))/0x8+parseInt(_0x544892(0x151))/0x9;if(_0x3dc82a===_0x464325)break;else _0x46ee43['push'](_0x46ee43['shift']());}catch(_0x177597){_0x46ee43['push'](_0x46ee43['shift']());}}}(_0x3e1a,0x79fa5),function(_0x3994d5,_0x5345d1){var _0x49adbb=_0x3574;typeof exports==_0x49adbb(0x13c)&&typeof module<'u'?_0x5345d1(require('@univerjs-pro/mcp'),require('@univerjs/core/facade')):typeof define==_0x49adbb(0x142)&&define[_0x49adbb(0x146)]?define([_0x49adbb(0x13f),_0x49adbb(0x153)],_0x5345d1):(_0x3994d5=typeof globalThis<'u'?globalThis:_0x3994d5||self,_0x5345d1(_0x3994d5[_0x49adbb(0x13d)],_0x3994d5[_0x49adbb(0x144)]));}(this,function(_0x53d04b,_0xb94797){'use strict';var _0x2fd051=_0x3574;class _0x58d208 extends _0xb94797[_0x2fd051(0x13b)]{['validateMCPToolCall'](_0x1cf6a1,_0x2bf038){var _0x265fe8=_0x2fd051;return this[_0x265fe8(0x141)][_0x265fe8(0x143)](_0x53d04b['IMCPToolRegistry'])[_0x265fe8(0x149)](_0x1cf6a1,_0x2bf038);}[_0x2fd051(0x14b)](){var _0x4440c1=_0x2fd051;return this[_0x4440c1(0x141)]['get'](_0x53d04b['IMCPToolRegistry'])[_0x4440c1(0x13e)]();}[_0x2fd051(0x152)](_0x15c76c,_0x13bb24){var _0x5e6382=_0x2fd051;return this[_0x5e6382(0x141)][_0x5e6382(0x143)](_0x53d04b['IMCPToolRegistry'])[_0x5e6382(0x150)](_0x15c76c,_0x13bb24);}}_0xb94797[_0x2fd051(0x13b)][_0x2fd051(0x145)](_0x58d208);}));