Skip to content

fix: config resource #173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 7 additions & 21 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,39 +150,25 @@ export class Server {
telemetry: this.userConfig.telemetry,
logPath: this.userConfig.logPath,
connectionString: this.userConfig.connectionString
? "set; no explicit connect needed, use switch-connection tool to connect to a different connection if necessary"
: "not set; before using any mongodb tool, you need to call the connect tool with a connection string",
? "set; access to MongoDB tools are currently available to use"
: "not set; before using any MongoDB tool, you need to configure a connection string, alternatively you can setup MongoDB Atlas access, more info at 'https://github.com/mongodb-js/mongodb-mcp-server'.",
connectOptions: this.userConfig.connectOptions,
atlas:
this.userConfig.apiClientId && this.userConfig.apiClientSecret
? "set; MongoDB Atlas tools are currently available to use"
: "not set; MongoDB Atlas tools are currently unavailable, to have access to MongoDB Atlas tools like creating clusters or connecting to clusters make sure to setup credentials, more info at 'https://github.com/mongodb-js/mongodb-mcp-server'.",
};
return {
contents: [
{
text: JSON.stringify(result),
mimeType: "application/json",
uri: uri.href,
},
],
};
}
);
if (this.userConfig.connectionString) {
this.mcpServer.resource(
"connection-string",
"config://connection-string",
{
description: "Preconfigured connection string that will be used as a default in the `connect` tool",
},
(uri) => {
return {
contents: [
{
text: `Preconfigured connection string: ${this.userConfig.connectionString}`,
uri: uri.href,
},
],
};
}
);
}
}

private async validateConfig(): Promise<void> {
Expand Down
Loading