list_assistants
Retrieve available OpenAI assistants with IDs and configurations to select one for use in conversation threads without creating new ones.
Instructions
List all available OpenAI assistants associated with the API key configured by the user.
Returns a list of assistants with their IDs, names, and configurations. This can be used to select an assistant to use in the ask_assistant_in_thread tool instead of creating a new one.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No |
Implementation Reference
- The @app.tool decorated handler function that implements the list_assistants tool logic. It calls the AssistantManager's list_assistants method and formats the output as a string.annotations={ "title": "List OpenAI Assistants", "readOnlyHint": True } ) async def list_assistants(limit: int = 20) -> str: """ List all available OpenAI assistants associated with the API key configured by the user. Returns a list of assistants with their IDs, names, and configurations. This can be used to select an assistant to use in the ask_assistant_in_thread tool instead of creating a new one. """ if not manager: raise ToolError("AssistantManager not initialized.") try: assistants = await manager.list_assistants(limit) if not assistants: return "No assistants found." assistant_list = [ dedent(f""" ID: {a.id} Name: {a.name} Model: {a.model}""") for a in assistants ] return "Available Assistants:\\n\\n" + "\\n---\\n".join(assistant_list) except Exception as e: raise ToolError(f"Failed to list assistants: {e}")
- The supporting method in AssistantManager class that interacts with the OpenAI API to retrieve the list of assistants.async def list_assistants(self, limit: int = 20) -> list[Assistant]: """List available OpenAI assistants.""" response = self.client.beta.assistants.list(limit=limit) return response.data
- mcp_simple_openai_assistant/app.py:170-174 (registration)The @app.tool decorator registers the list_assistants function as an MCP tool with title and read-only hint.annotations={ "title": "List OpenAI Assistants", "readOnlyHint": True } )