update_collection_attributes
Update collection attributes such as name, description, privacy setting, tags, or alternative names using the collection ID.
Instructions
Allows updating a collection's attributes (such as name or description) Args: id (required): The ID of the collection to update. attributes: Available attributes in a collection: * name: string * description: string * private: boolean * tags: array of strings * alt_names: array of strings Returns: A dictionary representing the updated collection.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ||
| attributes | No | ||
| api_key | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- gti_mcp/tools/collections.py:464-490 (handler)Handler function that updates a collection's attributes via PATCH /collections/{id} API call. Decorated with @server.tool() to register as an MCP tool.
@server.tool() async def update_collection_attributes( id: str, ctx: Context, attributes: typing.Dict[str, typing.Any] = None, api_key: str = None, ) -> typing.Dict[str, typing.Any]: """Allows updating a collection's attributes (such as name or description) Args: id (required): The ID of the collection to update. attributes: Available attributes in a collection: * name: string * description: string * private: boolean * tags: array of strings * alt_names: array of strings Returns: A dictionary representing the updated collection. """ async with vt_client(ctx, api_key=api_key) as client: collection_data = {"data": {"attributes": attributes, "type": "collection"}} res = await client.patch_async( f"/collections/{id}", json_data=collection_data ) data = await res.json_async() return utils.sanitize_response(data["data"]) - gti_mcp/tools/collections.py:464-490 (registration)Tool registration via @server.tool() decorator on the function. The server object is created in gti_mcp/server.py and tools are imported via gti_mcp/tools/__init__.py from line 72 in server.py: 'from gti_mcp.tools import *'
@server.tool() async def update_collection_attributes( id: str, ctx: Context, attributes: typing.Dict[str, typing.Any] = None, api_key: str = None, ) -> typing.Dict[str, typing.Any]: """Allows updating a collection's attributes (such as name or description) Args: id (required): The ID of the collection to update. attributes: Available attributes in a collection: * name: string * description: string * private: boolean * tags: array of strings * alt_names: array of strings Returns: A dictionary representing the updated collection. """ async with vt_client(ctx, api_key=api_key) as client: collection_data = {"data": {"attributes": attributes, "type": "collection"}} res = await client.patch_async( f"/collections/{id}", json_data=collection_data ) data = await res.json_async() return utils.sanitize_response(data["data"]) - gti_mcp/utils.py:119-138 (helper)Helper utility sanitize_response used to clean up the API response by recursively removing empty dicts and lists.
def sanitize_response(data: typing.Any) -> typing.Any: """Removes empty dictionaries and lists recursively from a response.""" if isinstance(data, dict): sanitized_dict = {} for key, value in data.items(): sanitized_value = sanitize_response(value) if sanitized_value is not None: sanitized_dict[key] = sanitized_value return sanitized_dict elif isinstance(data, list): sanitized_list = [] for item in data: sanitized_item = sanitize_response(item) if sanitized_item is not None: sanitized_list.append(sanitized_item) return sanitized_list elif isinstance(data, str): return data if data else None else: return data