Repository navigation
feat(tool/mongodb): allow collection to be specified at runtime - #3715
Conversation
…e with collectionAllowedValues.
feat(tool/mongodb): make collection optional; supply at runtime, scop…
There was a problem hiding this comment.
Code Review
This pull request updates various MongoDB tools to make the "collection" configuration field optional, exposing it as a required runtime parameter when omitted, and introduces an optional "collectionAllowedValues" field to restrict the agent's choices. The documentation, unit tests, and integration tests have been updated accordingly. The review feedback suggests adding duplicate parameter checks during the initialization of the "mongodb-aggregate" tool to prevent conflicts, and refactoring the "mongodb-insert-one" tool to reuse a local "paramsMap" variable for consistency and to avoid redundant map allocations.
|
There is some medium-priority comments generated by Gemini. Since these suggestions don't significantly change the underlying logic or behavior, I wanted to check if you consider them blocking for this PR? I'm happy to implement them if you prefer, |
|
Hi @dennisg, since you are the author of the MongoDB tools, would you like to review this change? Thank you! |
|
some minor comments, looks good to me! |
fix(tool/mongodb): check duplicate params in mongodb-aggregate tool
Hi @dennisg thanks for reviewing I have updated the branch with the duplicate check for mongodb-aggregate and synced with main. |
|
no other concerns from me |
|
Works for me ;-)
…On Fri, 31 Jul 2026, 15:44 Satya Sasini, ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In internal/tools/mongodb/mongodbdeletemany/mongodbdeletemany.go
<#3715 (comment)>
:
> @@ -74,6 +76,21 @@ func (cfg Config) Initialize(context.Context) (tools.Tool, error) {
allParameters := slices.Concat(cfg.FilterParams)
+ // If no collection is set in the config, expose it as a runtime parameter so
+ // the agent can pick the collection when invoking the tool.
+ if cfg.Collection == "" {
You're right, we don't have one, but yes now I m thinking of it is worth
adding — otherwise the agent has to guess collection names at runtime and
only finds out they're invalid after a failed call. py to take it on.
But I had some doubts,
The existing list-tables-style tools (e.g. clickhouse-list-tables,
postgres-list-tables) get their values by querying the database live at
call time. They return whatever actually exists.
allowedValues (and the collectionAllowedValues in this PR) works
differently, it's a server-side validation gate only. It's checked in the
parameter's Parse() and isn't surfaced anywhere the agent can see, it's not
in the tool manifest, not in the MCP input schema (no enum), and not in any
output. The agent only learns a value was disallowed by getting an error
after sending it.
How about opening an new issue on the same and continue the discussion for
an implementation? I mean I think this is going a little beyond than this
PR's scope. We can also finalise the approach here and incorporate that
too, whatever you suggest works
—
Reply to this email directly, view it on GitHub
<#3715?email_source=notifications&email_token=AAB3P3MYOSTPEIF2KYTEVI35HSPCVA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTIOBSHA4TSNRTGYZKM4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#discussion_r3690835776>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAB3P3PH74CEN2HAX2CQ7RT5HSPCVAVCNFSNUABFKJSXA33TNF2G64TZHM4DCMRQGQ2DCOBSHNEXG43VMU5TIOJYGI2DQMRSGEYKC5QC>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/AAB3P3JK5K4XACQ6JMFKZ4T5HSPCVA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTIOBSHA4TSNRTGYZKM4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJKTGN5XXIZLSL5UW64Y>
and Android
<https://github.com/notifications/mobile/android/AAB3P3KWXY4RFUADXXJ7YA35HSPCVA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTIOBSHA4TSNRTGYZKM4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLTGN5XXIZLSL5QW4ZDSN5UWI>.
Download it today!
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
Cool, Thanks @dennisg ! @duwenxin99 I think we have reviewed the changes in the PR. |
Thanks @dennisg and @SWITCHin2! I'll review again before we proceed with merging. |
…ject collection with collectionAllowedValues, and consolidate runtime-collection tests
Merge branch 'googleapis:main' into feat-mongodb-runtime-collection
|
Hi @SWITCHin2, |
|
Looking into this |
Head branch was pushed to by a user without write access
|
I have pushed the changes, tested on my end. Thanks for the heads up! |
|
/gcbrun |
|
Hi @duwenxin99 |
|
/gcbrun |
@SWITCHin2 Seems to be a timeout error. Just re-ran it to see if it's a glitch on Cloud Build. |
|
@duwenxin99 It timeout error again. |
|
@SWITCHin2 |
|
Oh! cool then! I thought may be it was something related to my changes. |
|
@SWITCHin2 Tests are now fixed. Any last-minute changes before I merge it? |
|
No I think I m fine |
|
@SWITCHin2 Merged. Thanks fro the contribution! |
… at runtime (#3715) ## Description > Should include a concise description of the changes (bug or feature), it's > impact, along with a summary of the solution Make the collection field optional across the MongoDB tools (find, find-one, aggregate, insert-one/many, update-one/many, delete-one/many). When collection is set in the config the behavior is unchanged. When it is omitted, the tool exposes a required collection parameter so the agent can choose the collection at invocation time. A configured collection is never overridden at runtime, keeping the change backward compatible and avoiding accidental exposure of collections that were not intended to be reachable. Since it is a regular string parameter, it can be scoped with allowedValues when runtime selection needs to be restricted. Adds unit tests covering the parameter injection and config-wins behavior, an integration test for runtime selection, and updates the tool docs. ## PR Checklist > Thank you for opening a Pull Request! Before submitting your PR, there are a > few things you can do to make sure it goes smoothly: - [x] Make sure you reviewed [CONTRIBUTING.md](https://github.com/googleapis/mcp-toolbox/blob/main/CONTRIBUTING.md) - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/mcp-toolbox/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [x] Ensure the tests and linter pass - [x] Code coverage does not decrease (if any source code was changed) - [x] Appropriate docs were updated (if necessary) - [ ] Make sure to add `!` if this involve a breaking change 🛠️ Fixes #1679 --------- Co-authored-by: Wenxin Du <[email protected]> Co-authored-by: Yuan Teoh <[email protected]>
… at runtime (googleapis#3715) ## Description > Should include a concise description of the changes (bug or feature), it's > impact, along with a summary of the solution Make the collection field optional across the MongoDB tools (find, find-one, aggregate, insert-one/many, update-one/many, delete-one/many). When collection is set in the config the behavior is unchanged. When it is omitted, the tool exposes a required collection parameter so the agent can choose the collection at invocation time. A configured collection is never overridden at runtime, keeping the change backward compatible and avoiding accidental exposure of collections that were not intended to be reachable. Since it is a regular string parameter, it can be scoped with allowedValues when runtime selection needs to be restricted. Adds unit tests covering the parameter injection and config-wins behavior, an integration test for runtime selection, and updates the tool docs. ## PR Checklist > Thank you for opening a Pull Request! Before submitting your PR, there are a > few things you can do to make sure it goes smoothly: - [x] Make sure you reviewed [CONTRIBUTING.md](https://github.com/googleapis/mcp-toolbox/blob/main/CONTRIBUTING.md) - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/mcp-toolbox/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [x] Ensure the tests and linter pass - [x] Code coverage does not decrease (if any source code was changed) - [x] Appropriate docs were updated (if necessary) - [ ] Make sure to add `!` if this involve a breaking change 🛠️ Fixes googleapis#1679 --------- Co-authored-by: Wenxin Du <[email protected]> Co-authored-by: Yuan Teoh <[email protected]>
|
Thanks! :) |
… at runtime (googleapis#3715) ## Description > Should include a concise description of the changes (bug or feature), it's > impact, along with a summary of the solution Make the collection field optional across the MongoDB tools (find, find-one, aggregate, insert-one/many, update-one/many, delete-one/many). When collection is set in the config the behavior is unchanged. When it is omitted, the tool exposes a required collection parameter so the agent can choose the collection at invocation time. A configured collection is never overridden at runtime, keeping the change backward compatible and avoiding accidental exposure of collections that were not intended to be reachable. Since it is a regular string parameter, it can be scoped with allowedValues when runtime selection needs to be restricted. Adds unit tests covering the parameter injection and config-wins behavior, an integration test for runtime selection, and updates the tool docs. ## PR Checklist > Thank you for opening a Pull Request! Before submitting your PR, there are a > few things you can do to make sure it goes smoothly: - [x] Make sure you reviewed [CONTRIBUTING.md](https://github.com/googleapis/mcp-toolbox/blob/main/CONTRIBUTING.md) - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/mcp-toolbox/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [x] Ensure the tests and linter pass - [x] Code coverage does not decrease (if any source code was changed) - [x] Appropriate docs were updated (if necessary) - [ ] Make sure to add `!` if this involve a breaking change 🛠️ Fixes googleapis#1679 --------- Co-authored-by: Wenxin Du <[email protected]> Co-authored-by: Yuan Teoh <[email protected]>
🤖 I have created a release *beep* *boop* --- ## [1.10.0](v1.9.0...v1.10.0) (2026-08-27) ### Features * **falkordb:** Add FalkorDB source and tools ([#3692](#3692)) ([a94702c](a94702c)) * **firestore-mongodb:** Add firestore-execute-mql and firestore-get-… ([#3826](#3826)) ([4a85d75](4a85d75)) * **mcp:** Add Secure Parameters support as Toolbox experimental extension ([#3394](#3394)) ([9750d2d](9750d2d)) * **server/mcp:** Support com.google.cloud/toolbox.v1 extension in v20260728 ([#3801](#3801)) ([f4f7da6](f4f7da6)) * **skill:** Add fix-failing-tests skill for mcp-toolbox ([#3821](#3821)) ([168e69c](168e69c)) * **sources:** Support native read-only mode and dynamic tool annotations ([#3872](#3872)) ([c257022](c257022)), refs [#3615](#3615) [#3816](#3816) [#3618](#3618) [#3851](#3851) [#3619](#3619) [#3617](#3617) * **tool/mongodb:** Allow collection to be specified at runtime ([#3715](#3715)) ([7626eaf](7626eaf)) ### Bug Fixes * **cloud-storage:** Resolve symlinks when enforcing local path boundaries ([#3810](#3810)) ([c2ada64](c2ada64)) * **config:** Compare env var offsets in rune space when skipping comments ([#3856](#3856)) ([2e76934](2e76934)) * Merge prebuilt tools when reloading custom config ([#3864](#3864)) ([5a6d865](5a6d865)) * Normalize postgres UUIDs to strings ([#3806](#3806)) ([3b02f1d](3b02f1d)) * **postgres:** Filter background processes in postgres-list-active-queries ([#3885](#3885)) ([3d9e62a](3d9e62a)) * **test/alloydbainl:** Use explicit SQL alias prompts to stabilize AI… ([#3877](#3877)) ([50e45ed](50e45ed)) * **tests:** Prevent resource leaks by using context.WithoutCancel ([#3849](#3849)) ([f97a4f9](f97a4f9)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: Yuan Teoh <[email protected]>
🤖 I have created a release *beep* *boop* --- ## [1.10.0](v1.9.0...v1.10.0) (2026-08-27) ### Features * **falkordb:** Add FalkorDB source and tools ([#3692](#3692)) ([a94702c](a94702c)) * **firestore-mongodb:** Add firestore-execute-mql and firestore-get-… ([#3826](#3826)) ([4a85d75](4a85d75)) * **mcp:** Add Secure Parameters support as Toolbox experimental extension ([#3394](#3394)) ([9750d2d](9750d2d)) * **server/mcp:** Support com.google.cloud/toolbox.v1 extension in v20260728 ([#3801](#3801)) ([f4f7da6](f4f7da6)) * **skill:** Add fix-failing-tests skill for mcp-toolbox ([#3821](#3821)) ([168e69c](168e69c)) * **sources:** Support native read-only mode and dynamic tool annotations ([#3872](#3872)) ([c257022](c257022)), refs [#3615](#3615) [#3816](#3816) [#3618](#3618) [#3851](#3851) [#3619](#3619) [#3617](#3617) * **tool/mongodb:** Allow collection to be specified at runtime ([#3715](#3715)) ([7626eaf](7626eaf)) ### Bug Fixes * **cloud-storage:** Resolve symlinks when enforcing local path boundaries ([#3810](#3810)) ([c2ada64](c2ada64)) * **config:** Compare env var offsets in rune space when skipping comments ([#3856](#3856)) ([2e76934](2e76934)) * Merge prebuilt tools when reloading custom config ([#3864](#3864)) ([5a6d865](5a6d865)) * Normalize postgres UUIDs to strings ([#3806](#3806)) ([3b02f1d](3b02f1d)) * **postgres:** Filter background processes in postgres-list-active-queries ([#3885](#3885)) ([3d9e62a](3d9e62a)) * **test/alloydbainl:** Use explicit SQL alias prompts to stabilize AI… ([#3877](#3877)) ([50e45ed](50e45ed)) * **tests:** Prevent resource leaks by using context.WithoutCancel ([#3849](#3849)) ([f97a4f9](f97a4f9)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: Yuan Teoh <[email protected]>
mcp-toolbox 1.10.0 Created-by: HarmonybrewBot Commit-by: HarmonybrewBot Merged-by: HarmonybrewBot Description: Created by `brew bump` --- Created with `brew bump-formula-pr`.<details> <summary>release notes</summary> <pre>## [1.10.0](googleapis/mcp-toolbox@v1.9.0...v1.10.0) (2026-08-27) ### Features * **falkordb:** Add FalkorDB source and tools ([#3692](googleapis/mcp-toolbox#3692)) ([a94702c](googleapis/mcp-toolbox@a94702c)) * **mcp:** Add Secure Parameters support as Toolbox experimental extension ([#3394](googleapis/mcp-toolbox#3394)) ([9750d2d](googleapis/mcp-toolbox@9750d2d)) * **server/mcp:** Support com.google.cloud/toolbox.v1 extension in v20260728 ([#3801](googleapis/mcp-toolbox#3801)) ([f4f7da6](googleapis/mcp-toolbox@f4f7da6)) * **skill:** Add fix-failing-tests skill for mcp-toolbox ([#3821](googleapis/mcp-toolbox#3821)) ([168e69c](googleapis/mcp-toolbox@168e69c)) * **sources:** Support native read-only mode and dynamic tool annotations ([#3872](googleapis/mcp-toolbox#3872)) ([c257022](googleapis/mcp-toolbox@c257022)), refs [#3615](googleapis/mcp-toolbox#3615) [#3816](googleapis/mcp-toolbox#3816) [#3618](googleapis/mcp-toolbox#3618) [#3851](googleapis/mcp-toolbox#3851) [#3619](googleapis/mcp-toolbox#3619) [#3617](googleapis/mcp-toolbox#3617) * **tools/firestore-mongodb:** Add tools for execute mql and get schema ([#3826](googleapis/mcp-toolbox#3826)) ([4a85d75](googleapis/mcp-toolbox@4a85d75)) * **tool/mongodb:** Allow collection to be specified at runtime ([#3715](googleapis/mcp-toolbox#3715)) ([7626eaf](googleapis/mcp-toolbox@7626eaf)) ### Bug Fixes * **cloud-storage:** Resolve symlinks when enforcing local path boundaries ([#3810](googleapis/mcp-toolbox#3810)) ([c2ada64](googleapis/mcp-toolbox@c2ada64)) * **config:** Compare env var offsets in rune space when skipping comments ([#3856](googleapis/mcp-toolbox#3856)) ([2e76934](googleapis/mcp-toolbox@2e76934)) * Merge prebuilt tools when reloading custom config ([#3864](googleapis/mcp-toolbox#3864)) ([5a6d865](googleapis/mcp-toolbox@5a6d865)) * Normalize postgres UUIDs to strings ([#3806](googleapis/mcp-toolbox#3806)) ([3b02f1d](googleapis/mcp-toolbox@3b02f1d)) * **postgres:** Filter background processes in postgres-list-active-queries ([#3885](googleapis/mcp-toolbox#3885)) ([3d9e62a](googleapis/mcp-toolbox@3d9e62a)) | **OS/Architecture** | **Description** | **SHA256 Hash** | | --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------- | | [linux/amd64](https://storage.googleapis.com/mcp-toolbox-for-databases/v1.10.0/linux/amd64/toolbox) ([Signature](https://storage.googleapis.com/mcp-toolbox-for-databases/v1.10.0/linux/amd64/toolbox.asc)) | For **Linux** systems running on **Intel/AMD 64-bit processors**. | 7e15dba09e6f957f64ce5924a0aa06b12cdf83ab26119813b0fa40edab566dd4 | | [darwin/arm64](https://storage.googleapis.com/mcp-toolbox-for-databases/v1.10.0/darwin/arm64/toolbox) | For **macOS** systems running on **Apple Silicon** (M1, M2, M3, etc.) processors. | c994f06781462abba4171cb4844776c45605e391c57dc96adb3e130c81b53825 | | [darwin/amd64](https://storage.googleapis.com/mcp-toolbox-for-databases/v1.10.0/darwin/amd64/toolbox) | For **macOS** systems running on **Intel processors**. | 12ebf78d9d05e8f3fe90c5d02ae14f2ccd96cf036f3dfba430bc32e3cfeadfd4 | | [windows/amd64](https://storage.googleapis.com/mcp-toolbox-for-databases/v1.10.0/windows/amd64/toolbox.exe) | For **Windows** systems running on **Intel/AMD 64-bit processors**. | 734783941cb5864c0e5d4d78be625f8b12be23b01d94781d7fa7db9b3c25aac6 | | [windows/arm64](https://storage.googleapis.com/mcp-toolbox-for-databases/v1.10.0/windows/arm64/toolbox.exe) | For **Windows** systems running on **ARM 64-bit processors**. | d9be7c2ce1d2e29c20f2974cbac4cde857adad836cee565d2584f3fbcc97f096 |</pre> <p>View the full release notes at <a href="https://github.com/googleapis/mcp-toolbox/releases/tag/v1.10.0">https://github.com/googleapis/mcp-toolbox/releases/tag/v1.10.0</a>.</p> </details> <hr> See merge request: Harmonybrew/homebrew-core!17982
Description
Make the collection field optional across the MongoDB tools (find, find-one, aggregate, insert-one/many, update-one/many, delete-one/many).
When collection is set in the config the behavior is unchanged. When it is omitted, the tool exposes a required collection parameter so the agent can choose the collection at invocation time. A configured collection is never overridden at runtime, keeping the change backward compatible and avoiding accidental exposure of collections that were not intended to be reachable. Since it is a regular string parameter, it can be scoped with allowedValues when runtime selection needs to be restricted.
Adds unit tests covering the parameter injection and config-wins behavior, an integration test for runtime selection, and updates the tool docs.
PR Checklist
CONTRIBUTING.md
bug/issue
before writing your code! That way we can discuss the change, evaluate
designs, and agree on the general idea
!if this involve a breaking change🛠️ Fixes #1679