From d56b57b61088df69e906af333b22ecde59792946 Mon Sep 17 00:00:00 2001 From: Luke Sanderson Date: Mon, 1 Sep 2025 11:41:54 +0100 Subject: [PATCH 1/7] Add Scaffolding for atlas-local tools --- README.md | 4 ++++ src/server.ts | 5 +++-- src/tools/atlas-local/atlas-localTool.ts | 18 ++++++++++++++++++ src/tools/atlas-local/tools.ts | 1 + src/tools/tool.ts | 2 +- 5 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 src/tools/atlas-local/atlas-localTool.ts create mode 100644 src/tools/atlas-local/tools.ts diff --git a/README.md b/README.md index d508b755..6bd0ac3b 100644 --- a/README.md +++ b/README.md @@ -284,6 +284,10 @@ npx -y mongodb-mcp-server@latest --transport http --httpHost=0.0.0.0 --httpPort= NOTE: atlas tools are only available when you set credentials on [configuration](#configuration) section. +#### MongoDB Atlas Local Tools + +- + #### MongoDB Database Tools - `connect` - Connect to a MongoDB instance diff --git a/src/server.ts b/src/server.ts index ded91618..3d0536bd 100644 --- a/src/server.ts +++ b/src/server.ts @@ -2,6 +2,7 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import type { Session } from "./common/session.js"; import type { Transport } from "@modelcontextprotocol/sdk/shared/transport.js"; import { AtlasTools } from "./tools/atlas/tools.js"; +import { AtlasLocalTools } from "./tools/atlas-local/tools.js"; import { MongoDbTools } from "./tools/mongodb/tools.js"; import { Resources } from "./resources/resources.js"; import type { LogLevel } from "./common/logger.js"; @@ -193,7 +194,7 @@ export class Server { } private registerTools(): void { - for (const toolConstructor of [...AtlasTools, ...MongoDbTools]) { + for (const toolConstructor of [...AtlasTools, ...AtlasLocalTools, ...MongoDbTools]) { const tool = new toolConstructor(this.session, this.userConfig, this.telemetry); if (tool.register(this)) { this.tools.push(tool); @@ -217,7 +218,7 @@ export class Server { console.error("Connection string validation failed with error: ", error); throw new Error( "Connection string validation failed with error: " + - (error instanceof Error ? error.message : String(error)) + (error instanceof Error ? error.message : String(error)) ); } } diff --git a/src/tools/atlas-local/atlas-localTool.ts b/src/tools/atlas-local/atlas-localTool.ts new file mode 100644 index 00000000..22c0a8ea --- /dev/null +++ b/src/tools/atlas-local/atlas-localTool.ts @@ -0,0 +1,18 @@ +import { CallToolResult } from "@modelcontextprotocol/sdk/types.js"; +import { ToolArgs, ToolBase, ToolCategory } from "../tool.js"; + +export abstract class AtlasToolBase extends ToolBase { + public category: ToolCategory = "atlas-local"; + + + protected handleError( + error: unknown, + args: ToolArgs + ): Promise | CallToolResult { + + // Error Handling for expected atlas-local errors go here + + // For other types of errors, use the default error handling from the base class + return super.handleError(error, args); + } +} \ No newline at end of file diff --git a/src/tools/atlas-local/tools.ts b/src/tools/atlas-local/tools.ts new file mode 100644 index 00000000..2d0f4e22 --- /dev/null +++ b/src/tools/atlas-local/tools.ts @@ -0,0 +1 @@ +export const AtlasLocalTools = []; \ No newline at end of file diff --git a/src/tools/tool.ts b/src/tools/tool.ts index 538d8c9b..2c3587ca 100644 --- a/src/tools/tool.ts +++ b/src/tools/tool.ts @@ -12,7 +12,7 @@ import type { Server } from "../server.js"; export type ToolArgs = z.objectOutputType; export type OperationType = "metadata" | "read" | "create" | "delete" | "update" | "connect"; -export type ToolCategory = "mongodb" | "atlas"; +export type ToolCategory = "mongodb" | "atlas" | "atlas-local"; export type TelemetryToolMetadata = { projectId?: string; orgId?: string; From d6b6ffcd5c9ec098f3213482afb390d4f69754d6 Mon Sep 17 00:00:00 2001 From: Luke Sanderson Date: Mon, 1 Sep 2025 11:56:01 +0100 Subject: [PATCH 2/7] lint --- src/server.ts | 2 +- src/tools/atlas-local/atlas-localTool.ts | 4 ++-- src/tools/atlas-local/tools.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/server.ts b/src/server.ts index 3d0536bd..b47945b9 100644 --- a/src/server.ts +++ b/src/server.ts @@ -218,7 +218,7 @@ export class Server { console.error("Connection string validation failed with error: ", error); throw new Error( "Connection string validation failed with error: " + - (error instanceof Error ? error.message : String(error)) + (error instanceof Error ? error.message : String(error)) ); } } diff --git a/src/tools/atlas-local/atlas-localTool.ts b/src/tools/atlas-local/atlas-localTool.ts index 22c0a8ea..e833e40a 100644 --- a/src/tools/atlas-local/atlas-localTool.ts +++ b/src/tools/atlas-local/atlas-localTool.ts @@ -10,9 +10,9 @@ export abstract class AtlasToolBase extends ToolBase { args: ToolArgs ): Promise | CallToolResult { - // Error Handling for expected atlas-local errors go here + // Error Handling for expected atlas-local errors go here // For other types of errors, use the default error handling from the base class return super.handleError(error, args); } -} \ No newline at end of file +} diff --git a/src/tools/atlas-local/tools.ts b/src/tools/atlas-local/tools.ts index 2d0f4e22..be1a9552 100644 --- a/src/tools/atlas-local/tools.ts +++ b/src/tools/atlas-local/tools.ts @@ -1 +1 @@ -export const AtlasLocalTools = []; \ No newline at end of file +export const AtlasLocalTools = []; From ef7e1fecb3191654e7ddeb7daba83f6567aa456d Mon Sep 17 00:00:00 2001 From: Luke Sanderson Date: Mon, 1 Sep 2025 12:01:35 +0100 Subject: [PATCH 3/7] eslint --- src/tools/atlas-local/atlas-localTool.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/tools/atlas-local/atlas-localTool.ts b/src/tools/atlas-local/atlas-localTool.ts index e833e40a..2b30e2b8 100644 --- a/src/tools/atlas-local/atlas-localTool.ts +++ b/src/tools/atlas-local/atlas-localTool.ts @@ -1,15 +1,14 @@ -import { CallToolResult } from "@modelcontextprotocol/sdk/types.js"; -import { ToolArgs, ToolBase, ToolCategory } from "../tool.js"; +import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js"; +import type { ToolArgs, ToolCategory } from "../tool.js"; +import { ToolBase } from "../tool.js"; export abstract class AtlasToolBase extends ToolBase { public category: ToolCategory = "atlas-local"; - protected handleError( error: unknown, args: ToolArgs ): Promise | CallToolResult { - // Error Handling for expected atlas-local errors go here // For other types of errors, use the default error handling from the base class From 216e0a91dd763de0f7c052102e263edcf66ce0c2 Mon Sep 17 00:00:00 2001 From: Luke Sanderson Date: Mon, 1 Sep 2025 12:06:03 +0100 Subject: [PATCH 4/7] prettier fix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6bd0ac3b..96ad4333 100644 --- a/README.md +++ b/README.md @@ -286,7 +286,7 @@ NOTE: atlas tools are only available when you set credentials on [configuration] #### MongoDB Atlas Local Tools -- +- #### MongoDB Database Tools From 8c56756fda293573b5ded8af0bb01e4ff2b7ac55 Mon Sep 17 00:00:00 2001 From: Luke Sanderson Date: Mon, 1 Sep 2025 13:03:56 +0100 Subject: [PATCH 5/7] Rename to camel case --- .../atlas-localTool.ts => atlasLocal/atlasLocalTool.ts} | 4 ++-- src/tools/{atlas-local => atlasLocal}/tools.ts | 0 src/tools/tool.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename src/tools/{atlas-local/atlas-localTool.ts => atlasLocal/atlasLocalTool.ts} (82%) rename src/tools/{atlas-local => atlasLocal}/tools.ts (100%) diff --git a/src/tools/atlas-local/atlas-localTool.ts b/src/tools/atlasLocal/atlasLocalTool.ts similarity index 82% rename from src/tools/atlas-local/atlas-localTool.ts rename to src/tools/atlasLocal/atlasLocalTool.ts index 2b30e2b8..510f3cab 100644 --- a/src/tools/atlas-local/atlas-localTool.ts +++ b/src/tools/atlasLocal/atlasLocalTool.ts @@ -2,8 +2,8 @@ import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js"; import type { ToolArgs, ToolCategory } from "../tool.js"; import { ToolBase } from "../tool.js"; -export abstract class AtlasToolBase extends ToolBase { - public category: ToolCategory = "atlas-local"; +export abstract class AtlasLocalToolBase extends ToolBase { + public category: ToolCategory = "atlasLocal"; protected handleError( error: unknown, diff --git a/src/tools/atlas-local/tools.ts b/src/tools/atlasLocal/tools.ts similarity index 100% rename from src/tools/atlas-local/tools.ts rename to src/tools/atlasLocal/tools.ts diff --git a/src/tools/tool.ts b/src/tools/tool.ts index 2c3587ca..5cd965b6 100644 --- a/src/tools/tool.ts +++ b/src/tools/tool.ts @@ -12,7 +12,7 @@ import type { Server } from "../server.js"; export type ToolArgs = z.objectOutputType; export type OperationType = "metadata" | "read" | "create" | "delete" | "update" | "connect"; -export type ToolCategory = "mongodb" | "atlas" | "atlas-local"; +export type ToolCategory = "mongodb" | "atlas" | "atlasLocal"; export type TelemetryToolMetadata = { projectId?: string; orgId?: string; From 404261ef055196149ca83b2b5679d974c0d6e387 Mon Sep 17 00:00:00 2001 From: Luke Sanderson Date: Mon, 1 Sep 2025 13:08:26 +0100 Subject: [PATCH 6/7] Fix renaming error --- src/server.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server.ts b/src/server.ts index b47945b9..006dc7cd 100644 --- a/src/server.ts +++ b/src/server.ts @@ -2,7 +2,7 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import type { Session } from "./common/session.js"; import type { Transport } from "@modelcontextprotocol/sdk/shared/transport.js"; import { AtlasTools } from "./tools/atlas/tools.js"; -import { AtlasLocalTools } from "./tools/atlas-local/tools.js"; +import { AtlasLocalTools } from "./tools/atlasLocal/tools.js"; import { MongoDbTools } from "./tools/mongodb/tools.js"; import { Resources } from "./resources/resources.js"; import type { LogLevel } from "./common/logger.js"; From bb97c13dd164d9463916eb06b0a17a8ab74f5a2c Mon Sep 17 00:00:00 2001 From: Luke Sanderson Date: Mon, 1 Sep 2025 14:56:40 +0100 Subject: [PATCH 7/7] revert change to ToolCategory to be in line with TD --- src/tools/atlasLocal/atlasLocalTool.ts | 4 ++-- src/tools/tool.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tools/atlasLocal/atlasLocalTool.ts b/src/tools/atlasLocal/atlasLocalTool.ts index 510f3cab..b5c7899f 100644 --- a/src/tools/atlasLocal/atlasLocalTool.ts +++ b/src/tools/atlasLocal/atlasLocalTool.ts @@ -3,13 +3,13 @@ import type { ToolArgs, ToolCategory } from "../tool.js"; import { ToolBase } from "../tool.js"; export abstract class AtlasLocalToolBase extends ToolBase { - public category: ToolCategory = "atlasLocal"; + public category: ToolCategory = "atlas-local"; protected handleError( error: unknown, args: ToolArgs ): Promise | CallToolResult { - // Error Handling for expected atlas-local errors go here + // Error Handling for expected Atlas Local errors go here // For other types of errors, use the default error handling from the base class return super.handleError(error, args); diff --git a/src/tools/tool.ts b/src/tools/tool.ts index 5cd965b6..2c3587ca 100644 --- a/src/tools/tool.ts +++ b/src/tools/tool.ts @@ -12,7 +12,7 @@ import type { Server } from "../server.js"; export type ToolArgs = z.objectOutputType; export type OperationType = "metadata" | "read" | "create" | "delete" | "update" | "connect"; -export type ToolCategory = "mongodb" | "atlas" | "atlasLocal"; +export type ToolCategory = "mongodb" | "atlas" | "atlas-local"; export type TelemetryToolMetadata = { projectId?: string; orgId?: string;