-
Notifications
You must be signed in to change notification settings - Fork 166
feat: allow reading config from a file and support toolMetadataOverrides MCP-292 MCP-300 #743
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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
toolMetadataOverridesconfiguration option to UserConfig schema - Refactored all tools to use
internalNameandinternalDescriptionproperties alongside computednameanddescriptiongetters - 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 |
Pull Request Test Coverage Report for Build 19627566401Details
💛 - Coveralls |
|
please update README.md |
|
please add validation to guard rail for name collision |
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.
fc66307 to
2587b6e
Compare
| * https://github.com/modelcontextprotocol/typescript-sdk/issues/414 for | ||
| * more details. | ||
| */ | ||
| this.update = (updates: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we really want to make it possible to rename tool mid-way?
This really makes our state less mutable and more messy. If someone wants to do this, they should look into using our tool-related hooks and defining custom tools as they likely need custom behavior at this point.
I'd prefer an approach where we only set the overrides on initalization, in which case we don't have getters and separate "internal"/"default" fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are already renaming tools midway. What the change is suggesting is that the rename should respect the tool metadata overrides.
| * This script generates argument definitions and updates: | ||
| * - server.json arrays | ||
| * - README.md configuration table | ||
| * - CONFIGURATION.md configuration table |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
subjective but i like this is in README, I really hate having to click extra things to find more crucial information, it's also worse for the LLM agents that might be reading this. I think we can make the table more compact by combining the ENV and -- variable options into 1 column
|
Tabling this PR for now until we have more clarity on how we want to proceed with this. |
Proposed changes
This PR introduces support for reading configuration from a file specified either by command line argument
--configor by environment variableMDB_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
toolMetadataOverrideswhich allows specifying name and description overrides for tool. It is basically a map of internal tool name to the override object.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)
Checklist