@lenso/mcp 0.1.0 → 0.2.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/index.d.ts +2 -0
- package/dist/index.js +23 -6
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type OperationBinding } from "@lenso/engine/application";
|
|
1
2
|
export interface StdioOptions {
|
|
2
3
|
/** Trusted launch configuration, never supplied by an MCP tool. */
|
|
3
4
|
root: string;
|
|
@@ -8,6 +9,7 @@ export interface StdioOptions {
|
|
|
8
9
|
maxInputBytes?: number;
|
|
9
10
|
maxOutputBytes?: number;
|
|
10
11
|
maxFrameBytes?: number;
|
|
12
|
+
binding?: OperationBinding;
|
|
11
13
|
}
|
|
12
14
|
/**
|
|
13
15
|
* Owns a dedicated stdio process. Tools translate only to CLI call; no app or
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// src/index.ts
|
|
3
3
|
import { Console } from "console";
|
|
4
|
-
import { resolve } from "path";
|
|
4
|
+
import { join, resolve } from "path";
|
|
5
5
|
import { Writable } from "stream";
|
|
6
6
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
7
7
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
@@ -12,7 +12,13 @@ import {
|
|
|
12
12
|
McpError,
|
|
13
13
|
ToolSchema
|
|
14
14
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
15
|
-
import {
|
|
15
|
+
import { invoke, CliError, diagnostic } from "@lenso/cli";
|
|
16
|
+
import { readApplication } from "@lenso/engine/application";
|
|
17
|
+
import {
|
|
18
|
+
describeOperation,
|
|
19
|
+
redactOperationDescription,
|
|
20
|
+
validateOperations
|
|
21
|
+
} from "@lenso/engine/operations";
|
|
16
22
|
import { environmentSecrets, redact, stableJson } from "@lenso/engine/diagnostics";
|
|
17
23
|
var serving = false;
|
|
18
24
|
function failure(code, phase, message) {
|
|
@@ -135,7 +141,8 @@ async function serveStdio(options) {
|
|
|
135
141
|
});
|
|
136
142
|
};
|
|
137
143
|
try {
|
|
138
|
-
const
|
|
144
|
+
const { app, configPath } = await readApplication(root, join(root, "lenso.config.ts"));
|
|
145
|
+
const selected = validateOperations(app.plugins, app.mcpOperations ?? app.operations ?? []);
|
|
139
146
|
const tools = [];
|
|
140
147
|
const bindings = new Map;
|
|
141
148
|
const seen = new Set;
|
|
@@ -144,7 +151,8 @@ async function serveStdio(options) {
|
|
|
144
151
|
if (seen.has(key))
|
|
145
152
|
throw failure("duplicate-operation", "discovery", "Duplicate MCP allowlist entry.");
|
|
146
153
|
seen.add(key);
|
|
147
|
-
const
|
|
154
|
+
const ref = selected.find((item) => item.plugin.id === allowed.pluginId && item.method === allowed.method);
|
|
155
|
+
const operation = ref ? redactOperationDescription(describeOperation(ref, configPath)) : undefined;
|
|
148
156
|
if (!operation)
|
|
149
157
|
throw failure("unknown-operation", "discovery", "MCP allowlist operation is not declared.");
|
|
150
158
|
const schema = operation.inputSchema;
|
|
@@ -197,7 +205,10 @@ async function serveStdio(options) {
|
|
|
197
205
|
const input = request.params.arguments ?? {};
|
|
198
206
|
if (Buffer.byteLength(stableJson(input)) > maxInput)
|
|
199
207
|
throw failure("input-too-large", "input", "Operation input exceeds the host limit.");
|
|
200
|
-
const data = await
|
|
208
|
+
const data = await invoke({ ...app, operations: selected, operationBinding: undefined }, binding.pluginId, binding.method, input, async (operation, validatedInput, running) => ({
|
|
209
|
+
...options.binding ? await options.binding(operation, validatedInput, running) : {},
|
|
210
|
+
maxOutputBytes: maxOutput
|
|
211
|
+
}));
|
|
201
212
|
if (extra.signal.aborted)
|
|
202
213
|
throw failure("request-cancelled", "invoke", "Request cancelled; operation may have completed. Cleanup was awaited.");
|
|
203
214
|
return result(data, maxOutput);
|
|
@@ -223,7 +234,13 @@ async function serveStdio(options) {
|
|
|
223
234
|
await server.connect(new StdioServerTransport(process.stdin, process.stdout, { maxBufferSize: maxFrame }));
|
|
224
235
|
return { close };
|
|
225
236
|
} catch (error) {
|
|
226
|
-
|
|
237
|
+
try {
|
|
238
|
+
await close();
|
|
239
|
+
} catch (closeError) {
|
|
240
|
+
throw new AggregateError([error, closeError], "MCP startup and close failed.", {
|
|
241
|
+
cause: closeError
|
|
242
|
+
});
|
|
243
|
+
}
|
|
227
244
|
throw error;
|
|
228
245
|
}
|
|
229
246
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lenso/mcp",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
"test": "bun test"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@lenso/cli": "^0.
|
|
28
|
-
"@lenso/engine": "^0.
|
|
27
|
+
"@lenso/cli": "^0.19.1",
|
|
28
|
+
"@lenso/engine": "^0.3.0",
|
|
29
29
|
"@modelcontextprotocol/sdk": "1.32.1",
|
|
30
30
|
"zod": "4.6.5"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@lenso/core": "^0.1
|
|
33
|
+
"@lenso/core": "^0.2.1"
|
|
34
34
|
}
|
|
35
35
|
}
|