@nwire/mcp 0.12.1 → 0.13.1
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/inspect.d.ts +9 -7
- package/dist/inspect.js +17 -30
- package/dist/mcp-adapter.js +11 -6
- package/dist/write-tools.js +4 -1
- package/package.json +6 -6
package/dist/inspect.d.ts
CHANGED
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
* Inspect tools — proxy a running wire's `/_nwire/*` introspection
|
|
3
3
|
* endpoints (or fall back to the on-disk `.nwire/` cache) as MCP tools.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* expose?" or "show me the last 100 events" without booting anything.
|
|
5
|
+
* The running wire mounts a rich read-only surface (manifest, recent
|
|
6
|
+
* events, dispatch…) at `/_nwire/*`. We adapt that surface into MCP
|
|
7
|
+
* tools so an AI client can ask "what actions does this app expose?" or
|
|
8
|
+
* "show me the last 100 events" without booting anything.
|
|
10
9
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* Telemetry records are now written by TelemetryReporter sinks (file,
|
|
11
|
+
* OTLP, …) rather than streamed over HTTP. The former `recent_telemetry`
|
|
12
|
+
* tool has been removed; read the `.nwire/telemetry/` JSONL files
|
|
13
|
+
* directly or connect an OTLP-compatible viewer.
|
|
13
14
|
*
|
|
15
|
+
* Discovery:
|
|
14
16
|
* 1. If `NWIRE_INSPECT_URL` is set, trust it.
|
|
15
17
|
* 2. Otherwise, probe a small fixed list of ports for a wire that
|
|
16
18
|
* answers `GET /_nwire/events/recent?limit=1` with a JSON array.
|
package/dist/inspect.js
CHANGED
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
* Inspect tools — proxy a running wire's `/_nwire/*` introspection
|
|
3
3
|
* endpoints (or fall back to the on-disk `.nwire/` cache) as MCP tools.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* expose?" or "show me the last 100 events" without booting anything.
|
|
5
|
+
* The running wire mounts a rich read-only surface (manifest, recent
|
|
6
|
+
* events, dispatch…) at `/_nwire/*`. We adapt that surface into MCP
|
|
7
|
+
* tools so an AI client can ask "what actions does this app expose?" or
|
|
8
|
+
* "show me the last 100 events" without booting anything.
|
|
10
9
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* Telemetry records are now written by TelemetryReporter sinks (file,
|
|
11
|
+
* OTLP, …) rather than streamed over HTTP. The former `recent_telemetry`
|
|
12
|
+
* tool has been removed; read the `.nwire/telemetry/` JSONL files
|
|
13
|
+
* directly or connect an OTLP-compatible viewer.
|
|
13
14
|
*
|
|
15
|
+
* Discovery:
|
|
14
16
|
* 1. If `NWIRE_INSPECT_URL` is set, trust it.
|
|
15
17
|
* 2. Otherwise, probe a small fixed list of ports for a wire that
|
|
16
18
|
* answers `GET /_nwire/events/recent?limit=1` with a JSON array.
|
|
@@ -190,8 +192,10 @@ export const inspectTools = [
|
|
|
190
192
|
properties: { module: { type: "string" } },
|
|
191
193
|
},
|
|
192
194
|
async run(args) {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
+
// Structure comes from the deep `.nwire/manifest.json` (the live
|
|
196
|
+
// `/_nwire/manifest` is a thin wire summary with no actions array).
|
|
197
|
+
const disk = readDiskCache("manifest.json");
|
|
198
|
+
const actions = (disk?.actions ?? (await getManifest()).actions ?? []);
|
|
195
199
|
return filterByModule(actions, args.module);
|
|
196
200
|
},
|
|
197
201
|
},
|
|
@@ -204,8 +208,8 @@ export const inspectTools = [
|
|
|
204
208
|
properties: { module: { type: "string" } },
|
|
205
209
|
},
|
|
206
210
|
async run(args) {
|
|
207
|
-
const
|
|
208
|
-
const events = (
|
|
211
|
+
const disk = readDiskCache("manifest.json");
|
|
212
|
+
const events = (disk?.events ?? (await getManifest()).events ?? []);
|
|
209
213
|
return filterByModule(events, args.module);
|
|
210
214
|
},
|
|
211
215
|
},
|
|
@@ -231,11 +235,11 @@ export const inspectTools = [
|
|
|
231
235
|
},
|
|
232
236
|
{
|
|
233
237
|
name: "list_plugins",
|
|
234
|
-
description:
|
|
238
|
+
description: "List discovered plugins (reads .nwire/plugins.json).",
|
|
235
239
|
inputSchema: {
|
|
236
240
|
type: "object",
|
|
237
241
|
additionalProperties: false,
|
|
238
|
-
properties: { kind: { type: "string", enum: ["plugin"
|
|
242
|
+
properties: { kind: { type: "string", enum: ["plugin"] } },
|
|
239
243
|
},
|
|
240
244
|
async run(args) {
|
|
241
245
|
let plugins = readDiskCache("plugins.json");
|
|
@@ -270,23 +274,6 @@ export const inspectTools = [
|
|
|
270
274
|
return httpGetJson(`${url}/_nwire/events/recent?limit=${limit}`);
|
|
271
275
|
},
|
|
272
276
|
},
|
|
273
|
-
{
|
|
274
|
-
name: "recent_telemetry",
|
|
275
|
-
description: "GET /_nwire/telemetry/recent?limit=N from the running wire. Requires a live wire.",
|
|
276
|
-
inputSchema: {
|
|
277
|
-
type: "object",
|
|
278
|
-
additionalProperties: false,
|
|
279
|
-
properties: { limit: { type: "number", minimum: 1, maximum: 10_000 } },
|
|
280
|
-
},
|
|
281
|
-
async run(args) {
|
|
282
|
-
const url = await discoverInspectUrl();
|
|
283
|
-
if (!url) {
|
|
284
|
-
throw new Error("no running wire detected; recent_telemetry requires a live wire.");
|
|
285
|
-
}
|
|
286
|
-
const limit = typeof args.limit === "number" ? args.limit : 100;
|
|
287
|
-
return httpGetJson(`${url}/_nwire/telemetry/recent?limit=${limit}`);
|
|
288
|
-
},
|
|
289
|
-
},
|
|
290
277
|
];
|
|
291
278
|
export function findInspectTool(name) {
|
|
292
279
|
return inspectTools.find((t) => t.name === name);
|
package/dist/mcp-adapter.js
CHANGED
|
@@ -56,12 +56,17 @@ export function mcpAdapter(config = {}) {
|
|
|
56
56
|
const reqContainer = parentContainer.createScope();
|
|
57
57
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
58
58
|
const wireApp = wire.app;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return await
|
|
59
|
+
const runtime = wireApp?.runtime;
|
|
60
|
+
if (runtime?.receive) {
|
|
61
|
+
// Unified inbound — the MCP tool call becomes a command on the
|
|
62
|
+
// runtime's source chain (the same path http-koa uses). The terminal
|
|
63
|
+
// router lands it on runtime.execute and threads the logger extra.
|
|
64
|
+
return await runtime.receive({
|
|
65
|
+
kind: "command",
|
|
66
|
+
name: wire.handler?.name ?? binding.tool,
|
|
67
|
+
input: parsedInput,
|
|
68
|
+
target: wire.handler,
|
|
69
|
+
}, { extras: { logger } });
|
|
65
70
|
}
|
|
66
71
|
const handlerCtx = {
|
|
67
72
|
resolve: (name) => reqContainer.resolve(name),
|
package/dist/write-tools.js
CHANGED
|
@@ -109,7 +109,10 @@ const dispatchAction = {
|
|
|
109
109
|
const user = args.user;
|
|
110
110
|
const tenant = args.tenant;
|
|
111
111
|
const payload = {
|
|
112
|
-
|
|
112
|
+
// The inspect `/dispatch` endpoint dispatches any handler by name and
|
|
113
|
+
// reads `body.handler` (Studio's Dispatch panel sends the same). Keep the
|
|
114
|
+
// tool arg `action` for UX, but POST it as `handler`.
|
|
115
|
+
handler: action,
|
|
113
116
|
input: args.input ?? {},
|
|
114
117
|
...(user?.id !== undefined && { userId: user.id }),
|
|
115
118
|
...(tenant !== undefined && { tenant }),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nwire/mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Nwire MCP (Model Context Protocol) server — exposes the kernel's CommandRouter as MCP tools over stdio. AI clients (Claude, Cursor, …) drive nwire commands the same way the CLI and Studio do.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
"access": "public"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@nwire/container": "0.
|
|
26
|
-
"@nwire/logger": "0.
|
|
27
|
-
"@nwire/wires": "0.
|
|
28
|
-
"@nwire/
|
|
29
|
-
"@nwire/
|
|
25
|
+
"@nwire/container": "0.13.1",
|
|
26
|
+
"@nwire/logger": "0.13.1",
|
|
27
|
+
"@nwire/wires": "0.13.1",
|
|
28
|
+
"@nwire/endpoint": "0.13.1",
|
|
29
|
+
"@nwire/supervisor": "0.13.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/node": "^22.19.9",
|