@memoraone/mcp 0.1.52 → 0.1.53
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/cli.cjs +103 -5
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -231,7 +231,7 @@ var require_package = __commonJS({
|
|
|
231
231
|
"package.json"(exports2, module2) {
|
|
232
232
|
module2.exports = {
|
|
233
233
|
name: "@memoraone/mcp",
|
|
234
|
-
version: "0.1.
|
|
234
|
+
version: "0.1.53",
|
|
235
235
|
type: "module",
|
|
236
236
|
main: "dist/index.cjs",
|
|
237
237
|
exports: {
|
|
@@ -13815,6 +13815,17 @@ function extractJsonRpcId(line) {
|
|
|
13815
13815
|
return void 0;
|
|
13816
13816
|
}
|
|
13817
13817
|
}
|
|
13818
|
+
function extractInitializeProtocolVersion(line) {
|
|
13819
|
+
try {
|
|
13820
|
+
const message = JSON.parse(line.trim());
|
|
13821
|
+
const version2 = message.params?.protocolVersion;
|
|
13822
|
+
if (typeof version2 === "string" && version2.trim() !== "") {
|
|
13823
|
+
return version2;
|
|
13824
|
+
}
|
|
13825
|
+
} catch {
|
|
13826
|
+
}
|
|
13827
|
+
return "2024-11-05";
|
|
13828
|
+
}
|
|
13818
13829
|
function connectWithRetry(socketPath, log, maxRetries, retryDelayMs, connect2) {
|
|
13819
13830
|
return new Promise((resolve44, reject) => {
|
|
13820
13831
|
const tryConnect = (attempt) => {
|
|
@@ -13949,11 +13960,19 @@ async function runBridgeProxy(options) {
|
|
|
13949
13960
|
if (message.method === "initialize") {
|
|
13950
13961
|
log("resolve binding from initialize request before daemon connect");
|
|
13951
13962
|
const params = message.params ?? {};
|
|
13952
|
-
await router.ensureDaemonForInitialize(params);
|
|
13963
|
+
const sessionKind = await router.ensureDaemonForInitialize(params);
|
|
13964
|
+
if (sessionKind === "setup_required") {
|
|
13965
|
+
router.completeSetupRequiredInitialize(trimmed);
|
|
13966
|
+
continue;
|
|
13967
|
+
}
|
|
13953
13968
|
await router.forwardInitializeToDaemon(trimmed);
|
|
13954
13969
|
await router.replayDeferredClientMessages();
|
|
13955
13970
|
continue;
|
|
13956
13971
|
}
|
|
13972
|
+
if (router.isSetupRequiredSession()) {
|
|
13973
|
+
router.handleSetupRequiredClientLine(trimmed);
|
|
13974
|
+
continue;
|
|
13975
|
+
}
|
|
13957
13976
|
if (!router.hasClientInitialize()) {
|
|
13958
13977
|
const method = typeof message.method === "string" && message.method.trim() !== "" ? message.method : "(unknown)";
|
|
13959
13978
|
if (message.id !== void 0 && message.id !== null) {
|
|
@@ -13976,7 +13995,7 @@ async function runBridgeProxy(options) {
|
|
|
13976
13995
|
router.close();
|
|
13977
13996
|
}
|
|
13978
13997
|
}
|
|
13979
|
-
var net, readline4, import_node_child_process7, defaultLog, JSONRPC_METHOD_NOT_FOUND, BridgeDaemonRouter;
|
|
13998
|
+
var net, readline4, import_node_child_process7, defaultLog, JSONRPC_METHOD_NOT_FOUND, SETUP_REQUIRED_FINISH_SETUP_TOOL, BridgeDaemonRouter;
|
|
13980
13999
|
var init_bridgeProxy = __esm({
|
|
13981
14000
|
"src/bridgeProxy.ts"() {
|
|
13982
14001
|
net = __toESM(require("net"), 1);
|
|
@@ -13996,6 +14015,11 @@ var init_bridgeProxy = __esm({
|
|
|
13996
14015
|
`);
|
|
13997
14016
|
};
|
|
13998
14017
|
JSONRPC_METHOD_NOT_FOUND = -32601;
|
|
14018
|
+
SETUP_REQUIRED_FINISH_SETUP_TOOL = {
|
|
14019
|
+
name: "memora_finish_setup",
|
|
14020
|
+
description: "Start MemoraOne Cursor plugin pairing for this workspace so the user can finish setup. Returns an authorization URL and request metadata; does not open a browser. Use when this plugin-managed session is unbound (setup required).",
|
|
14021
|
+
inputSchema: { type: "object", properties: {} }
|
|
14022
|
+
};
|
|
13999
14023
|
BridgeDaemonRouter = class {
|
|
14000
14024
|
constructor(options) {
|
|
14001
14025
|
this.activeSocket = null;
|
|
@@ -14006,6 +14030,8 @@ var init_bridgeProxy = __esm({
|
|
|
14006
14030
|
this.pendingDeferredClientLines = [];
|
|
14007
14031
|
this.handshakeDeferredClientLines = [];
|
|
14008
14032
|
this.clientInitializeSeen = false;
|
|
14033
|
+
/** Unbound Cursor-plugin session: no daemon by design; handshake is local. */
|
|
14034
|
+
this.setupRequiredSession = false;
|
|
14009
14035
|
/** Waiters for daemon JSON-RPC responses (keyed by request id). */
|
|
14010
14036
|
this.pendingDaemonResponseWaiters = /* @__PURE__ */ new Map();
|
|
14011
14037
|
this.env = options.env ?? process.env;
|
|
@@ -14056,6 +14082,9 @@ var init_bridgeProxy = __esm({
|
|
|
14056
14082
|
hasClientInitialize() {
|
|
14057
14083
|
return this.clientInitializeSeen;
|
|
14058
14084
|
}
|
|
14085
|
+
isSetupRequiredSession() {
|
|
14086
|
+
return this.setupRequiredSession;
|
|
14087
|
+
}
|
|
14059
14088
|
async ensureDaemonForInitialize(params) {
|
|
14060
14089
|
logInitializeDebug(
|
|
14061
14090
|
this.log,
|
|
@@ -14115,14 +14144,22 @@ var init_bridgeProxy = __esm({
|
|
|
14115
14144
|
log: this.log
|
|
14116
14145
|
}) : await resolveBinding();
|
|
14117
14146
|
if (isPluginStartupSetupRequired(binding)) {
|
|
14118
|
-
|
|
14147
|
+
this.setupRequiredSession = true;
|
|
14148
|
+
this.activeBinding = null;
|
|
14149
|
+
this.detachSocketReader();
|
|
14150
|
+
const previousSocket = this.activeSocket;
|
|
14151
|
+
this.activeSocket = null;
|
|
14152
|
+
previousSocket?.destroy();
|
|
14153
|
+
this.log("setup_required: no active binding; initialize will complete locally");
|
|
14154
|
+
return "setup_required";
|
|
14119
14155
|
}
|
|
14156
|
+
this.setupRequiredSession = false;
|
|
14120
14157
|
const environmentLog = binding.environment !== void 0 ? ` environment=${binding.environment}` : "";
|
|
14121
14158
|
this.log(
|
|
14122
14159
|
`session binding binding=${binding.repositoryBindingId} project=${binding.projectId} workspace=${binding.workspaceRoot} source=${binding.bindingSource}${environmentLog}`
|
|
14123
14160
|
);
|
|
14124
14161
|
if (this.activeBinding && bindingsMatch(this.activeBinding, binding) && this.activeSocket) {
|
|
14125
|
-
return;
|
|
14162
|
+
return "connected";
|
|
14126
14163
|
}
|
|
14127
14164
|
if (this.activeBinding && !bindingsMatch(this.activeBinding, binding)) {
|
|
14128
14165
|
this.log(
|
|
@@ -14137,11 +14174,71 @@ var init_bridgeProxy = __esm({
|
|
|
14137
14174
|
this.activeBinding = binding;
|
|
14138
14175
|
await this.connectActiveDaemon();
|
|
14139
14176
|
this.log("bridge connected");
|
|
14177
|
+
return "connected";
|
|
14140
14178
|
}
|
|
14141
14179
|
recordClientInitialize(line) {
|
|
14142
14180
|
this.lastInitializeLine = line;
|
|
14143
14181
|
this.clientInitializeSeen = true;
|
|
14144
14182
|
}
|
|
14183
|
+
/**
|
|
14184
|
+
* Finish Setup session: answer initialize on the bridge. Does not connect,
|
|
14185
|
+
* spawn, or forward to a daemon — there is no binding by design.
|
|
14186
|
+
*/
|
|
14187
|
+
completeSetupRequiredInitialize(line) {
|
|
14188
|
+
this.recordClientInitialize(line);
|
|
14189
|
+
const initId = extractJsonRpcId(line);
|
|
14190
|
+
if (initId !== void 0) {
|
|
14191
|
+
this.stdout.write(
|
|
14192
|
+
`${JSON.stringify({
|
|
14193
|
+
jsonrpc: "2.0",
|
|
14194
|
+
id: initId,
|
|
14195
|
+
result: {
|
|
14196
|
+
protocolVersion: extractInitializeProtocolVersion(line),
|
|
14197
|
+
capabilities: { tools: { listChanged: true } },
|
|
14198
|
+
serverInfo: { name: "memoraone-mcp", version: "1.0.0" }
|
|
14199
|
+
}
|
|
14200
|
+
})}
|
|
14201
|
+
`
|
|
14202
|
+
);
|
|
14203
|
+
}
|
|
14204
|
+
this.log("setup_required: initialize completed locally");
|
|
14205
|
+
const deferred = this.pendingDeferredClientLines.slice();
|
|
14206
|
+
this.pendingDeferredClientLines = [];
|
|
14207
|
+
this.handshakeDeferredClientLines = deferred.slice();
|
|
14208
|
+
for (const deferredLine of deferred) {
|
|
14209
|
+
this.handleSetupRequiredClientLine(deferredLine);
|
|
14210
|
+
}
|
|
14211
|
+
}
|
|
14212
|
+
/** Local MCP replies for a setup_required session (no daemon socket). */
|
|
14213
|
+
handleSetupRequiredClientLine(line) {
|
|
14214
|
+
let message;
|
|
14215
|
+
try {
|
|
14216
|
+
message = JSON.parse(line.trim());
|
|
14217
|
+
} catch {
|
|
14218
|
+
return;
|
|
14219
|
+
}
|
|
14220
|
+
const method = typeof message.method === "string" ? message.method : "";
|
|
14221
|
+
const id = message.id;
|
|
14222
|
+
if (method === "tools/list" && (typeof id === "string" || typeof id === "number")) {
|
|
14223
|
+
this.stdout.write(
|
|
14224
|
+
`${JSON.stringify({
|
|
14225
|
+
jsonrpc: "2.0",
|
|
14226
|
+
id,
|
|
14227
|
+
result: { tools: [SETUP_REQUIRED_FINISH_SETUP_TOOL] }
|
|
14228
|
+
})}
|
|
14229
|
+
`
|
|
14230
|
+
);
|
|
14231
|
+
return;
|
|
14232
|
+
}
|
|
14233
|
+
if (id === void 0 || id === null) {
|
|
14234
|
+
return;
|
|
14235
|
+
}
|
|
14236
|
+
writePreInitializeJsonRpcError(
|
|
14237
|
+
this.stdout,
|
|
14238
|
+
id,
|
|
14239
|
+
method.trim() !== "" ? method : "(unknown)"
|
|
14240
|
+
);
|
|
14241
|
+
}
|
|
14145
14242
|
/**
|
|
14146
14243
|
* Forward initialize to the daemon and wait for its JSON-RPC response before
|
|
14147
14244
|
* returning. Prevents pipelined tools/call (e.g. Claude Code lazy MCP connect)
|
|
@@ -14241,6 +14338,7 @@ var init_bridgeProxy = __esm({
|
|
|
14241
14338
|
this.pendingDeferredClientLines = [];
|
|
14242
14339
|
this.handshakeDeferredClientLines = [];
|
|
14243
14340
|
this.clientInitializeSeen = false;
|
|
14341
|
+
this.setupRequiredSession = false;
|
|
14244
14342
|
this.activeBinding = null;
|
|
14245
14343
|
this.activeIdeType = void 0;
|
|
14246
14344
|
}
|