Skip to main content
Glama
andybrandt

MCP Simple OpenAI Assistant

by andybrandt

Create New Assistant Thread

create_new_assistant_thread

Create persistent conversation threads with custom names and descriptions for organized, reusable interactions with OpenAI assistants.

Instructions

Creates a new, persistent conversation thread with a user-defined name and description for easy identification and reuse. These threads are stored in OpenAI's servers and are not deleted unless the user deletes them, which means you can re-use them for future conversations. Additionally, the thread name and description are stored in the local database, which means you can list them and update them later.

Think how you can utilize threads in your particular use case.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
descriptionNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool 'create_new_assistant_thread' handler function, registered via @app.tool decorator. It checks for initialized manager, calls the core AssistantManager method, and returns a success message with thread ID or raises ToolError on failure.
    @app.tool(
        annotations={"title": "Create New Assistant Thread", "readOnlyHint": False}
    )
    async def create_new_assistant_thread(
        name: str, description: Optional[str] = None
    ) -> str:
        """
        Creates a new, persistent conversation thread with a user-defined name and
        description for easy identification and reuse. These threads are stored in OpenAI's servers 
        and are not deleted unless the user deletes them, which means you can re-use them for future conversations.
        Additionally, the thread name and description are stored in the local database, which means you can list them
        and update them later.
    
        Think how you can utilize threads in your particular use case.
        """
        if not manager:
            raise ToolError("AssistantManager not initialized.")
        try:
            thread = await manager.create_new_assistant_thread(name, description)
            return f"Created new thread '{name}' with ID: {thread.id}"
        except Exception as e:
            raise ToolError(f"Failed to create thread: {e}")
  • Core helper method in AssistantManager class that creates a new OpenAI thread with user-provided metadata and persists the thread details (ID, name, description) to the local ThreadStore database.
    async def create_new_assistant_thread(
        self, name: str, description: Optional[str] = None
    ) -> Thread:
        """Creates a new, persistent conversation thread."""
        metadata = {
            "name": name,
            "description": description or ""
        }
        thread = self.client.beta.threads.create(metadata=metadata)
        self.thread_store.add_thread(thread.id, name, description)
        return thread
  • Supporting utility in ThreadStore class that inserts the new thread record into the local SQLite database, including current timestamp for last_used_at.
    def add_thread(self, thread_id: str, name: str, description: str | None) -> int:
        """Adds a new thread record to the database.
    
        Args:
            thread_id: The unique identifier for the thread from OpenAI.
            name: A user-defined name for the thread.
            description: A user-defined description for the thread.
    
        Returns:
            The row ID of the newly inserted thread.
        """
        conn = self._get_connection()
        cursor = conn.cursor()
        cursor.execute("""
            INSERT INTO threads (thread_id, name, description, last_used_at)
            VALUES (?, ?, ?, ?)
        """, (thread_id, name, description, datetime.now(timezone.utc)))
        conn.commit()
        return cursor.lastrowid
Behavior4/5

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

Annotations provide readOnlyHint=false, indicating a write operation, which aligns with 'creates.' The description adds valuable behavioral context beyond annotations: it discloses persistence ('stored in OpenAI's servers,' 'not deleted unless the user deletes them'), storage details ('stored in the local database'), and reusability. No contradictions with annotations.

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

Conciseness4/5

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

The description is appropriately sized and front-loaded with key information (creation, persistence, storage). The final sentence ('Think how you can utilize threads...') is somewhat vague and could be omitted for better conciseness, but overall, most sentences earn their place.

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 moderate complexity (creation with persistence), annotations cover safety, and an output schema exists (so return values need not be explained), the description is mostly complete. It covers purpose, behavior, and storage, but could improve by addressing prerequisites or error cases.

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?

Schema description coverage is 0%, so the description must compensate. It mentions 'user-defined name and description,' which maps to the two parameters, but does not add meaning beyond what the schema names imply (e.g., no format, length, or content guidelines). The description provides basic semantics but lacks depth, resulting in a baseline score.

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 verb 'creates' and the resource 'new, persistent conversation thread' with specific attributes (user-defined name and description). It distinguishes from siblings like 'list_threads' (which lists) and 'delete_thread' (which removes). The purpose is specific and unambiguous.

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

Usage Guidelines4/5

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

The description provides clear context for usage ('for easy identification and reuse,' 'can re-use them for future conversations'), but does not explicitly state when to use this tool versus alternatives like 'update_thread' or 'ask_assistant_in_thread.' It implies usage for starting new threads but lacks explicit exclusions or comparisons.

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