Skip to content

Commit fbfb49a

Browse files
committed
feat(workspaces): migrate to Deno workspaces and improve validation
This commit introduces two major improvements to the monorepo structure and a key dependency: 1. **Migration to Deno Workspaces:** The project has been migrated to use Deno's native workspace functionality. This simplifies local package management and dependency resolution. - An import map has been added to the root `deno.json` for all internal packages (e.g., `@mcpc/core`). - Package `deno.json` files now use `workspace:^` to reference other packages within the monorepo, replacing the previous `jsr:` specifiers. - Package versions have been bumped across the repository to reflect these structural changes. 2. **Refactor Validation in `plugin-code-execution`:** The validation logic for tool arguments in the `plugin-code-execution` package has been refactored. - Switched from `json-schema-to-zod` and `zod` to using `ajv` with `ajv-errors`. - This removes the intermediate step of converting JSON schema to a Zod schema, simplifying the validation process and reducing dependencies. - Error messages are now more user-friendly, directly using the output from `ajv-errors`.
1 parent e467851 commit fbfb49a

File tree

12 files changed

+97
-39
lines changed

12 files changed

+97
-39
lines changed

deno.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
"./packages/plugin-code-execution"
1818
],
1919
"imports": {
20+
"@mcpc/utils": "./packages/utils/mod.ts",
21+
"@mcpc/core": "./packages/core/mod.ts",
22+
"@mcpc/cli": "./packages/cli/mod.ts",
23+
"@mcpc/acp-ai-provider": "./packages/acp-ai-provider/mod.ts",
24+
"@mcpc/mcp-sampling-ai-provider": "./packages/mcp-sampling-ai-provider/mod.ts",
25+
"@mcpc/builder": "./packages/mcpc-builder/mod.ts",
26+
"@mcpc/plugin-code-execution": "./packages/plugin-code-execution/mod.ts",
2027
"@es-toolkit/es-toolkit": "jsr:@es-toolkit/es-toolkit@^1.37.2",
2128
"json-schema-faker": "npm:json-schema-faker@^0.5.9",
2229
"json-schema-traverse": "npm:json-schema-traverse@^1.0.0"

deno.lock

Lines changed: 13 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/acp-ai-provider/deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"imports": {
1515
"@agentclientprotocol/sdk": "npm:@agentclientprotocol/sdk@^0.4.8",
16-
"@mcpc/core": "jsr:@mcpc/core@^0.3.4",
16+
"@mcpc/core": "jsr:@mcpc/core@^0.3.9",
1717
"@modelcontextprotocol/sdk": "npm:@modelcontextprotocol/sdk@^1.8.0",
1818
"@ai-sdk/provider": "npm:@ai-sdk/provider@^2.0.0",
1919
"@ai-sdk/provider-utils": "npm:@ai-sdk/provider-utils@^2.2.8",

packages/cli/deno.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
"./app": "./src/app.ts"
1313
},
1414
"imports": {
15-
"@mcpc-tech/plugin-code-execution": "npm:@mcpc-tech/plugin-code-execution@^0.0.6",
16-
"@mcpc/core": "jsr:@mcpc/core@^0.3.7",
17-
"@mcpc/utils": "jsr:@mcpc/utils@^0.2.2",
15+
"@mcpc-tech/plugin-code-execution": "npm:@mcpc-tech/plugin-code-execution@^0.0.8",
16+
"@mcpc/core": "jsr:@mcpc/core@^0.3.9",
17+
"@mcpc/utils": "jsr:@mcpc/utils@^0.2.5",
1818
"@modelcontextprotocol/sdk": "npm:@modelcontextprotocol/sdk@^1.8.0",
1919
"@mcpc-tech/ripgrep-napi": "npm:@mcpc-tech/ripgrep-napi@^0.0.4",
2020
"@hono/zod-openapi": "npm:@hono/zod-openapi@^0.19.2",

packages/cli/src/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const createServer = async (
1717
{
1818
name: null,
1919
description: "",
20-
plugins: [createLargeResultPlugin({}), codeExecutionPlugin()],
20+
plugins: [createLargeResultPlugin({}), codeExecutionPlugin],
2121
options: {
2222
mode: "code_execution",
2323
},

packages/cli/tests/config_loader_test.ts

Lines changed: 66 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,72 @@ Deno.test("Config Loader - object format", async () => {
116116
});
117117

118118
Deno.test("Config Loader - no config returns null", async () => {
119-
// Ensure no config sources are set
120-
delete process.env.MCPC_CONFIG;
121-
delete process.env.MCPC_CONFIG_URL;
122-
delete process.env.MCPC_CONFIG_FILE;
123-
124-
// Test
125-
const config = await loadConfig();
126-
127-
// Verify - should return null when no config found
128-
assertEquals(config, null);
119+
// Save original argv and cwd
120+
const originalArgv = process.argv;
121+
const originalCwd = Deno.cwd();
122+
123+
// Create a temp directory with no config files
124+
const tempDir = await Deno.makeTempDir();
125+
126+
try {
127+
// Change to temp directory (no mcpc.config.json exists)
128+
Deno.chdir(tempDir);
129+
130+
// Set clean argv without any flags
131+
Object.defineProperty(process, "argv", {
132+
value: ["deno", "run"],
133+
configurable: true,
134+
writable: true,
135+
});
136+
137+
// Ensure no config sources are set
138+
delete process.env.MCPC_CONFIG;
139+
delete process.env.MCPC_CONFIG_URL;
140+
delete process.env.MCPC_CONFIG_FILE;
141+
142+
// Temporarily rename user config if it exists
143+
const userConfigPath = `${Deno.env.get("HOME")}/.mcpc/config.json`;
144+
const userConfigBackup = `${userConfigPath}.backup`;
145+
let hadUserConfig = false;
146+
try {
147+
await Deno.rename(userConfigPath, userConfigBackup);
148+
hadUserConfig = true;
149+
} catch {
150+
// User config doesn't exist, that's fine
151+
}
152+
153+
try {
154+
// Test
155+
const config = await loadConfig();
156+
157+
// Verify - should return null when no config found
158+
assertEquals(config, null);
159+
} finally {
160+
// Restore user config if we backed it up
161+
if (hadUserConfig) {
162+
try {
163+
await Deno.rename(userConfigBackup, userConfigPath);
164+
} catch {
165+
// Ignore errors during restore
166+
}
167+
}
168+
}
169+
} finally {
170+
// Restore original cwd and argv
171+
Deno.chdir(originalCwd);
172+
Object.defineProperty(process, "argv", {
173+
value: originalArgv,
174+
configurable: true,
175+
writable: true,
176+
});
177+
178+
// Cleanup temp directory
179+
try {
180+
await Deno.remove(tempDir, { recursive: true });
181+
} catch {
182+
// Ignore cleanup errors
183+
}
184+
}
129185
});
130186

131187
Deno.test("Config Loader - nested environment variable substitution", async () => {

packages/cli/tests/wrap_mode_test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ Deno.test("wrap mode - parse multiple servers with different transports", async
119119

120120
// Check third server (sse)
121121
const sseConfig = mcpServers?.["https___api_example_com_sse"] as any;
122-
assertEquals(sseConfig?.command, "npx");
122+
assertEquals(sseConfig?.command, "https://api.example.com/sse");
123123
assertEquals(sseConfig?.args, []);
124124
assertEquals(
125125
mcpServers?.["https___api_example_com_sse"]?.transportType,

packages/core/deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"test:watch": "deno test --allow-all --watch tests/"
1818
},
1919
"imports": {
20-
"@mcpc/utils": "jsr:@mcpc/utils@^0.2.0",
20+
"@mcpc/utils": "jsr:@mcpc/utils@^0.2.5",
2121
"@mcpc-tech/ripgrep-napi": "npm:@mcpc-tech/ripgrep-napi@^0.0.4",
2222
"@modelcontextprotocol/sdk": "npm:@modelcontextprotocol/sdk@^1.8.0",
2323
"@opentelemetry/api": "npm:@opentelemetry/api@^1.9.0",

packages/mcp-sampling-ai-provider/deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"test": "deno test --allow-all tests/"
1313
},
1414
"imports": {
15-
"@mcpc/core": "jsr:@mcpc/core@^0.3.4",
15+
"@mcpc/core": "jsr:@mcpc/core@^0.3.9",
1616
"@modelcontextprotocol/sdk": "npm:@modelcontextprotocol/sdk@^1.8.0",
1717
"@ai-sdk/provider": "npm:@ai-sdk/provider@^2.0.0",
1818
"@ai-sdk/provider-utils": "npm:@ai-sdk/provider-utils@^2.2.8",

packages/mcpc-builder/deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"mcpc-builder-agent": "./mcpc-builder-agent.ts"
1414
},
1515
"imports": {
16-
"@mcpc/core": "jsr:@mcpc/core@^0.3.4",
16+
"@mcpc/core": "jsr:@mcpc/core@^0.3.9",
1717
"@modelcontextprotocol/sdk": "npm:@modelcontextprotocol/sdk@^1.8.0",
1818
"@std/assert": "jsr:@std/assert@^1.0.14",
1919
"zod": "npm:zod@^3.24.2"

0 commit comments

Comments
 (0)