@wrongstack/sage-mcp 0.306.0 → 0.306.3
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/adapter.d.ts +17 -0
- package/dist/cli.js +31 -26
- package/dist/index.js +5 -4
- package/package.json +4 -4
package/dist/adapter.d.ts
CHANGED
|
@@ -24,6 +24,23 @@ import type { MemoryPort } from '@wrongstack/core/types';
|
|
|
24
24
|
import { type SageServiceLike } from '@wrongstack/sage';
|
|
25
25
|
import { type SageMcpPolicyOptions } from './policy.js';
|
|
26
26
|
export interface SageMcpToolHostOptions extends SageMcpPolicyOptions {
|
|
27
|
+
/**
|
|
28
|
+
* Project root the served memory belongs to, used for the synthetic
|
|
29
|
+
* `Context`. Defaults to `process.cwd()`.
|
|
30
|
+
*
|
|
31
|
+
* The CLI already requires and canonicalizes `--project-root` to build the
|
|
32
|
+
* port, so defaulting the Context to the server's cwd meant the two could
|
|
33
|
+
* disagree: every tool would be told it was operating on whatever directory
|
|
34
|
+
* the MCP server happened to be launched from. No SAGE tool reads
|
|
35
|
+
* `ctx.projectRoot` today — the store resolves anchors against its OWN root
|
|
36
|
+
* (`SqliteCreateCandidateContext`), and the middleware that does read it
|
|
37
|
+
* (`path-remap`, `tool-call-memory`) only runs in the agent loop, never
|
|
38
|
+
* here — so this is a trap rather than a live defect. It is worth closing
|
|
39
|
+
* anyway: a tool that later reads the field would mis-resolve paths
|
|
40
|
+
* silently, and "silently anchored to the wrong root" is not a failure that
|
|
41
|
+
* announces itself.
|
|
42
|
+
*/
|
|
43
|
+
projectRoot?: string | undefined;
|
|
27
44
|
}
|
|
28
45
|
/**
|
|
29
46
|
* Resolve the SAGE service capability from any `MemoryPort`. Both
|
package/dist/cli.js
CHANGED
|
@@ -80,7 +80,7 @@ function createSageMcpToolHost(port, opts = {}) {
|
|
|
80
80
|
const allTools = createSageTools(service);
|
|
81
81
|
const allowed = selectAllowedTools(allTools, opts);
|
|
82
82
|
const allowedByName = new Map(allowed.map((entry) => [entry.name, entry.tool]));
|
|
83
|
-
const ctx = createSyntheticContext();
|
|
83
|
+
const ctx = createSyntheticContext(opts.projectRoot);
|
|
84
84
|
const ac = new AbortController();
|
|
85
85
|
const signal = ac.signal;
|
|
86
86
|
function jsonSchemaToObject(schema) {
|
|
@@ -127,11 +127,12 @@ function createSageMcpToolHost(port, opts = {}) {
|
|
|
127
127
|
}
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
|
-
function createSyntheticContext() {
|
|
130
|
+
function createSyntheticContext(projectRoot) {
|
|
131
|
+
const root = projectRoot ?? process.cwd();
|
|
131
132
|
return {
|
|
132
133
|
systemPrompt: [],
|
|
133
|
-
cwd:
|
|
134
|
-
projectRoot:
|
|
134
|
+
cwd: root,
|
|
135
|
+
projectRoot: root,
|
|
135
136
|
allowOutsideProjectRoot: false,
|
|
136
137
|
model: "sage-mcp",
|
|
137
138
|
tools: [],
|
|
@@ -254,33 +255,37 @@ async function main() {
|
|
|
254
255
|
);
|
|
255
256
|
return 3;
|
|
256
257
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
258
|
+
try {
|
|
259
|
+
const server = createSageMcpServer(port, { writable: args.writable, projectRoot });
|
|
260
|
+
if (args.transport === "http") {
|
|
261
|
+
const handle2 = await serveHttp(server, {
|
|
262
|
+
port: args.httpPort,
|
|
263
|
+
host: args.httpHost,
|
|
264
|
+
...args.httpToken ? { token: args.httpToken } : {},
|
|
265
|
+
logger: { warn: (m) => process.stderr.write(`[sage-mcp] ${m}
|
|
264
266
|
`) }
|
|
265
|
-
|
|
267
|
+
});
|
|
268
|
+
process.stderr.write(
|
|
269
|
+
`${SERVER_INFO.name}: ready at ${handle2.url} \u2014 projectRoot=${projectRoot} transport=http writable=${String(args.writable)}${args.httpToken ? " [token auth]" : ""}
|
|
270
|
+
`
|
|
271
|
+
);
|
|
272
|
+
await new Promise((resolve3) => {
|
|
273
|
+
process.once("SIGINT", resolve3);
|
|
274
|
+
process.once("SIGTERM", resolve3);
|
|
275
|
+
});
|
|
276
|
+
await handle2.close();
|
|
277
|
+
return 0;
|
|
278
|
+
}
|
|
279
|
+
const handle = serveStdio(server);
|
|
266
280
|
process.stderr.write(
|
|
267
|
-
`${SERVER_INFO.name}: ready
|
|
281
|
+
`${SERVER_INFO.name}: ready on stdio \u2014 projectRoot=${projectRoot} transport=stdio writable=${String(args.writable)}
|
|
268
282
|
`
|
|
269
283
|
);
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
});
|
|
284
|
+
await handle.done;
|
|
285
|
+
return 0;
|
|
286
|
+
} finally {
|
|
287
|
+
await port.dispose();
|
|
275
288
|
}
|
|
276
|
-
const handle = serveStdio(server);
|
|
277
|
-
process.stderr.write(
|
|
278
|
-
`${SERVER_INFO.name}: ready on stdio \u2014 projectRoot=${projectRoot} transport=stdio writable=${String(args.writable)}
|
|
279
|
-
`
|
|
280
|
-
);
|
|
281
|
-
await handle.done;
|
|
282
|
-
await port.dispose();
|
|
283
|
-
return 0;
|
|
284
289
|
}
|
|
285
290
|
function isMainModule() {
|
|
286
291
|
const entry = process.argv[1];
|
package/dist/index.js
CHANGED
|
@@ -70,7 +70,7 @@ function createSageMcpToolHost(port, opts = {}) {
|
|
|
70
70
|
const allTools = createSageTools(service);
|
|
71
71
|
const allowed = selectAllowedTools(allTools, opts);
|
|
72
72
|
const allowedByName = new Map(allowed.map((entry) => [entry.name, entry.tool]));
|
|
73
|
-
const ctx = createSyntheticContext();
|
|
73
|
+
const ctx = createSyntheticContext(opts.projectRoot);
|
|
74
74
|
const ac = new AbortController();
|
|
75
75
|
const signal = ac.signal;
|
|
76
76
|
function jsonSchemaToObject(schema) {
|
|
@@ -117,11 +117,12 @@ function createSageMcpToolHost(port, opts = {}) {
|
|
|
117
117
|
}
|
|
118
118
|
};
|
|
119
119
|
}
|
|
120
|
-
function createSyntheticContext() {
|
|
120
|
+
function createSyntheticContext(projectRoot) {
|
|
121
|
+
const root = projectRoot ?? process.cwd();
|
|
121
122
|
return {
|
|
122
123
|
systemPrompt: [],
|
|
123
|
-
cwd:
|
|
124
|
-
projectRoot:
|
|
124
|
+
cwd: root,
|
|
125
|
+
projectRoot: root,
|
|
125
126
|
allowOutsideProjectRoot: false,
|
|
126
127
|
model: "sage-mcp",
|
|
127
128
|
tools: [],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wrongstack/sage-mcp",
|
|
3
|
-
"version": "0.306.
|
|
3
|
+
"version": "0.306.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "WrongStack SAGE Memory as an MCP (Model Context Protocol) server: STDIO and loopback HTTP, additive to the existing SAGE IPC server.",
|
|
6
6
|
"repository": {
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"!dist/**/*.map"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@wrongstack/
|
|
35
|
-
"@wrongstack/
|
|
36
|
-
"@wrongstack/
|
|
34
|
+
"@wrongstack/core": "0.306.3",
|
|
35
|
+
"@wrongstack/sage": "0.306.3",
|
|
36
|
+
"@wrongstack/mcp": "0.306.3"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/node": "^26.1.2",
|