@univerjs-pro/mcp 0.10.7-nightly.202509090319 → 0.10.7-nightly.202509130640

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 _0x1cd3(){var _0x2e7bee=['126626ndKuAK','@univerjs/core/facade','callMCPTool','UniverCoreFacade','1051712nmcHSj','validateMCPToolCall','22355PlRUJe','UniverProMcp','187893lgljHf','IMCPToolRegistry','object','282wdXmYX','extend','executeTool','amd','validateToolCall','getAllMCPTools','8540325kvKlZT','2387552jGkEfC','6192249kXEazj','_injector','get','FUniver','46gsmEGR'];_0x1cd3=function(){return _0x2e7bee;};return _0x1cd3();}function _0x2462(_0x1c774b,_0x24b98e){var _0x1cd356=_0x1cd3();return _0x2462=function(_0x2462a0,_0x27e950){_0x2462a0=_0x2462a0-0x15f;var _0x3e9fa0=_0x1cd356[_0x2462a0];return _0x3e9fa0;},_0x2462(_0x1c774b,_0x24b98e);}(function(_0x10fcb2,_0x1ba2f1){var _0x400c3e=_0x2462,_0x5ed87c=_0x10fcb2();while(!![]){try{var _0x421c04=parseInt(_0x400c3e(0x16c))/0x1+-parseInt(_0x400c3e(0x16b))/0x2*(-parseInt(_0x400c3e(0x174))/0x3)+-parseInt(_0x400c3e(0x166))/0x4+-parseInt(_0x400c3e(0x172))/0x5*(parseInt(_0x400c3e(0x15f))/0x6)+parseInt(_0x400c3e(0x167))/0x7+parseInt(_0x400c3e(0x170))/0x8+-parseInt(_0x400c3e(0x165))/0x9;if(_0x421c04===_0x1ba2f1)break;else _0x5ed87c['push'](_0x5ed87c['shift']());}catch(_0x3abcf2){_0x5ed87c['push'](_0x5ed87c['shift']());}}}(_0x1cd3,0xc9f7c),function(_0x1f5f86,_0x5786d9){var _0x330b6f=_0x2462;typeof exports==_0x330b6f(0x176)&&typeof module<'u'?_0x5786d9(require('@univerjs-pro/mcp'),require('@univerjs/core/facade')):typeof define=='function'&&define[_0x330b6f(0x162)]?define(['@univerjs-pro/mcp',_0x330b6f(0x16d)],_0x5786d9):(_0x1f5f86=typeof globalThis<'u'?globalThis:_0x1f5f86||self,_0x5786d9(_0x1f5f86[_0x330b6f(0x173)],_0x1f5f86[_0x330b6f(0x16f)]));}(this,function(_0x4a3a98,_0x405b15){'use strict';var _0x5cb6c9=_0x2462;class _0x29c400 extends _0x405b15['FUniver']{[_0x5cb6c9(0x171)](_0x4dc1ee,_0x43ccef){var _0x1f2fad=_0x5cb6c9;return this[_0x1f2fad(0x168)][_0x1f2fad(0x169)](_0x4a3a98[_0x1f2fad(0x175)])[_0x1f2fad(0x163)](_0x4dc1ee,_0x43ccef);}[_0x5cb6c9(0x164)](){var _0xd01ba7=_0x5cb6c9;return this[_0xd01ba7(0x168)][_0xd01ba7(0x169)](_0x4a3a98[_0xd01ba7(0x175)])['getAllTools']();}[_0x5cb6c9(0x16e)](_0x4d1985,_0x5be11d){var _0x1ef673=_0x5cb6c9;return this[_0x1ef673(0x168)][_0x1ef673(0x169)](_0x4a3a98[_0x1ef673(0x175)])[_0x1ef673(0x161)](_0x4d1985,_0x5be11d);}}_0x405b15[_0x5cb6c9(0x16a)][_0x5cb6c9(0x160)](_0x29c400);}));
1
+ function _0x3451(_0x1e33f1,_0x2bbb71){var _0x382815=_0x3828();return _0x3451=function(_0x34514b,_0x4b0b54){_0x34514b=_0x34514b-0x197;var _0x5e13e2=_0x382815[_0x34514b];return _0x5e13e2;},_0x3451(_0x1e33f1,_0x2bbb71);}(function(_0x51b145,_0x48e23e){var _0x143d44=_0x3451,_0x1e9423=_0x51b145();while(!![]){try{var _0x251e94=parseInt(_0x143d44(0x19d))/0x1*(parseInt(_0x143d44(0x1ad))/0x2)+parseInt(_0x143d44(0x1a1))/0x3*(parseInt(_0x143d44(0x1b0))/0x4)+-parseInt(_0x143d44(0x198))/0x5*(parseInt(_0x143d44(0x1ab))/0x6)+-parseInt(_0x143d44(0x19f))/0x7*(-parseInt(_0x143d44(0x19b))/0x8)+parseInt(_0x143d44(0x1a2))/0x9+-parseInt(_0x143d44(0x1a5))/0xa+-parseInt(_0x143d44(0x1a6))/0xb*(-parseInt(_0x143d44(0x197))/0xc);if(_0x251e94===_0x48e23e)break;else _0x1e9423['push'](_0x1e9423['shift']());}catch(_0x112301){_0x1e9423['push'](_0x1e9423['shift']());}}}(_0x3828,0x6d66f),function(_0x53649d,_0x22c89d){var _0x4c3f39=_0x3451;typeof exports==_0x4c3f39(0x1af)&&typeof module<'u'?_0x22c89d(require('@univerjs-pro/mcp'),require('@univerjs/core/facade')):typeof define==_0x4c3f39(0x1a8)&&define[_0x4c3f39(0x1ae)]?define([_0x4c3f39(0x1a9),_0x4c3f39(0x1a7)],_0x22c89d):(_0x53649d=typeof globalThis<'u'?globalThis:_0x53649d||self,_0x22c89d(_0x53649d[_0x4c3f39(0x199)],_0x53649d['UniverCoreFacade']));}(this,function(_0x1c9acb,_0x5298f5){'use strict';var _0x198942=_0x3451;class _0x419847 extends _0x5298f5[_0x198942(0x1a0)]{[_0x198942(0x19a)](_0x2600d6,_0xfb938){var _0x1240c8=_0x198942;return this[_0x1240c8(0x19c)][_0x1240c8(0x1a3)](_0x1c9acb[_0x1240c8(0x1ac)])['validateToolCall'](_0x2600d6,_0xfb938);}['getAllMCPTools'](){var _0xa9eff4=_0x198942;return this[_0xa9eff4(0x19c)][_0xa9eff4(0x1a3)](_0x1c9acb[_0xa9eff4(0x1ac)])[_0xa9eff4(0x19e)]();}[_0x198942(0x1a4)](_0x507828,_0x597eb3){var _0x5ecaa2=_0x198942;return this['_injector'][_0x5ecaa2(0x1a3)](_0x1c9acb['IMCPToolRegistry'])['executeTool'](_0x507828,_0x597eb3);}}_0x5298f5['FUniver'][_0x198942(0x1aa)](_0x419847);}));function _0x3828(){var _0x13bac0=['getAllTools','337967cjBJBi','FUniver','724596TsBlbf','3382587VahHnU','get','callMCPTool','8652090KvuZQJ','715rzSxzR','@univerjs/core/facade','function','@univerjs-pro/mcp','extend','5502ZuQNUa','IMCPToolRegistry','42754kwPTtJ','amd','object','4epZMQc','46392JclCCY','3130EKKDym','UniverProMcp','validateMCPToolCall','144OGaJBs','_injector','7iYyucO'];_0x3828=function(){return _0x13bac0;};return _0x3828();}