update_thread
Modify the name and description of an existing conversation thread, updating both local storage and the corresponding OpenAI thread object.
Instructions
Updates the name and/or description of a locally saved conversation thread. Both the local database and the OpenAI thread object will be updated.
The thread ID can be retrieved from the list_threads tool.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| description | No | ||
| name | No | ||
| thread_id | Yes |
Implementation Reference
- Primary MCP tool handler for 'update_thread'. Decorated with @app.tool() for registration. Validates inputs, delegates to AssistantManager, handles errors, and returns success message.@app.tool(annotations={"title": "Update Managed Thread", "readOnlyHint": False}) async def update_thread( thread_id: str, name: Optional[str] = None, description: Optional[str] = None ) -> str: """ Updates the name and/or description of a locally saved conversation thread. Both the local database and the OpenAI thread object will be updated. The thread ID can be retrieved from the list_threads tool. """ if not manager: raise ToolError("AssistantManager not initialized.") if not name and not description: raise ToolError("You must provide either a new name or a new description.") try: await manager.update_thread(thread_id, name, description) return f"Successfully updated thread {thread_id}." except Exception as e: raise ToolError(f"Failed to update thread {thread_id}: {e}")
- Helper method in AssistantManager that updates thread metadata on OpenAI servers via API and in local ThreadStore database.async def update_thread( self, thread_id: str, name: Optional[str], description: Optional[str] ): """Update the metadata of a thread on OpenAI and in the local DB.""" metadata = { "name": name, "description": description or "" } # First, update the thread on OpenAI's servers updated_thread = self.client.beta.threads.update( thread_id=thread_id, metadata=metadata ) # Then, update the local database self.thread_store.update_thread_metadata(thread_id, name, description) return updated_thread
- Database helper that updates the name, description, and last_used_at timestamp for a thread in the local SQLite database.def update_thread_metadata(self, thread_id: str, name: str, description: str | None): """Updates the name and description of a specific thread. Args: thread_id: The ID of the thread to update. name: The new name for the thread. description: The new description for the thread. """ conn = self._get_connection() cursor = conn.cursor() cursor.execute(""" UPDATE threads SET name = ?, description = ?, last_used_at = ? WHERE thread_id = ? """, (name, description, datetime.now(timezone.utc), thread_id)) conn.commit()
- mcp_simple_openai_assistant/app.py:93-93 (registration)FastMCP decorator that registers the update_thread function as an MCP tool with title and readOnlyHint metadata.@app.tool(annotations={"title": "Update Managed Thread", "readOnlyHint": False})