Skip to content

Commit 312285b

Browse files
committed
chore: refactor import patterns and update to beta versions
1 parent a853885 commit 312285b

File tree

7 files changed

+49
-42
lines changed

7 files changed

+49
-42
lines changed

deno.lock

Lines changed: 23 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cli/deno.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@mcpc/cli",
3-
"version": "0.1.11",
3+
"version": "0.1.12-beta.1",
44
"repository": {
55
"type": "git",
66
"url": "git+https://github.com/mcpc-tech/mcpc.git"
@@ -12,7 +12,7 @@
1212
"./app": "./src/app.ts"
1313
},
1414
"imports": {
15-
"@mcpc/core": "jsr:@mcpc/core@^0.3.1",
15+
"@mcpc/core": "jsr:@mcpc/core@^0.3.2-beta.1",
1616
"@mcpc/utils": "jsr:@mcpc/utils@^0.2.2",
1717
"@modelcontextprotocol/sdk": "npm:@modelcontextprotocol/sdk@^1.8.0",
1818
"@mcpc-tech/ripgrep-napi": "npm:@mcpc-tech/ripgrep-napi@^0.0.4",

packages/core/deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@mcpc/core",
3-
"version": "0.3.1",
3+
"version": "0.3.2-beta.1",
44
"repository": {
55
"type": "git",
66
"url": "git+https://github.com/mcpc-tech/mcpc.git"

packages/core/src/compose.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ import { sortPluginsByOrder, validatePlugins } from "./plugin-utils.ts";
2929
// Import new manager modules
3030
import { PluginManager } from "./utils/plugin-manager.ts";
3131
import { ToolManager } from "./utils/tool-manager.ts";
32-
import { buildDependencyGroups } from "./utils/compose-helpers.ts";
32+
import {
33+
buildDependencyGroups,
34+
processToolsWithPlugins,
35+
} from "./utils/compose-helpers.ts";
3336
import { sanitizePropertyKey } from "./utils/common/provider.ts";
3437

3538
const ALL_TOOLS_PLACEHOLDER = "__ALL__";
@@ -344,10 +347,7 @@ export class ComposableMCPServer extends Server {
344347
externalTools: Record<string, ComposedTool>,
345348
mode: ExecutionMode,
346349
): Promise<void> {
347-
const { processToolsWithPlugins: processTools } = await import(
348-
"./utils/compose-helpers.ts"
349-
);
350-
await processTools(this, externalTools, mode);
350+
await processToolsWithPlugins(this, externalTools, mode);
351351
}
352352

353353
/**

packages/core/src/types.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { MCPCStep, WorkflowState } from "./utils/state.ts";
2+
13
export type JSONSchema = Record<string, unknown>;
24

35
export type ToolCallback = (args: unknown, extra?: unknown) => unknown;
@@ -20,7 +22,7 @@ export interface RegisterToolParams {
2022
}
2123

2224
export interface RegisterWorkflowToolParams extends RegisterToolParams {
23-
predefinedSteps?: import("./utils/state.ts").MCPCStep[];
25+
predefinedSteps?: MCPCStep[];
2426
ensureStepActions?: string[];
2527
toolNameToIdMapping?: Map<string, string>;
2628
}
@@ -36,9 +38,9 @@ export interface ArgsDefCreator {
3638
action: () => JSONSchema;
3739
forTool: () => JSONSchema;
3840
forCurrentState: (
39-
state: import("./utils/state.ts").WorkflowState,
41+
state: WorkflowState,
4042
) => JSONSchema;
41-
forNextState: (state: import("./utils/state.ts").WorkflowState) => JSONSchema;
43+
forNextState: (state: WorkflowState) => JSONSchema;
4244
forSampling: () => JSONSchema;
4345
forAgentic: (
4446
toolNameToDetailList: [string, unknown][],
@@ -48,11 +50,11 @@ export interface ArgsDefCreator {
4850
) => JSONSchema;
4951
forToolDescription: (
5052
description: string,
51-
state: import("./utils/state.ts").WorkflowState,
53+
state: WorkflowState,
5254
) => string;
5355
forInitialStepDescription: (
54-
steps: import("./utils/state.ts").MCPCStep[],
55-
state: import("./utils/state.ts").WorkflowState,
56+
steps: MCPCStep[],
57+
state: WorkflowState,
5658
) => string;
5759
}
5860

packages/core/src/utils/compose-helpers.ts

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { sanitizePropertyKey } from "./common/provider.ts";
1717
*/
1818
export async function processToolsWithPlugins(
1919
server: ComposableMCPServer,
20-
externalTools: Record<string, ComposedTool>,
20+
_externalTools: Record<string, ComposedTool>,
2121
mode: ExecutionMode,
2222
): Promise<void> {
2323
const toolManager = (server as any).toolManager;
@@ -54,25 +54,6 @@ export async function processToolsWithPlugins(
5454
processedTool.inputSchema as JSONSchema,
5555
processedTool.execute,
5656
);
57-
58-
if (externalTools[toolId]) {
59-
// If a visibility processor is provided by built-in plugins, try to call it.
60-
try {
61-
const builtIn: any = await import("../plugins/built-in/index.ts");
62-
if (builtIn && typeof builtIn.processToolVisibility === "function") {
63-
builtIn.processToolVisibility(
64-
toolId,
65-
processedTool,
66-
server,
67-
externalTools,
68-
);
69-
}
70-
} catch {
71-
// ignore if not present
72-
}
73-
74-
externalTools[toolId] = processedTool;
75-
}
7657
}
7758
}
7859

@@ -98,12 +79,12 @@ export function buildDependencyGroups(
9879
}
9980

10081
if (!tool) {
101-
const allToolNames = [
102-
...toolNameToDetailList.map(([n]) => n),
103-
];
82+
const allToolNames = [...toolNameToDetailList.map(([n]) => n)];
10483
throw new Error(
10584
`Action ${toolName} not found, available action list: ${
106-
allToolNames.join(", ")
85+
allToolNames.join(
86+
", ",
87+
)
10788
}`,
10889
);
10990
}
@@ -153,7 +134,9 @@ export function registerGlobalTools(
153134
if (!tool) {
154135
throw new Error(
155136
`Global tool ${toolId} not found in registry, available: ${
156-
Object.keys(tools).join(", ")
137+
Object.keys(
138+
tools,
139+
).join(", ")
157140
}`,
158141
);
159142
}

packages/mcp-sampling-ai-provider/examples/background_code_analysis.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import { createMCPSamplingProvider } from "../mod.ts";
2121
import { generateText, jsonSchema, stepCountIs, tool } from "ai";
2222
import process from "node:process";
2323
import { convertToAISDKTools } from "../../core/src/ai-sdk-adapter.ts";
24+
import { promisify } from "node:util";
25+
import { execFile } from "node:child_process";
2426

2527
// Store analysis results
2628
const analysisResults = new Map<
@@ -84,8 +86,6 @@ const server = await mcpc(
8486

8587
// Get git diff for changed files
8688
async function getGitDiff(workDir: string, filePath?: string): Promise<string> {
87-
const { promisify } = await import("node:util");
88-
const { execFile } = await import("node:child_process");
8989
const execFilePromise = promisify(execFile);
9090

9191
const args = filePath ? ["diff", "HEAD", filePath] : ["diff", "HEAD"];

0 commit comments

Comments
 (0)