@kya-os/mcp-i 1.2.9 → 1.2.10
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/dist/runtime/adapter-express.js +1 -1
- package/dist/runtime/adapter-nextjs.js +1 -1
- package/dist/runtime/http.js +1 -1
- package/dist/runtime/identity.d.ts +1 -0
- package/dist/runtime/identity.js +6 -4
- package/dist/runtime/stdio.js +1 -1
- package/dist/runtime/utils/server.js +32 -16
- package/dist/runtime/utils/tools.js +16 -5
- package/package.json +1 -1
|
@@ -38,39 +38,55 @@ function loadTools() {
|
|
|
38
38
|
const toolModules = new Map();
|
|
39
39
|
// Debug: log what tools are being injected
|
|
40
40
|
const toolPaths = Object.keys(exports.injectedTools);
|
|
41
|
-
|
|
41
|
+
if (identityConfig?.debug) {
|
|
42
|
+
console.error("[loadTools] Injected tool paths:", toolPaths);
|
|
43
|
+
}
|
|
42
44
|
const toolPromises = toolPaths.map((path) => exports.injectedTools[path]().then((toolModule) => {
|
|
43
|
-
|
|
45
|
+
if (identityConfig?.debug) {
|
|
46
|
+
console.error("[loadTools] Loaded tool from path:", path);
|
|
47
|
+
}
|
|
44
48
|
toolModules.set(path, toolModule);
|
|
45
49
|
}));
|
|
46
50
|
return [toolPromises, toolModules];
|
|
47
51
|
}
|
|
48
52
|
async function createServer() {
|
|
49
|
-
|
|
53
|
+
if (identityConfig?.debug) {
|
|
54
|
+
console.error("[createServer] Starting server creation");
|
|
55
|
+
}
|
|
50
56
|
// Guard against double initialization using global scope
|
|
51
57
|
// This ensures singleton even if webpack creates multiple module instances
|
|
52
58
|
if (typeof global !== 'undefined' && global.__MCPI_SERVER_CREATED__) {
|
|
53
|
-
|
|
59
|
+
if (identityConfig?.debug) {
|
|
60
|
+
console.error("[createServer] Server already exists, returning cached instance");
|
|
61
|
+
}
|
|
54
62
|
if (global.__MCPI_SERVER_INSTANCE__) {
|
|
55
63
|
return global.__MCPI_SERVER_INSTANCE__;
|
|
56
64
|
}
|
|
57
65
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
66
|
+
if (identityConfig?.debug) {
|
|
67
|
+
console.error("[createServer] Creating new McpServer");
|
|
68
|
+
console.error("[createServer] SERVER_INFO constant:", JSON.stringify(exports.SERVER_INFO));
|
|
69
|
+
console.error("[createServer] SERVER_CAPABILITIES constant:", JSON.stringify(exports.SERVER_CAPABILITIES));
|
|
70
|
+
console.error("[createServer] Calling: new McpServer(SERVER_INFO, SERVER_CAPABILITIES)");
|
|
71
|
+
}
|
|
62
72
|
const server = new index_js_1.Server(exports.SERVER_INFO, exports.SERVER_CAPABILITIES);
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
73
|
+
if (identityConfig?.debug) {
|
|
74
|
+
console.error("[createServer] Server created successfully");
|
|
75
|
+
// Debug: Verify what the server actually received
|
|
76
|
+
const serverAny = server;
|
|
77
|
+
console.error("[createServer] Actual server._serverInfo:", JSON.stringify(serverAny._serverInfo || "undefined"));
|
|
78
|
+
console.error("[createServer] Actual server._capabilities:", JSON.stringify(serverAny._capabilities || "undefined"));
|
|
79
|
+
console.error("[createServer] Loading tools...");
|
|
80
|
+
}
|
|
69
81
|
const [toolPromises, toolModules] = loadTools();
|
|
70
82
|
await Promise.all(toolPromises);
|
|
71
|
-
|
|
83
|
+
if (identityConfig?.debug) {
|
|
84
|
+
console.error("[createServer] Tools loaded, configuring server");
|
|
85
|
+
}
|
|
72
86
|
const configuredServer = await configureServer(server, toolModules);
|
|
73
|
-
|
|
87
|
+
if (identityConfig?.debug) {
|
|
88
|
+
console.error("[createServer] Server configured successfully");
|
|
89
|
+
}
|
|
74
90
|
// Store in global scope
|
|
75
91
|
if (typeof global !== 'undefined') {
|
|
76
92
|
global.__MCPI_SERVER_CREATED__ = true;
|
|
@@ -33,13 +33,17 @@ async function addToolsToServer(server, toolModules, identityConfig) {
|
|
|
33
33
|
// Set this IMMEDIATELY to prevent race conditions
|
|
34
34
|
if (typeof global !== 'undefined') {
|
|
35
35
|
if (global.__MCPI_HANDLERS_REGISTERED__) {
|
|
36
|
-
|
|
36
|
+
if (identityConfig?.debug) {
|
|
37
|
+
console.error("[MCPI] Handlers already registered, skipping duplicate registration");
|
|
38
|
+
}
|
|
37
39
|
return server;
|
|
38
40
|
}
|
|
39
41
|
// Mark as registered RIGHT NOW before doing anything else
|
|
40
42
|
global.__MCPI_HANDLERS_REGISTERED__ = true;
|
|
41
43
|
}
|
|
42
|
-
|
|
44
|
+
if (identityConfig?.debug) {
|
|
45
|
+
console.error("[MCPI] Registering handlers for the first time");
|
|
46
|
+
}
|
|
43
47
|
// Initialize identity manager if identity is enabled
|
|
44
48
|
let identityManager = null;
|
|
45
49
|
if (identityConfig?.enabled) {
|
|
@@ -48,6 +52,7 @@ async function addToolsToServer(server, toolModules, identityConfig) {
|
|
|
48
52
|
environment: identityConfig.environment ||
|
|
49
53
|
"development",
|
|
50
54
|
devIdentityPath: identityConfig.devIdentityPath,
|
|
55
|
+
debug: identityConfig.debug,
|
|
51
56
|
});
|
|
52
57
|
// Ensure identity exists (loads or generates it)
|
|
53
58
|
const identity = await identityManager.ensureIdentity();
|
|
@@ -57,7 +62,9 @@ async function addToolsToServer(server, toolModules, identityConfig) {
|
|
|
57
62
|
}
|
|
58
63
|
}
|
|
59
64
|
catch (error) {
|
|
60
|
-
|
|
65
|
+
if (identityConfig?.debug) {
|
|
66
|
+
console.error("[MCPI] Failed to initialize identity:", error);
|
|
67
|
+
}
|
|
61
68
|
// Continue without identity if initialization fails
|
|
62
69
|
}
|
|
63
70
|
}
|
|
@@ -105,7 +112,9 @@ async function addToolsToServer(server, toolModules, identityConfig) {
|
|
|
105
112
|
toolHandlers.set(toolConfig.name, handler);
|
|
106
113
|
});
|
|
107
114
|
// Debug: log server state before registering handler
|
|
108
|
-
|
|
115
|
+
if (identityConfig?.debug) {
|
|
116
|
+
console.error("[MCPI] About to register tools/list handler");
|
|
117
|
+
}
|
|
109
118
|
// Register tools/list handler
|
|
110
119
|
server.setRequestHandler(types_js_1.ListToolsRequestSchema, async (request) => {
|
|
111
120
|
return {
|
|
@@ -201,6 +210,8 @@ async function addToolsToServer(server, toolModules, identityConfig) {
|
|
|
201
210
|
};
|
|
202
211
|
}
|
|
203
212
|
});
|
|
204
|
-
|
|
213
|
+
if (identityConfig?.debug) {
|
|
214
|
+
console.error("[MCPI] Handlers registered successfully");
|
|
215
|
+
}
|
|
205
216
|
return server;
|
|
206
217
|
}
|