mirror of
https://github.com/googleapis/genai-toolbox.git
synced 2026-05-02 03:00:36 -04:00
The `required` tag raises validation failure error when a boolean field is defined as `false`: ``` ERROR "unable to parse tool file at "mongodb_tools.yaml": unable to parse tool "insert-one-device" as kind "mongodb-insert-one": [2:12] Key: 'Config.Canonical' Error:Field validation for 'Canonical' failed on the 'required' tag\n 1 | authRequired: []\n> 2 | canonical: false\n ^\n 3 | collection: Device\n 4 | database: xiar\n 5 | description: Inserts a single new document into the Device collection. The 'data' parameter must be a string containing the JSON object to insert.\n 6 | " ``` All the `required` tags are removed from the boolean `canonical` field of the MongoDB tools. Unit tests are added.
2.4 KiB
2.4 KiB
title, type, weight, description, aliases
| title | type | weight | description | aliases | |
|---|---|---|---|---|---|
| mongodb-insert-one | docs | 1 | A "mongodb-insert-one" tool inserts a single new document into a MongoDB collection. |
|
About
The mongodb-insert-one tool inserts a single new document into a specified
MongoDB collection.
This tool takes one required parameter named data, which must be a string
containing the JSON object you want to insert. Upon successful insertion, the
tool returns the unique _id of the newly created document.
This tool is compatible with the following source kind:
Example
Here is an example configuration for a tool that adds a new user to a users
collection.
tools:
create_new_user:
kind: mongodb-insert-one
source: my-mongo-source
description: Creates a new user record in the database.
database: user_data
collection: users
canonical: false
An LLM would call this tool by providing the document as a JSON string in the
data parameter, like this:
tool_code: create_new_user(data='{"email": "new.user@example.com", "name": "Jane Doe", "status": "active"}')
Reference
| field | type | required | description |
|---|---|---|---|
| kind | string | true | Must be mongodb-insert-one. |
| source | string | true | The name of the mongodb source to use. |
| 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 | true | The name of the MongoDB collection into which the document will be inserted. |
| canonical | bool | false | Determines if the data string is parsed using MongoDB's Canonical or Relaxed Extended JSON format. Defaults to false. |