Skip to content

Commit 49cab34

Browse files
committed
fix tabs
1 parent e6219bb commit 49cab34

File tree

2 files changed

+101
-101
lines changed

2 files changed

+101
-101
lines changed

src/server/mcp.test.ts

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -509,74 +509,74 @@ describe('tool()', () => {
509509
* Test: Tool disable, enable, and remove via tool instance
510510
*/
511511
test("should manage tool when using tool instance", async () => {
512-
const mcpServer = new McpServer({
513-
name: "test server",
514-
version: "1.0",
515-
});
516-
517-
// Register initial tool
518-
const tool = mcpServer.tool("test", async () => ({
519-
content: [
520-
{
521-
type: "text",
522-
text: "Test response",
523-
},
524-
],
525-
}));
526-
527-
expect(mcpServer['_registeredTools'].test).toBeDefined();
528-
529-
// Now disable the tool
530-
tool.disable();
531-
532-
expect(mcpServer['_registeredTools'].test.enabled).toBe(false);
533-
534-
// Now enable the tool
535-
tool.enable();
536-
537-
expect(mcpServer['_registeredTools'].test.enabled).toBe(true);
538-
539-
// Now delete the tool
540-
tool.remove();
541-
542-
expect(mcpServer['_registeredTools'].test).toBeUndefined();
512+
const mcpServer = new McpServer({
513+
name: "test server",
514+
version: "1.0",
515+
});
516+
517+
// Register initial tool
518+
const tool = mcpServer.tool('test', async () => ({
519+
content: [
520+
{
521+
type: 'text',
522+
text: 'Test response'
523+
}
524+
]
525+
}));
526+
527+
expect(mcpServer['_registeredTools'].test).toBeDefined();
528+
529+
// Now disable the tool
530+
tool.disable();
531+
532+
expect(mcpServer['_registeredTools'].test.enabled).toBe(false);
533+
534+
// Now enable the tool
535+
tool.enable();
536+
537+
expect(mcpServer['_registeredTools'].test.enabled).toBe(true);
538+
539+
// Now delete the tool
540+
tool.remove();
541+
542+
expect(mcpServer['_registeredTools'].test).toBeUndefined();
543543
});
544544

545545
/***
546546
* Test: Tool disable, enable, and remove via server instance
547547
*/
548548
test("should manage tool when using server instance", async () => {
549-
const mcpServer = new McpServer({
550-
name: "test server",
551-
version: "1.0",
552-
});
553-
554-
// Register initial tool
555-
mcpServer.tool("test", async () => ({
556-
content: [
557-
{
558-
type: "text",
559-
text: "Test response",
560-
},
561-
],
562-
}));
563-
564-
expect(mcpServer['_registeredTools'].test).toBeDefined();
565-
566-
// Now disable the tool
567-
mcpServer.disableTool("test");
568-
569-
expect(mcpServer['_registeredTools'].test.enabled).toBe(false);
570-
571-
// Now enable the tool
572-
mcpServer.enableTool("test");
573-
574-
expect(mcpServer['_registeredTools'].test.enabled).toBe(true);
575-
576-
// Now delete the tool
577-
mcpServer.removeTool("test");
578-
579-
expect(mcpServer['_registeredTools'].test).toBeUndefined();
549+
const mcpServer = new McpServer({
550+
name: "test server",
551+
version: "1.0",
552+
});
553+
554+
// Register initial tool
555+
mcpServer.tool('test', async () => ({
556+
content: [
557+
{
558+
type: 'text',
559+
text: 'Test response'
560+
}
561+
]
562+
}));
563+
564+
expect(mcpServer['_registeredTools'].test).toBeDefined();
565+
566+
// Now disable the tool
567+
mcpServer.disableTool("test");
568+
569+
expect(mcpServer['_registeredTools'].test.enabled).toBe(false);
570+
571+
// Now enable the tool
572+
mcpServer.enableTool("test");
573+
574+
expect(mcpServer['_registeredTools'].test.enabled).toBe(true);
575+
576+
// Now delete the tool
577+
mcpServer.removeTool("test");
578+
579+
expect(mcpServer['_registeredTools'].test).toBeUndefined();
580580
});
581581

582582
/***

src/server/mcp.ts

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -821,43 +821,43 @@ export class McpServer {
821821
* Does nothing if the tool is not registered.
822822
*/
823823
enableTool(name: string) {
824-
const tool = this._registeredTools[name];
825-
if (tool) {
826-
tool.enable();
827-
}
824+
const tool = this._registeredTools[name];
825+
if (tool) {
826+
tool.enable();
827+
}
828828
};
829829

830830
/**
831831
* Disables a tool from the server by name.
832832
* Does nothing if the tool is not registered.
833833
*/
834834
disableTool(name: string) {
835-
const tool = this._registeredTools[name];
836-
if (tool) {
837-
tool.disable();
838-
}
835+
const tool = this._registeredTools[name];
836+
if (tool) {
837+
tool.disable();
838+
}
839839
};
840840

841841
/**
842842
* Updates a tool from the server by name.
843843
* Does nothing if the tool is not registered.
844844
*/
845845
updateTool<InputArgs extends ZodRawShape, OutputArgs extends ZodRawShape>(name: string, updates: ToolUpdates<InputArgs, OutputArgs>) {
846-
const tool = this._registeredTools[name];
847-
if (tool) {
848-
tool.update(updates);
849-
}
846+
const tool = this._registeredTools[name];
847+
if (tool) {
848+
tool.update(updates);
849+
}
850850
};
851851

852852
/**
853853
* Removes a tool from the server by name.
854854
* Does nothing if the tool is not registered.
855855
*/
856856
removeTool(name: string) {
857-
const tool = this._registeredTools[name];
858-
if (tool) {
859-
tool.update({ name: null });
860-
}
857+
const tool = this._registeredTools[name];
858+
if (tool) {
859+
tool.update({ name: null });
860+
}
861861
};
862862

863863
/**
@@ -1063,32 +1063,32 @@ export type ToolCallback<Args extends undefined | ZodRawShape = undefined> = Arg
10631063
: (extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => CallToolResult | Promise<CallToolResult>;
10641064

10651065
export type ToolUpdates<InputArgs extends ZodRawShape, OutputArgs extends ZodRawShape> = {
1066-
name?: string | null,
1067-
title?: string,
1068-
description?: string,
1069-
paramsSchema?: InputArgs,
1070-
outputSchema?: OutputArgs,
1071-
annotations?: ToolAnnotations,
1072-
_meta?: Record<string, unknown>,
1073-
callback?: ToolCallback<InputArgs>,
1074-
enabled?: boolean
1066+
name?: string | null,
1067+
title?: string,
1068+
description?: string,
1069+
paramsSchema?: InputArgs,
1070+
outputSchema?: OutputArgs,
1071+
annotations?: ToolAnnotations,
1072+
_meta?: Record<string, unknown>,
1073+
callback?: ToolCallback<InputArgs>,
1074+
enabled?: boolean
10751075
}
10761076

10771077
export type RegisteredTool = {
1078-
title?: string;
1079-
description?: string;
1080-
inputSchema?: AnyZodObject;
1081-
outputSchema?: AnyZodObject;
1082-
annotations?: ToolAnnotations;
1083-
_meta?: Record<string, unknown>;
1084-
callback: ToolCallback<undefined | ZodRawShape>;
1085-
enabled: boolean;
1086-
enable(): void;
1087-
disable(): void;
1088-
update<InputArgs extends ZodRawShape, OutputArgs extends ZodRawShape>(
1089-
updates: ToolUpdates<InputArgs, OutputArgs>
1090-
): void
1091-
remove(): void
1078+
title?: string;
1079+
description?: string;
1080+
inputSchema?: AnyZodObject;
1081+
outputSchema?: AnyZodObject;
1082+
annotations?: ToolAnnotations;
1083+
_meta?: Record<string, unknown>;
1084+
callback: ToolCallback<undefined | ZodRawShape>;
1085+
enabled: boolean;
1086+
enable(): void;
1087+
disable(): void;
1088+
update<InputArgs extends ZodRawShape, OutputArgs extends ZodRawShape>(
1089+
updates: ToolUpdates<InputArgs, OutputArgs>
1090+
): void
1091+
remove(): void
10921092
};
10931093

10941094
const EMPTY_OBJECT_JSON_SCHEMA = {

0 commit comments

Comments
 (0)