@minicor/mcp-server 3.3.1 → 3.3.4
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/README.md +36 -3
- package/dist/__tests__/codemode.test.d.ts +2 -0
- package/dist/__tests__/codemode.test.d.ts.map +1 -0
- package/dist/__tests__/codemode.test.js +129 -0
- package/dist/__tests__/codemode.test.js.map +1 -0
- package/dist/codemode.d.ts +60 -0
- package/dist/codemode.d.ts.map +1 -0
- package/dist/codemode.js +726 -0
- package/dist/codemode.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -2
- package/dist/index.js.map +1 -1
- package/dist/laminar-client.d.ts.map +1 -1
- package/dist/laminar-client.js +3 -1
- package/dist/laminar-client.js.map +1 -1
- package/dist/lib.d.ts +2 -0
- package/dist/lib.d.ts.map +1 -1
- package/dist/lib.js +17 -2
- package/dist/lib.js.map +1 -1
- package/dist/tools/core.js +2 -2
- package/dist/tools/core.js.map +1 -1
- package/dist/tools/workflow-ops.js +1 -1
- package/dist/tools/workflow-ops.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ claude mcp add minicor -- minicor-mcp
|
|
|
29
29
|
### 2. Authenticate
|
|
30
30
|
|
|
31
31
|
```bash
|
|
32
|
-
npx @minicor/mcp-server
|
|
32
|
+
npx @minicor/mcp-server
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
Opens a browser to sign in. Tokens stored at `~/.minicor/tokens.json` with auto-refresh. For headless: `npx @minicor/mcp-server-setup --cli`.
|
|
@@ -53,9 +53,43 @@ npx @minicor/mcp-server minicor-bootstrap all --dir ./my-workspace
|
|
|
53
53
|
|
|
54
54
|
`npx` users: restart your editor (auto-fetches latest). Global: `npm update -g @minicor/mcp-server`.
|
|
55
55
|
|
|
56
|
+
## Code Mode
|
|
57
|
+
|
|
58
|
+
Authenticated servers now default to a code-mode MCP surface. Instead of exposing every Minicor operation as a separate MCP tool, the server exposes one `codemode` tool that runs JavaScript and provides Minicor methods as async functions on the `minicor` global:
|
|
59
|
+
|
|
60
|
+
```javascript
|
|
61
|
+
const workspaces = await minicor.list_workspaces({});
|
|
62
|
+
const matches = await codemode.search("workflow");
|
|
63
|
+
const docs = await codemode.describe("minicor.create_rpa_flow");
|
|
64
|
+
return { workspaces, matches, docs };
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
This follows Cloudflare's Code Mode pattern: the model writes code that chains tool calls, branches, loops, and composes results locally instead of making one model round trip per operation.
|
|
68
|
+
|
|
69
|
+
Inside `codemode`:
|
|
70
|
+
|
|
71
|
+
- `await minicor.tool_name({ ... })` calls a Minicor MCP operation.
|
|
72
|
+
- `await codemode.search("query")` discovers relevant methods.
|
|
73
|
+
- `await codemode.describe("minicor.tool_name")` returns TypeScript-style parameter docs.
|
|
74
|
+
- `await codemode.list()` lists all available methods.
|
|
75
|
+
|
|
76
|
+
If you need the legacy one-tool-per-operation surface, set either environment variable before launching the server:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
MINICOR_MCP_LEGACY_TOOLS=1 minicor-mcp
|
|
80
|
+
# or
|
|
81
|
+
MINICOR_MCP_CODE_MODE=0 minicor-mcp
|
|
82
|
+
```
|
|
83
|
+
|
|
56
84
|
## Session Lifecycle
|
|
57
85
|
|
|
58
|
-
The MCP server sends **instructions** to every client on connect, telling agents to
|
|
86
|
+
The MCP server sends **instructions** to every client on connect, telling agents to start a session first when in a workspace clone. In code mode, call `session_start` through the `codemode` tool:
|
|
87
|
+
|
|
88
|
+
```javascript
|
|
89
|
+
return await minicor.session_start({ directory: "/path/to/workspace" });
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
This works across all harnesses, including Claude Code, Cursor, and Bedrock.
|
|
59
93
|
|
|
60
94
|
### Session Tools
|
|
61
95
|
|
|
@@ -431,4 +465,3 @@ src/
|
|
|
431
465
|
skills/
|
|
432
466
|
general/ — Bundled skill files (shipped with npm package)
|
|
433
467
|
```
|
|
434
|
-
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codemode.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/codemode.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { CodeModeToolRegistry, compactToolDocs } from "../codemode.js";
|
|
4
|
+
import { ok, text } from "../helpers.js";
|
|
5
|
+
function createFakeServer() {
|
|
6
|
+
const exposed = new Map();
|
|
7
|
+
const server = {
|
|
8
|
+
tool: vi.fn((name, ...args) => {
|
|
9
|
+
exposed.set(name, args[args.length - 1]);
|
|
10
|
+
}),
|
|
11
|
+
prompt: vi.fn(),
|
|
12
|
+
};
|
|
13
|
+
return { server, exposed };
|
|
14
|
+
}
|
|
15
|
+
function parseCodeModeResult(response) {
|
|
16
|
+
return JSON.parse(response.content[0].text);
|
|
17
|
+
}
|
|
18
|
+
describe("CodeModeToolRegistry", () => {
|
|
19
|
+
it("captures legacy tools and exposes a single codemode tool", async () => {
|
|
20
|
+
const { server, exposed } = createFakeServer();
|
|
21
|
+
const registry = new CodeModeToolRegistry(server);
|
|
22
|
+
registry.tool("add_numbers", "Add two numbers.", {
|
|
23
|
+
a: z.number().describe("First number"),
|
|
24
|
+
b: z.number().describe("Second number"),
|
|
25
|
+
}, async ({ a, b }) => ok({ sum: a + b }));
|
|
26
|
+
registry.registerCodeModeTool();
|
|
27
|
+
expect(exposed.has("add_numbers")).toBe(false);
|
|
28
|
+
expect(exposed.has("codemode")).toBe(true);
|
|
29
|
+
const response = await exposed.get("codemode")({
|
|
30
|
+
code: `
|
|
31
|
+
const added = await minicor.add_numbers({ a: 2, b: 3 });
|
|
32
|
+
return added;
|
|
33
|
+
`,
|
|
34
|
+
});
|
|
35
|
+
const result = parseCodeModeResult(response);
|
|
36
|
+
expect(result.status).toBe("completed");
|
|
37
|
+
expect(result.result).toEqual({ sum: 5 });
|
|
38
|
+
});
|
|
39
|
+
it("supports in-sandbox search and describe", async () => {
|
|
40
|
+
const { server, exposed } = createFakeServer();
|
|
41
|
+
const registry = new CodeModeToolRegistry(server);
|
|
42
|
+
registry.tool("list_workspaces", "List all workspaces the user has access to.", {
|
|
43
|
+
region: z.enum(["us", "ca"]).optional().describe("Region filter"),
|
|
44
|
+
}, async () => ok([]));
|
|
45
|
+
registry.registerCodeModeTool();
|
|
46
|
+
const response = await exposed.get("codemode")({
|
|
47
|
+
code: `
|
|
48
|
+
const matches = await codemode.search("workspace");
|
|
49
|
+
const docs = await codemode.describe("minicor.list_workspaces");
|
|
50
|
+
return { matches, docs };
|
|
51
|
+
`,
|
|
52
|
+
});
|
|
53
|
+
const result = parseCodeModeResult(response);
|
|
54
|
+
expect(result.status).toBe("completed");
|
|
55
|
+
expect(result.result.matches[0].name).toBe("minicor.list_workspaces");
|
|
56
|
+
expect(result.result.docs.signature).toContain("interface ListWorkspacesInput");
|
|
57
|
+
expect(result.result.docs.signature).toContain("region?");
|
|
58
|
+
});
|
|
59
|
+
it("passes text tool results through as strings when they are not JSON", async () => {
|
|
60
|
+
const { server, exposed } = createFakeServer();
|
|
61
|
+
const registry = new CodeModeToolRegistry(server);
|
|
62
|
+
registry.tool("say_hello", "Say hello.", {}, async () => text("hello"));
|
|
63
|
+
registry.registerCodeModeTool();
|
|
64
|
+
const response = await exposed.get("codemode")({
|
|
65
|
+
code: `return await minicor.say_hello({});`,
|
|
66
|
+
});
|
|
67
|
+
const result = parseCodeModeResult(response);
|
|
68
|
+
expect(result.status).toBe("completed");
|
|
69
|
+
expect(result.result).toBe("hello");
|
|
70
|
+
});
|
|
71
|
+
it("executes parenthesized async arrow functions", async () => {
|
|
72
|
+
const { server, exposed } = createFakeServer();
|
|
73
|
+
const registry = new CodeModeToolRegistry(server);
|
|
74
|
+
registry.tool("say_hello", "Say hello.", {}, async () => text("hello"));
|
|
75
|
+
registry.registerCodeModeTool();
|
|
76
|
+
const response = await exposed.get("codemode")({
|
|
77
|
+
code: `(async () => {
|
|
78
|
+
return await minicor.say_hello({});
|
|
79
|
+
})`,
|
|
80
|
+
});
|
|
81
|
+
const result = parseCodeModeResult(response);
|
|
82
|
+
expect(result.status).toBe("completed");
|
|
83
|
+
expect(result.result).toBe("hello");
|
|
84
|
+
});
|
|
85
|
+
it("keeps renderable content out of the JSON text payload", async () => {
|
|
86
|
+
const { server, exposed } = createFakeServer();
|
|
87
|
+
const registry = new CodeModeToolRegistry(server);
|
|
88
|
+
registry.tool("screenshot", "Return an image.", {}, async () => ({
|
|
89
|
+
content: [
|
|
90
|
+
{
|
|
91
|
+
type: "image",
|
|
92
|
+
data: "abc123",
|
|
93
|
+
mimeType: "image/png",
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
}));
|
|
97
|
+
registry.registerCodeModeTool();
|
|
98
|
+
const response = await exposed.get("codemode")({
|
|
99
|
+
code: `return await minicor.screenshot({});`,
|
|
100
|
+
});
|
|
101
|
+
const result = parseCodeModeResult(response);
|
|
102
|
+
expect(result.result.content[0].data).toBe("[6 base64 chars omitted from text summary]");
|
|
103
|
+
expect(response.content[1]).toMatchObject({
|
|
104
|
+
type: "image",
|
|
105
|
+
data: "abc123",
|
|
106
|
+
mimeType: "image/png",
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
it("can still expose legacy tools when requested", () => {
|
|
110
|
+
const { server } = createFakeServer();
|
|
111
|
+
const registry = new CodeModeToolRegistry(server, { exposeLegacyTools: true });
|
|
112
|
+
registry.tool("legacy_tool", "Legacy tool.", {}, async () => ok({ ok: true }));
|
|
113
|
+
expect(server.tool.mock.calls[0][0]).toBe("legacy_tool");
|
|
114
|
+
});
|
|
115
|
+
it("builds compact docs from captured tools", () => {
|
|
116
|
+
const { server } = createFakeServer();
|
|
117
|
+
const registry = new CodeModeToolRegistry(server);
|
|
118
|
+
registry.tool("create-workflow", "Create a workflow.", {
|
|
119
|
+
name: z.string().describe("Workflow name"),
|
|
120
|
+
}, async () => ok({ id: 1 }));
|
|
121
|
+
const docs = compactToolDocs(registry.docs());
|
|
122
|
+
expect(docs[0]).toMatchObject({
|
|
123
|
+
name: "minicor.create_workflow",
|
|
124
|
+
tool: "create-workflow",
|
|
125
|
+
description: "Create a workflow.",
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
//# sourceMappingURL=codemode.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codemode.test.js","sourceRoot":"","sources":["../../src/__tests__/codemode.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAEzC,SAAS,gBAAgB;IACvB,MAAM,OAAO,GAAG,IAAI,GAAG,EAAe,CAAC;IACvC,MAAM,MAAM,GAAG;QACb,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,IAAY,EAAE,GAAG,IAAW,EAAE,EAAE;YAC3C,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;QAC3C,CAAC,CAAC;QACF,MAAM,EAAE,EAAE,CAAC,EAAE,EAAE;KACQ,CAAC;IAC1B,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAC7B,CAAC;AAED,SAAS,mBAAmB,CAAC,QAAa;IACxC,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAC9C,CAAC;AAED,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;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C,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAE/E,MAAM,CAAE,MAAM,CAAC,IAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE;QACjD,MAAM,EAAE,MAAM,EAAE,GAAG,gBAAgB,EAAE,CAAC;QACtC,MAAM,QAAQ,GAAG,IAAI,oBAAoB,CAAC,MAAM,CAAC,CAAC;QAElD,QAAQ,CAAC,IAAI,CACX,iBAAiB,EACjB,oBAAoB,EACpB;YACE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,eAAe,CAAC;SAC3C,EACD,KAAK,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAC1B,CAAC;QAEF,MAAM,IAAI,GAAG,eAAe,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;QAC9C,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;YAC5B,IAAI,EAAE,yBAAyB;YAC/B,IAAI,EAAE,iBAAiB;YACvB,WAAW,EAAE,oBAAoB;SAClC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
interface ToolDoc {
|
|
3
|
+
name: string;
|
|
4
|
+
apiName: string;
|
|
5
|
+
qualifiedName: string;
|
|
6
|
+
description: string;
|
|
7
|
+
parameters: Array<{
|
|
8
|
+
name: string;
|
|
9
|
+
optional: boolean;
|
|
10
|
+
type: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
}>;
|
|
13
|
+
signature: string;
|
|
14
|
+
}
|
|
15
|
+
interface CodeModeOptions {
|
|
16
|
+
exposeLegacyTools?: boolean;
|
|
17
|
+
defaultTimeoutMs?: number;
|
|
18
|
+
maxTimeoutMs?: number;
|
|
19
|
+
}
|
|
20
|
+
export declare class CodeModeToolRegistry {
|
|
21
|
+
private readonly server;
|
|
22
|
+
private readonly tools;
|
|
23
|
+
private readonly byApiName;
|
|
24
|
+
private readonly exposeLegacyTools;
|
|
25
|
+
private readonly defaultTimeoutMs;
|
|
26
|
+
private readonly maxTimeoutMs;
|
|
27
|
+
constructor(server: McpServer, options?: CodeModeOptions);
|
|
28
|
+
tool(name: string, ...args: any[]): any;
|
|
29
|
+
prompt(...args: any[]): any;
|
|
30
|
+
registerCodeModeTool(): void;
|
|
31
|
+
docs(): ToolDoc[];
|
|
32
|
+
execute(code: string, timeoutMs?: number): Promise<{
|
|
33
|
+
status: "completed" | "error";
|
|
34
|
+
executionMs: number;
|
|
35
|
+
result?: unknown;
|
|
36
|
+
error?: string;
|
|
37
|
+
logs: Array<{
|
|
38
|
+
level: string;
|
|
39
|
+
message: string;
|
|
40
|
+
}>;
|
|
41
|
+
}>;
|
|
42
|
+
private invoke;
|
|
43
|
+
private uniqueApiName;
|
|
44
|
+
}
|
|
45
|
+
export declare function shouldUseCodeMode(): boolean;
|
|
46
|
+
export declare function buildCodeModeInstructions(baseInstructions: string): string;
|
|
47
|
+
export declare function asMcpServer(registry: CodeModeToolRegistry): McpServer;
|
|
48
|
+
export declare function compactToolDocs(tools: ToolDoc[]): {
|
|
49
|
+
name: string;
|
|
50
|
+
tool: string;
|
|
51
|
+
description: string;
|
|
52
|
+
parameters: {
|
|
53
|
+
name: string;
|
|
54
|
+
type: string;
|
|
55
|
+
optional: boolean;
|
|
56
|
+
description: string | undefined;
|
|
57
|
+
}[];
|
|
58
|
+
}[];
|
|
59
|
+
export {};
|
|
60
|
+
//# sourceMappingURL=codemode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codemode.d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