Skip to content

Conversation

@himanshusinghs
Copy link
Collaborator

@himanshusinghs himanshusinghs commented Nov 20, 2025

Proposed changes

This PR introduces support for reading configuration from a file specified either by command line argument --config or by environment variable MDB_MCP_CONFIG. The configuration from the file is used as the base on top of which configuration from environment variables are applied and then config from CLI arguments. The precedence order is provided and maintained by yargs-parser itself.

Furthermore, we've added a new config property called toolMetadataOverrides which allows specifying name and description overrides for tool. It is basically a map of internal tool name to the override object.

{
  "toolMetadataOverrides": {
    "insert-many": {
      "name": "insertMany",
      "description": "..."
    },
    "delete-many": {
      "name: "deleteMany"
      // either property (name, description) is optional
    }
  }
}

We expect users to be using config file for specifying this configuration and ensuring that access to the config is locked down to the user running the MongoDB MCP Server. Doing the same through command line arguments is gruesome but possible and not encouraged at all. An example:

CLI Arguments (nested keys separated by dot)

npx mongodb-mcp-server \
--toolMetadataOverrides.insert-many.name="insertMany" \
--toolMetadataOverrides.insert-many.description="..."

Checklist

@himanshusinghs himanshusinghs requested a review from a team as a code owner November 20, 2025 19:51
Copilot AI review requested due to automatic review settings November 20, 2025 19:51
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces support for reading configuration from a file and adds the ability to override tool metadata (name and description) through user configuration. The changes enable users to customize tool names and descriptions while maintaining internal tool identification.

Key Changes:

  • Added toolMetadataOverrides configuration option to UserConfig schema
  • Refactored all tools to use internalName and internalDescription properties alongside computed name and description getters
  • Implemented config file loading via CLI argument (--config) and environment variable (MDB_MCP_CONFIG)

Reviewed Changes

Copilot reviewed 49 out of 49 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/common/config/userConfig.ts Added toolMetadataOverrides field to UserConfig schema
src/common/config/createUserConfig.ts Added config file loading support via yargs-parser
src/tools/tool.ts Refactored to support internal vs configured tool metadata with getters
src/tools/mongodb/connect/connect.ts Updated to use new internal metadata properties and override logic
tests/unit/common/config.test.ts Added comprehensive tests for config file loading and precedence
tests/integration/tools/mongodb/connect/connect.test.ts Added integration tests for metadata override functionality
tests/fixtures/*.json Added fixture files for config loading tests
src/tools/mongodb/**/*.ts Updated all MongoDB tools to use internalName/internalDescription
src/tools/atlas/**/*.ts Updated all Atlas tools to use internalName/internalDescription
src/tools/atlasLocal/**/*.ts Updated all Atlas Local tools to use internalName/internalDescription
tests/unit/toolBase.test.ts Updated test tool to use new property names
tests/integration/**/*.ts Updated test tools to use new property names

@coveralls
Copy link
Collaborator

coveralls commented Nov 20, 2025

Pull Request Test Coverage Report for Build 19577555100

Details

  • 137 of 137 (100.0%) changed or added relevant lines in 44 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.6%) to 80.697%

Totals Coverage Status
Change from base Build 19575600461: 0.6%
Covered Lines: 6471
Relevant Lines: 7922

💛 - Coveralls

@fmenezes
Copy link
Collaborator

please update README.md

@fmenezes
Copy link
Collaborator

please add validation to guard rail for name collision

himanshusinghs and others added 10 commits November 21, 2025 17:41
This commit ensures that we register the tool with correct metadata
, taking into consideration the toolMetadataOverrides provided by the
users.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit ensures that when toolMetadataOverrides accidentally lead to
tool name collision then we error out before even starting the
server.
@himanshusinghs himanshusinghs force-pushed the feat/MCP-292-config-file branch from fc66307 to 2587b6e Compare November 21, 2025 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants