Skip to content

Commit 57d1143

Browse files
committed
chore: add precommit task to deno.json and fix formatting issues in compose.ts and logging-plugin.ts
1 parent 641cd0e commit 57d1143

File tree

3 files changed

+33
-29
lines changed

3 files changed

+33
-29
lines changed

deno.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
22
"vendor": true,
33
"nodeModulesDir": "auto",
4-
"tasks": {},
4+
"tasks": {
5+
"precommit": "deno lint && deno check && deno fmt"
6+
},
57
"workspace": ["./packages/core"],
68
"imports": {
79
"@es-toolkit/es-toolkit": "jsr:@es-toolkit/es-toolkit@^1.37.2",

packages/core/src/compose.ts

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export class ComposableMCPServer extends Server {
6969
_toolName: string,
7070
args: unknown,
7171
_mode: "input" | "output",
72-
_originalArgs?: unknown
72+
_originalArgs?: unknown,
7373
): unknown {
7474
// For now, just return args unchanged
7575
// TODO: Implement transformResult hooks for runtime transformation
@@ -108,7 +108,7 @@ export class ComposableMCPServer extends Server {
108108
description: string,
109109
paramsSchema: Schema<T>,
110110
cb: (args: T, extra?: unknown) => unknown,
111-
options: { internal?: boolean; plugins?: ToolPlugin[] } = {}
111+
options: { internal?: boolean; plugins?: ToolPlugin[] } = {},
112112
) {
113113
this.toolRegistry.set(name, {
114114
callback: cb as ToolCallback,
@@ -158,7 +158,7 @@ export class ComposableMCPServer extends Server {
158158
toolName,
159159
result,
160160
"output",
161-
args
161+
args,
162162
) as CallToolResult;
163163
});
164164
}
@@ -207,7 +207,7 @@ export class ComposableMCPServer extends Server {
207207
const processedArgs = this.applyPluginTransforms(
208208
resolvedName,
209209
args,
210-
"input"
210+
"input",
211211
);
212212
const result = await callback(processedArgs);
213213
return this.applyPluginTransforms(resolvedName, result, "output", args);
@@ -241,7 +241,7 @@ export class ComposableMCPServer extends Server {
241241
const hiddenSet = new Set(this.getHiddenToolNames());
242242

243243
return allRegistered.filter(
244-
(n) => !publicSet.has(n) && !internalSet.has(n) && !hiddenSet.has(n)
244+
(n) => !publicSet.has(n) && !internalSet.has(n) && !hiddenSet.has(n),
245245
);
246246
}
247247

@@ -258,7 +258,7 @@ export class ComposableMCPServer extends Server {
258258
* Get internal tool schema by name
259259
*/
260260
getInternalToolSchema(
261-
name: string
261+
name: string,
262262
): { description: string; schema: JSONSchema } | undefined {
263263
const tool = this.toolRegistry.get(name);
264264
const config = this.toolConfigs.get(name);
@@ -371,10 +371,10 @@ export class ComposableMCPServer extends Server {
371371
private async applyTransformToolHooks(
372372
tool: ComposedTool,
373373
toolName: string,
374-
mode: "agentic" | "agentic_workflow"
374+
mode: "agentic" | "agentic_workflow",
375375
): Promise<ComposedTool> {
376376
const transformPlugins = this.globalPlugins.filter(
377-
(p) => p.transformTool && shouldApplyPlugin(p, mode)
377+
(p) => p.transformTool && shouldApplyPlugin(p, mode),
378378
);
379379

380380
if (transformPlugins.length === 0) {
@@ -411,9 +411,9 @@ export class ComposableMCPServer extends Server {
411411
*/
412412
private async processToolsWithPlugins(
413413
externalTools: Record<string, ComposedTool>,
414-
mode: "agentic" | "agentic_workflow"
414+
mode: "agentic" | "agentic_workflow",
415415
): Promise<void> {
416-
for (const [toolId, toolData] of this.toolRegistry.entries()) {
416+
for (const [toolId, toolData] of this.toolRegistry.entries()) {
417417
const defaultSchema = {
418418
type: "object",
419419
properties: {},
@@ -429,7 +429,7 @@ export class ComposableMCPServer extends Server {
429429
const processedTool = await this.applyTransformToolHooks(
430430
tempTool,
431431
toolId,
432-
mode
432+
mode,
433433
);
434434

435435
this.toolRegistry.set(toolId, {
@@ -449,7 +449,7 @@ export class ComposableMCPServer extends Server {
449449
toolId,
450450
processedTool,
451451
this,
452-
externalTools
452+
externalTools,
453453
);
454454
}
455455
} catch {
@@ -465,10 +465,10 @@ export class ComposableMCPServer extends Server {
465465
* Trigger composeEnd hooks for all plugins
466466
*/
467467
private async triggerComposeEndHooks(
468-
context: ComposeEndContext
468+
context: ComposeEndContext,
469469
): Promise<void> {
470470
const endPlugins = this.globalPlugins.filter(
471-
(p) => p.composeEnd && shouldApplyPlugin(p, context.mode)
471+
(p) => p.composeEnd && shouldApplyPlugin(p, context.mode),
472472
);
473473

474474
for (const plugin of endPlugins) {
@@ -482,7 +482,7 @@ export class ComposableMCPServer extends Server {
482482
name: string | null,
483483
description: string,
484484
depsConfig: z.infer<typeof McpSettingsSchema> = { mcpServers: {} },
485-
options: ComposeDefinition["options"] = { mode: "agentic" }
485+
options: ComposeDefinition["options"] = { mode: "agentic" },
486486
) {
487487
const refDesc = options.refs?.join("") ?? "";
488488
const { tagToResults, $ } = parseTags(description + refDesc, [
@@ -552,7 +552,7 @@ export class ComposableMCPServer extends Server {
552552
tool.attribs.name === toolId
553553
);
554554
});
555-
}
555+
},
556556
)) as {
557557
tools: Record<string, ComposedTool>;
558558
cleanupClients: () => Promise<void>;
@@ -567,8 +567,8 @@ export class ComposableMCPServer extends Server {
567567
});
568568
});
569569

570-
// Trigger transformation hooks for all tools
571-
await this.processToolsWithPlugins(tools, options.mode ?? "agentic");
570+
// Trigger transformation hooks for all tools
571+
await this.processToolsWithPlugins(tools, options.mode ?? "agentic");
572572

573573
// Cleanup clients when server is closed (pretty-printed to match logging plugin)
574574
this.onclose = async () => {
@@ -604,7 +604,7 @@ export class ComposableMCPServer extends Server {
604604
toolId,
605605
tool.description || "No description available",
606606
jsonSchema(tool.inputSchema as any),
607-
tool.execute
607+
tool.execute,
608608
);
609609
});
610610

@@ -639,9 +639,11 @@ export class ComposableMCPServer extends Server {
639639
}
640640
if (!tool) {
641641
throw new Error(
642-
`Action ${toolName} not found, available action list: ${allToolNames.join(
643-
", "
644-
)}`
642+
`Action ${toolName} not found, available action list: ${
643+
allToolNames.join(
644+
", ",
645+
)
646+
}`,
645647
);
646648
}
647649

packages/core/src/plugins/built-in/logging-plugin.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const createLoggingPlugin = (
99
enabled?: boolean;
1010
verbose?: boolean;
1111
compact?: boolean;
12-
} = {}
12+
} = {},
1313
): ToolPlugin => {
1414
const { enabled = true, verbose = false, compact = true } = options;
1515

@@ -33,7 +33,7 @@ export const createLoggingPlugin = (
3333
const globalCount = publicToolNames.length;
3434

3535
console.log(
36-
`🧩 [${context.toolName}] ${pluginCount} plugins • ${externalCount} external • ${internalCount} internal • ${hiddenCount} hidden • ${globalCount} global`
36+
`🧩 [${context.toolName}] ${pluginCount} plugins • ${externalCount} external • ${internalCount} internal • ${hiddenCount} hidden • ${globalCount} global`,
3737
);
3838
} else if (verbose) {
3939
console.log(`🧩 [${context.toolName}]`);
@@ -42,18 +42,18 @@ export const createLoggingPlugin = (
4242
// Get all tool information from server
4343
const server = context.server;
4444
const globalToolNames = Array.from(
45-
new Set(server.getPublicToolNames().map(String))
45+
new Set(server.getPublicToolNames().map(String)),
4646
);
4747

4848
// Ensure uniqueness across categories and coerce to string[]
4949
const external: string[] = Array.from(
50-
new Set(server.getExternalToolNames().map(String))
50+
new Set(server.getExternalToolNames().map(String)),
5151
);
5252
const internal: string[] = Array.from(
53-
new Set(server.getInternalToolNames().map(String))
53+
new Set(server.getInternalToolNames().map(String)),
5454
);
5555
const hidden: string[] = Array.from(
56-
new Set(server.getHiddenToolNames().map(String))
56+
new Set(server.getHiddenToolNames().map(String)),
5757
);
5858
const globalNames: string[] = globalToolNames.map(String);
5959
const totalSet = new Set<string>([

0 commit comments

Comments
 (0)