Skip to main content
Glama
andybrandt

MCP Simple OpenAI Assistant

by andybrandt

update_thread

Modify the name or description of a saved conversation thread to organize and identify discussions clearly.

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
NameRequiredDescriptionDefault
thread_idYes
nameNo
descriptionNo

Implementation Reference

  • MCP tool handler implementation for 'update_thread'. This is the entry point decorated with @app.tool that validates inputs and delegates to AssistantManager.
    @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}")
  • Core business logic method in AssistantManager that updates the thread metadata both on OpenAI servers and in the 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
  • ThreadStore method that persists the thread metadata updates 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()

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/andybrandt/mcp-simple-openai-assistant'

If you have feedback or need assistance with the MCP directory API, please join our Discord server