Skip to content

Commit d8b07cf

Browse files
committed
feat(core): add workflows provision writer
- Implement workflowsWriter (ProvisionWriterDef) producing McpServerEntry with npx command and configurable env - 5 behavioral tests https://claude.ai/code/session_01GCqwdfAMznLZZ97tYfJXRa
1 parent f2e1bf4 commit d8b07cf

2 files changed

Lines changed: 82 additions & 0 deletions

File tree

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import { describe, it, expect } from "vitest";
2+
import { workflowsWriter } from "./workflows.js";
3+
import type { ResolutionContext } from "../types.js";
4+
5+
describe("workflowsWriter", () => {
6+
const context: ResolutionContext = { resolved: {} };
7+
8+
it("has id 'workflows'", () => {
9+
expect(workflowsWriter.id).toBe("workflows");
10+
});
11+
12+
it("returns mcp_servers with correct ref, command, and args for a given package", async () => {
13+
const result = await workflowsWriter.write(
14+
{ package: "@codemcp/workflows-server" },
15+
context
16+
);
17+
expect(result).toEqual({
18+
mcp_servers: [
19+
{
20+
ref: "@codemcp/workflows-server",
21+
command: "npx",
22+
args: ["-y", "@codemcp/workflows-server"],
23+
env: {}
24+
}
25+
]
26+
});
27+
});
28+
29+
it("includes env in the entry when env is specified", async () => {
30+
const result = await workflowsWriter.write(
31+
{
32+
package: "@codemcp/workflows-server",
33+
env: { API_KEY: "secret", NODE_ENV: "production" }
34+
},
35+
context
36+
);
37+
expect(result.mcp_servers![0].env).toEqual({
38+
API_KEY: "secret",
39+
NODE_ENV: "production"
40+
});
41+
});
42+
43+
it("defaults env to an empty object when not specified", async () => {
44+
const result = await workflowsWriter.write(
45+
{ package: "@codemcp/workflows-server" },
46+
context
47+
);
48+
expect(result.mcp_servers![0].env).toEqual({});
49+
});
50+
51+
it("only returns mcp_servers, not other LogicalConfig keys", async () => {
52+
const result = await workflowsWriter.write(
53+
{ package: "@codemcp/workflows-server" },
54+
context
55+
);
56+
expect(Object.keys(result)).toEqual(["mcp_servers"]);
57+
expect(result).not.toHaveProperty("instructions");
58+
expect(result).not.toHaveProperty("cli_actions");
59+
expect(result).not.toHaveProperty("knowledge_sources");
60+
});
61+
});
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import type { ProvisionWriterDef } from "../types.js";
2+
3+
export const workflowsWriter: ProvisionWriterDef = {
4+
id: "workflows",
5+
async write(config) {
6+
const { package: pkg, env } = config as {
7+
package: string;
8+
env?: Record<string, string>;
9+
};
10+
return {
11+
mcp_servers: [
12+
{
13+
ref: pkg,
14+
command: "npx",
15+
args: ["-y", pkg],
16+
env: env ?? {}
17+
}
18+
]
19+
};
20+
}
21+
};

0 commit comments

Comments
 (0)