diff --git a/cmd/internal/tools_file_test.go b/cmd/internal/tools_file_test.go index e3bef34e5b42..0dcc812f9d6a 100644 --- a/cmd/internal/tools_file_test.go +++ b/cmd/internal/tools_file_test.go @@ -1766,9 +1766,13 @@ func TestPrebuiltTools(t *testing.T) { name: "firestore prebuilt tools", in: firestoreconfig, wantToolset: server.ToolsetConfigs{ - "firestore_database_tools": tools.ToolsetConfig{ - Name: "firestore_database_tools", - ToolNames: []string{"get_documents", "add_documents", "update_document", "list_collections", "delete_documents", "query_collection", "get_rules", "validate_rules"}, + "data": tools.ToolsetConfig{ + Name: "data", + ToolNames: []string{"get_documents", "add_documents", "update_document", "delete_documents", "query_collection", "list_collections"}, + }, + "security": tools.ToolsetConfig{ + Name: "security", + ToolNames: []string{"get_rules", "validate_rules"}, }, }, }, @@ -1966,6 +1970,14 @@ func TestPrebuiltTools(t *testing.T) { if len(toolsFile.Prompts) != 0 { t.Fatalf("expected empty prompts map for prebuilt config, got: %v", toolsFile.Prompts) } + + t.Run("check toolset sizes", func(t *testing.T) { + for tsName, ts := range toolsFile.Toolsets { + if len(ts.ToolNames) > 10 { + t.Logf("WARNING: Toolset %q in config %q has %d tools, which is larger than the recommended maximum of 10.", tsName, tc.name, len(ts.ToolNames)) + } + } + }) }) } } diff --git a/internal/prebuiltconfigs/tools/firestore.yaml b/internal/prebuiltconfigs/tools/firestore.yaml index 42383b23e17e..7e1387685cd3 100644 --- a/internal/prebuiltconfigs/tools/firestore.yaml +++ b/internal/prebuiltconfigs/tools/firestore.yaml @@ -13,70 +13,69 @@ # limitations under the License. sources: - firestore-source: - kind: firestore - project: ${FIRESTORE_PROJECT} - database: ${FIRESTORE_DATABASE:} - + firestore-source: + kind: firestore + project: ${FIRESTORE_PROJECT} + database: ${FIRESTORE_DATABASE:} tools: - get_documents: - kind: firestore-get-documents - source: firestore-source - description: Gets multiple documents from Firestore by their paths - add_documents: - kind: firestore-add-documents - source: firestore-source - description: | - Adds a new document to a Firestore collection. Please follow the best practices : - 1. Always use typed values in the documentData: Every field must be wrapped with its appropriate type indicator (e.g., {"stringValue": "text"}) - 2. Integer values can be strings in the documentData: The tool accepts integer values as strings (e.g., {"integerValue": "1500"}) - 3. Use returnData sparingly: Only set to true when you need to verify the exact data that was written - 4. Validate data before sending: Ensure your data matches Firestore's native JSON format - 5. Handle timestamps properly: Use RFC3339 format for timestamp strings - 6. Base64 encode binary data: Binary data must be base64 encoded in the bytesValue field - 7. Consider security rules: Ensure your Firestore security rules allow document creation in the target collection - update_document: - kind: firestore-update-document - source: firestore-source - description: | - Updates an existing document in Firestore. Supports both full document updates and selective field updates using an update mask. Please follow the best practices: - 1. Use update masks for precision: When you only need to update specific fields, use the updateMask parameter to avoid unintended changes - 2. Always use typed values in the documentData: Every field must be wrapped with its appropriate type indicator (e.g., {"stringValue": "text"}) - 3. Delete fields using update mask: To delete fields, include them in the updateMask but omit them from documentData - 4. Integer values can be strings: The tool accepts integer values as strings (e.g., {"integerValue": "1500"}) - 5. Use returnData sparingly: Only set to true when you need to verify the exact data after the update - 6. Handle timestamps properly: Use RFC3339 format for timestamp strings - 7. Consider security rules: Ensure your Firestore security rules allow document updates - list_collections: - kind: firestore-list-collections - source: firestore-source - description: List Firestore collections for a given parent path - delete_documents: - kind: firestore-delete-documents - source: firestore-source - description: Delete multiple documents from Firestore - query_collection: - kind: firestore-query-collection - source: firestore-source - description: | - Retrieves one or more Firestore documents from a collection in a database in the current project by a collection with a full document path. - Use this if you know the exact path of a collection and the filtering clause you would like for the document. - get_rules: - kind: firestore-get-rules - source: firestore-source - description: Retrieves the active Firestore security rules for the current project - validate_rules: - kind: firestore-validate-rules - source: firestore-source - description: Checks the provided Firestore Rules source for syntax and validation errors. Provide the source code to validate. - + get_documents: + kind: firestore-get-documents + source: firestore-source + description: Gets multiple documents from Firestore by their paths + add_documents: + kind: firestore-add-documents + source: firestore-source + description: | + Adds a new document to a Firestore collection. Please follow the best practices : + 1. Always use typed values in the documentData: Every field must be wrapped with its appropriate type indicator (e.g., {"stringValue": "text"}) + 2. Integer values can be strings in the documentData: The tool accepts integer values as strings (e.g., {"integerValue": "1500"}) + 3. Use returnData sparingly: Only set to true when you need to verify the exact data that was written + 4. Validate data before sending: Ensure your data matches Firestore's native JSON format + 5. Handle timestamps properly: Use RFC3339 format for timestamp strings + 6. Base64 encode binary data: Binary data must be base64 encoded in the bytesValue field + 7. Consider security rules: Ensure your Firestore security rules allow document creation in the target collection + update_document: + kind: firestore-update-document + source: firestore-source + description: | + Updates an existing document in Firestore. Supports both full document updates and selective field updates using an update mask. Please follow the best practices: + 1. Use update masks for precision: When you only need to update specific fields, use the updateMask parameter to avoid unintended changes + 2. Always use typed values in the documentData: Every field must be wrapped with its appropriate type indicator (e.g., {"stringValue": "text"}) + 3. Delete fields using update mask: To delete fields, include them in the updateMask but omit them from documentData + 4. Integer values can be strings: The tool accepts integer values as strings (e.g., {"integerValue": "1500"}) + 5. Use returnData sparingly: Only set to true when you need to verify the exact data after the update + 6. Handle timestamps properly: Use RFC3339 format for timestamp strings + 7. Consider security rules: Ensure your Firestore security rules allow document updates + list_collections: + kind: firestore-list-collections + source: firestore-source + description: List Firestore collections for a given parent path + delete_documents: + kind: firestore-delete-documents + source: firestore-source + description: Delete multiple documents from Firestore + query_collection: + kind: firestore-query-collection + source: firestore-source + description: | + Retrieves one or more Firestore documents from a collection in a database in the current project by a collection with a full document path. + Use this if you know the exact path of a collection and the filtering clause you would like for the document. + get_rules: + kind: firestore-get-rules + source: firestore-source + description: Retrieves the active Firestore security rules for the current project + validate_rules: + kind: firestore-validate-rules + source: firestore-source + description: Checks the provided Firestore Rules source for syntax and validation errors. Provide the source code to validate. toolsets: - firestore_database_tools: - - get_documents - - add_documents - - update_document - - list_collections - - delete_documents - - query_collection - - get_rules - - validate_rules + data: + - get_documents + - add_documents + - update_document + - delete_documents + - query_collection + - list_collections + security: + - get_rules + - validate_rules