@@ -2,7 +2,6 @@ import { z } from "zod";
22import { CallToolResult } from "@modelcontextprotocol/sdk/types.js" ;
33import { MongoDBToolBase } from "../mongodbTool.js" ;
44import { ToolArgs , OperationType } from "../../tool.js" ;
5- import { ErrorCodes , MongoDBError } from "../../../errors.js" ;
65import config from "../../../config.js" ;
76import { MongoError as DriverError } from "mongodb" ;
87
@@ -37,25 +36,23 @@ export class ConnectTool extends MongoDBToolBase {
3736
3837 let connectionString : string ;
3938
40- if ( typeof connectionStringOrClusterName === "string" ) {
41- if (
42- connectionStringOrClusterName . startsWith ( "mongodb://" ) ||
43- connectionStringOrClusterName . startsWith ( "mongodb+srv://" )
44- ) {
45- connectionString = connectionStringOrClusterName ;
46- } else {
47- // TODO:
48- return {
49- content : [
50- {
51- type : "text" ,
52- text : `Connecting via cluster name not supported yet. Please provide a connection string.` ,
53- } ,
54- ] ,
55- } ;
56- }
39+ if (
40+ connectionStringOrClusterName . startsWith ( "mongodb://" ) ||
41+ connectionStringOrClusterName . startsWith ( "mongodb+srv://" )
42+ ) {
43+ connectionString = connectionStringOrClusterName ;
5744 } else {
58- throw new MongoDBError ( ErrorCodes . InvalidParams , "Invalid connection options" ) ;
45+ // TODO: https://github.com/mongodb-js/mongodb-mcp-server/issues/19
46+ // We don't support connecting via cluster name since we'd need to obtain the user credentials
47+ // and fill in the connection string.
48+ return {
49+ content : [
50+ {
51+ type : "text" ,
52+ text : `Connecting via cluster name not supported yet. Please provide a connection string.` ,
53+ } ,
54+ ] ,
55+ } ;
5956 }
6057
6158 try {
0 commit comments