Skip to main content
Glama
andybrandt

MCP Simple OpenAI Assistant

by andybrandt

Delete Managed Thread

delete_thread

Remove conversation threads from OpenAI servers and local databases. This permanent deletion helps manage storage and organize assistant interactions.

Instructions

Deletes a conversation thread from both OpenAI's servers and the local database. This action is irreversible.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
thread_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler and registration for 'delete_thread'. Decorated with @app.tool(), it calls AssistantManager.delete_thread() and handles errors, providing user-friendly responses.
    @app.tool(annotations={"title": "Delete Managed Thread", "readOnlyHint": False})
    async def delete_thread(thread_id: str) -> str:
        """
        Deletes a conversation thread from both OpenAI's servers and the local database.
        This action is irreversible.
        """
        if not manager:
            raise ToolError("AssistantManager not initialized.")
        try:
            result = await manager.delete_thread(thread_id)
            if result.deleted:
                return f"Successfully deleted thread {thread_id}."
            else:
                return f"Failed to delete thread {thread_id} on the server."
        except Exception as e:
            raise ToolError(f"Failed to delete thread {thread_id}: {e}")
  • Helper method in AssistantManager that deletes the thread from OpenAI's servers using the API and conditionally deletes from the local ThreadStore.
    async def delete_thread(self, thread_id: str):
        """Delete a thread from OpenAI and the local database."""
        # First, delete the thread from OpenAI's servers
        result = self.client.beta.threads.delete(thread_id)
        # If successful, delete from the local database
        if result.deleted:
            self.thread_store.delete_thread(thread_id)
        return result
  • Core helper implementation in ThreadStore that performs the SQL DELETE operation to remove the thread record from the local SQLite database.
    def delete_thread(self, thread_id: str):
        """Deletes a thread record from the database by its thread_id.
    
        Args:
            thread_id: The ID of the thread to delete.
        """
        conn = self._get_connection()
        cursor = conn.cursor()
        cursor.execute("DELETE FROM threads WHERE thread_id = ?", (thread_id,))
        conn.commit()
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations provide readOnlyHint=false, indicating a mutation, but the description adds crucial behavioral context: it specifies the deletion scope (both servers and local database) and explicitly warns that the action is irreversible. This goes beyond annotations by detailing the destructive nature and permanence of the operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences, front-loaded with the core action and followed by a critical warning. Every word earns its place, with no redundancy or unnecessary elaboration, making it highly efficient and easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (destructive, irreversible operation) and the presence of an output schema (which handles return values), the description is mostly complete. It covers the action, scope, and key behavioral warning. However, it could benefit from more explicit usage guidelines or error handling context to reach a perfect score.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0% description coverage, but the description does not add any parameter-specific information beyond what is implied by the tool name and action. With one parameter (thread_id) and no schema details, the baseline is 3, as the description does not compensate for the lack of schema coverage but doesn't contradict it either.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Deletes') and resource ('a conversation thread'), with explicit scope ('from both OpenAI's servers and the local database'). It distinguishes from sibling tools like 'list_threads' or 'update_thread' by specifying a destructive deletion operation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context through the irreversible warning, suggesting this should be used only when permanent removal is intended. However, it does not explicitly state when to use this tool versus alternatives (e.g., archiving vs. deletion) or mention prerequisites like thread existence, leaving room for improvement.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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