Skip to content
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
ad2b4d9
feat(tools): surface literal string allowedValues as JSON Schema enum…
SWITCHin2 Sep 19, 2026
43c4466
feat(source/mongodb): add allowedCollections allow-list
SWITCHin2 Sep 19, 2026
647c307
refactor(tool/mongodb): centralise collection scoping in mongodbcommon
SWITCHin2 Sep 19, 2026
2b3bf0e
feat(tool/mongodb): enforce source allowedCollections across MongoDB …
SWITCHin2 Sep 19, 2026
5a2bfb2
docs(source/mongodb): document allowedCollections precedence
SWITCHin2 Sep 19, 2026
82568c1
test(tool/mongodb): integration coverage for source allowedCollections
SWITCHin2 Sep 19, 2026
c3795bc
feat(source/mongodb): enforce allowedCollections on aggregate pipelin…
SWITCHin2 Sep 27, 2026
fb2f882
Merge branch 'googleapis:main' into feat/mongodb-allowed-collections
SWITCHin2 Oct 23, 2026
e5b4476
Merge branch 'googleapis:main' into feat/mongodb-allowed-collections
SWITCHin2 Oct 26, 2026
82a8a50
fix(source/mongodb): reject duplicate keys and unreadable stages in a…
SWITCHin2 Oct 26, 2026
d23b997
fix(tool/mongodb): match collectionAllowedValues as whole names and c…
SWITCHin2 Oct 26, 2026
ab5baf8
fix(util/parameters): advertise allowedValues as a JSON Schema enum o…
SWITCHin2 Oct 26, 2026
4386dea
docs(source/mongodb): document whole-name collection matching and fai…
SWITCHin2 Oct 26, 2026
9f61ceb
Merge branch 'main' into feat/mongodb-allowed-collections
SWITCHin2 Nov 8, 2026
bcb3ce1
test(source/mongodb): cover cross-database $lookup sub-pipeline scope
SWITCHin2 Nov 8, 2026
fc4c091
fix(source/mongodb): check $lookup sub-pipelines in the referenced co…
SWITCHin2 Nov 8, 2026
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
4 changes: 2 additions & 2 deletions docs/en/documentation/configuration/tools/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ parameters:
| description | string | true | Natural language description of the parameter to describe it to the agent. |
| default | parameter type | false | Default value of the parameter. If provided, `required` will be `false`. |
| required | bool | false | Indicate if the parameter is required. Default to `true`. |
| allowedValues | []string | false | Input value will be checked against this field. Regex is also supported. |
| allowedValues | []string | false | Input value will be checked against this field. Regex is also supported. For `string` parameters where every entry is a literal string, the list is also advertised to MCP clients as the parameter's JSON Schema `enum`. |
| excludedValues | []string | false | Input value will be checked against this field. Regex is also supported. |
| escape | string | false | Only available for type `string`. Indicate the escaping delimiters used for the parameter. This field is intended to be used with templateParameters. Must be one of "single-quotes", "double-quotes", "backticks", "square-brackets". |
| minValue | int or float | false | Only available for type `integer` and `float`. Indicate the minimum value allowed. |
Expand Down Expand Up @@ -496,7 +496,7 @@ templateParameters:
| description | string | true | Natural language description of the template parameter to describe it to the agent. |
| default | parameter type | false | Default value of the parameter. If provided, `required` will be `false`. |
| required | bool | false | Indicate if the parameter is required. Default to `true`. |
| allowedValues | []string | false | Input value will be checked against this field. Regex is also supported. |
| allowedValues | []string | false | Input value will be checked against this field. Regex is also supported. For `string` parameters where every entry is a literal string, the list is also advertised to MCP clients as the parameter's JSON Schema `enum`. |
| excludedValues | []string | false | Input value will be checked against this field. Regex is also supported. |
| items | parameter object | true (if array) | Specify a Parameter object for the type of the values in the array (string only). |

Expand Down
61 changes: 57 additions & 4 deletions docs/en/integrations/mongodb/source.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,62 @@ uri: "mongodb+srv://username:password@host.mongodb.net"

```

Restrict every tool on the source to a fixed set of collections:

```yaml
kind: source
name: my-mongodb
type: mongodb
uri: "mongodb+srv://username:password@host.mongodb.net"
allowedCollections:
- crm.customers
- crm.orders
```

## Reference

| **field** | **type** | **required** | **description** |
|-----------|:--------:|:------------:|-------------------------------------------------------------------|
| type | string | true | Must be "mongodb". |
| uri | string | true | connection string to connect to MongoDB |
| **field** | **type** | **required** | **description** |
|--------------------|:--------:|:------------:|-------------------------------------------------------------------------------------------------------------------------------------------------------|
| type | string | true | Must be "mongodb". |
| uri | string | true | connection string to connect to MongoDB |
| allowedCollections | list | false | An optional list of `database.collection` entries that every tool on this source is restricted to. If omitted, tools may use any collection. |

## Advanced Usage

### Restricting collections

`allowedCollections` is the authoritative scope for every tool bound to the
source. Each entry must be fully qualified as `database.collection`, because a
MongoDB source has no default database -- each tool names its own. A database
name cannot contain a dot, so the name is split on the first one.

A tool's own `collectionAllowedValues` is an optional second layer that can only
*narrow* the source's list; it can never widen it. The effective set is the
intersection of the two, and it is advertised to the agent as the JSON Schema
`enum` of the runtime `collection` parameter. When the source sets
`allowedCollections`, each `collectionAllowedValues` entry must match a whole
collection name: `orders` selects only `orders`, not `orders_confidential`, and
a regex such as `order_[0-9]+` is matched as `^(?:order_[0-9]+)$`.

| `source.allowedCollections` | tool config | behaviour |
|-----------------------------|-----------------------------------------------|----------------------------------------------------|
| unset | fixed `collection: c` | allowed, unrestricted |
| unset | omitted, no `collectionAllowedValues` | runtime parameter, no `enum`, any collection |
| unset | omitted + `collectionAllowedValues: [a,b]` | runtime parameter, `enum: [a,b]` |
| `[a,b,c]` | fixed `collection: a` | allowed |
| `[a,b,c]` | fixed `collection: z` | rejected at startup |
| `[a,b,c]` | omitted | runtime parameter, `enum: [a,b,c]` |
| `[a,b,c]` | omitted + `collectionAllowedValues: [a,b]` | runtime parameter, `enum: [a,b]` |
| `[a,b]` | omitted + `collectionAllowedValues: [c]` | rejected at startup, the tool escapes the source |

A configuration that can never resolve to an allowed collection fails when the
server starts rather than when the agent calls the tool. At invocation time the
collection is checked again against the effective set, so the `enum` is a hint
to the client and the server remains the guard.

An aggregation pipeline can reach collections other than the one it runs on, so
every collection named by a `$lookup`, `$graphLookup`, `$unionWith`, `$out`,
`$merge` or `$facet` stage, including nested pipelines, must also be allowed by
the source. A pipeline that cannot be checked with certainty is rejected, for
example a stage document with a repeated field such as two `from` keys, or a
collection reference that is neither a name nor a `{db, coll}` document.
2 changes: 1 addition & 1 deletion docs/en/integrations/mongodb/tools/mongodb-aggregate.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pipelineParams:
| description | string | true | A description of the tool that is passed to the LLM. |
| database | string | true | The name of the MongoDB database containing the collection. |
| collection | string | false | The name of the MongoDB collection to run the aggregation on. Mutually exclusive with `collectionAllowedValues`. If omitted, it must be supplied at runtime as a `collection` parameter, and can be restricted with `collectionAllowedValues`. |
| collectionAllowedValues | list | false | An optional list of collection names the agent may choose from when `collection` is provided at runtime. Only configure this if collection is omitted. |
| collectionAllowedValues | list | false | An optional list of collection names the agent may choose from when `collection` is provided at runtime. Only configure this if collection is omitted. It can only narrow the source's `allowedCollections`, never widen it. |
| pipelinePayload | string | true | A JSON array of aggregation stage documents, provided as a string. Uses `{{json .param_name}}` for templating. |
| pipelineParams | list | true | A list of parameter objects that define the variables used in the `pipelinePayload`. |
| canonical | bool | false | Determines if the pipeline string is parsed using MongoDB's Canonical or Relaxed Extended JSON format. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ filterParams:
| description | string | true | A description of the tool that is passed to the LLM. |
| database | string | true | The name of the MongoDB database containing the collection. |
| collection | string | false | The name of the MongoDB collection from which to delete documents. Mutually exclusive with `collectionAllowedValues`. If omitted, it must be supplied at runtime as a `collection` parameter, and can be restricted with `collectionAllowedValues`. |
| collectionAllowedValues | list | false | An optional list of collection names the agent may choose from when `collection` is provided at runtime. Only configure this if collection is omitted. |
| collectionAllowedValues | list | false | An optional list of collection names the agent may choose from when `collection` is provided at runtime. Only configure this if collection is omitted. It can only narrow the source's `allowedCollections`, never widen it. |
| filterPayload | string | true | The MongoDB query filter document to select the documents for deletion. Uses `{{json .param_name}}` for templating. |
| filterParams | list | false | A list of parameter objects that define the variables used in the `filterPayload`. |
2 changes: 1 addition & 1 deletion docs/en/integrations/mongodb/tools/mongodb-delete-one.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ filterParams:
| description | string | true | A description of the tool that is passed to the LLM. |
| database | string | true | The name of the MongoDB database containing the collection. |
| collection | string | false | The name of the MongoDB collection from which to delete a document. Mutually exclusive with `collectionAllowedValues`. If omitted, it must be supplied at runtime as a `collection` parameter, and can be restricted with `collectionAllowedValues`. |
| collectionAllowedValues | list | false | An optional list of collection names the agent may choose from when `collection` is provided at runtime. Only configure this if collection is omitted. |
| collectionAllowedValues | list | false | An optional list of collection names the agent may choose from when `collection` is provided at runtime. Only configure this if collection is omitted. It can only narrow the source's `allowedCollections`, never widen it. |
| filterPayload | string | true | The MongoDB query filter document to select the document for deletion. Uses `{{json .param_name}}` for templating. |
| filterParams | list | false | A list of parameter objects that define the variables used in the `filterPayload`. |
2 changes: 1 addition & 1 deletion docs/en/integrations/mongodb/tools/mongodb-find-one.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ projectPayload: |
| description | string | true | A description of the tool that is passed to the LLM. |
| database | string | true | The name of the MongoDB database to query. |
| collection | string | false | The name of the MongoDB collection to query. Mutually exclusive with `collectionAllowedValues`. If omitted, it must be supplied at runtime as a `collection` parameter, and can be restricted with `collectionAllowedValues`. |
| collectionAllowedValues | list | false | An optional list of collection names the agent may choose from when `collection` is provided at runtime. Only configure this if collection is omitted. |
| collectionAllowedValues | list | false | An optional list of collection names the agent may choose from when `collection` is provided at runtime. Only configure this if collection is omitted. It can only narrow the source's `allowedCollections`, never widen it. |
| filterPayload | string | true | The MongoDB query filter document to select the document. Uses `{{json .param_name}}` for templating. |
| filterParams | list | false | A list of parameter objects that define the variables used in the `filterPayload`. |
| projectPayload | string | false | An optional MongoDB projection document to specify which fields to include (1) or exclude (0) in the result. |
Expand Down
2 changes: 1 addition & 1 deletion docs/en/integrations/mongodb/tools/mongodb-find.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ sortParams:
| description | string | true | A description of the tool that is passed to the LLM. |
| database | string | true | The name of the MongoDB database to query. |
| collection | string | false | The name of the MongoDB collection to query. Mutually exclusive with `collectionAllowedValues`. If omitted, it must be supplied at runtime as a `collection` parameter, and can be restricted with `collectionAllowedValues`. |
| collectionAllowedValues | list | false | An optional list of collection names the agent may choose from when `collection` is provided at runtime. Only configure this if collection is omitted. |
| collectionAllowedValues | list | false | An optional list of collection names the agent may choose from when `collection` is provided at runtime. Only configure this if collection is omitted. It can only narrow the source's `allowedCollections`, never widen it. |
| filterPayload | string | true | The MongoDB query filter document to select which documents to return. Uses `{{json .param_name}}` for templating. |
| filterParams | list | false | A list of parameter objects that define the variables used in the `filterPayload`. |
| projectPayload | string | false | An optional MongoDB projection document to specify which fields to include (1) or exclude (0) in the results. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ in the `data` parameter, like this:
| description | string | true | A description of the tool that is passed to the LLM. |
| database | string | true | The name of the MongoDB database containing the collection. |
| collection | string | false | The name of the MongoDB collection into which the documents will be inserted. Mutually exclusive with `collectionAllowedValues`. If omitted, it must be supplied at runtime as a `collection` parameter, and can be restricted with `collectionAllowedValues`. |
| collectionAllowedValues | list | false | An optional list of collection names the agent may choose from when `collection` is provided at runtime. Only configure this if collection is omitted. |
| collectionAllowedValues | list | false | An optional list of collection names the agent may choose from when `collection` is provided at runtime. Only configure this if collection is omitted. It can only narrow the source's `allowedCollections`, never widen it. |
| canonical | bool | false | Determines if the data string is parsed using MongoDB's Canonical or Relaxed Extended JSON format. Defaults to `false`. |
2 changes: 1 addition & 1 deletion docs/en/integrations/mongodb/tools/mongodb-insert-one.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ An LLM would call this tool by providing the document as a JSON string in the
| description | string | true | A description of the tool that is passed to the LLM. |
| database | string | true | The name of the MongoDB database containing the collection. |
| collection | string | false | The name of the MongoDB collection into which the document will be inserted. Mutually exclusive with `collectionAllowedValues`. If omitted, it must be supplied at runtime as a `collection` parameter, and can be restricted with `collectionAllowedValues`. |
| collectionAllowedValues | list | false | An optional list of collection names the agent may choose from when `collection` is provided at runtime. Only configure this if collection is omitted. |
| collectionAllowedValues | list | false | An optional list of collection names the agent may choose from when `collection` is provided at runtime. Only configure this if collection is omitted. It can only narrow the source's `allowedCollections`, never widen it. |
| canonical | bool | false | Determines if the data string is parsed using MongoDB's Canonical or Relaxed Extended JSON format. Defaults to `false`. |
Loading
Loading