update_assistant
Modify an existing assistant's configuration by updating its name, instructions, or AI model to adapt to changing requirements.
Instructions
Modify an existing assistant's name, instructions, or model used.
At least one optional parameter - what to change - must be provided, otherwise the tool will return an error. The ID required can be retrieved from the list_assistants tool.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| assistant_id | Yes | ||
| name | No | ||
| instructions | No | ||
| model | No |
Implementation Reference
- The FastMCP tool handler for 'update_assistant', registered via @app.tool decorator. Performs initialization checks, input validation, delegates to AssistantManager.update_assistant, and formats the response.@app.tool( annotations={ "title": "Update OpenAI Assistant", "readOnlyHint": False } ) async def update_assistant( assistant_id: str, name: str = None, instructions: str = None, model: str = None ) -> str: """ Modify an existing assistant's name, instructions, or model used. At least one optional parameter - what to change - must be provided, otherwise the tool will return an error. The ID required can be retrieved from the list_assistants tool. """ if not manager: raise ToolError("AssistantManager not initialized.") if not any([name, instructions, model]): raise ToolError("You must provide at least one field to update (name, instructions, or model).") try: result = await manager.update_assistant(assistant_id, name, instructions, model) return f"Successfully updated assistant '{result.name}' (ID: {result.id})." except Exception as e: raise ToolError(f"Failed to update assistant {assistant_id}: {e}")
- Core helper function in AssistantManager that constructs update parameters from provided arguments and calls the OpenAI API to update the assistant.async def update_assistant( self, assistant_id: str, name: Optional[str] = None, instructions: Optional[str] = None, model: Optional[str] = None ) -> Assistant: """Update an existing assistant's configuration.""" update_params = {} if name is not None: update_params["name"] = name if instructions is not None: update_params["instructions"] = instructions if model is not None: update_params["model"] = model return self.client.beta.assistants.update( assistant_id=assistant_id, **update_params )
- mcp_simple_openai_assistant/app.py:223-249 (registration)Registration of the 'update_assistant' tool using FastMCP's @app.tool decorator with annotations.@app.tool( annotations={ "title": "Update OpenAI Assistant", "readOnlyHint": False } ) async def update_assistant( assistant_id: str, name: str = None, instructions: str = None, model: str = None ) -> str: """ Modify an existing assistant's name, instructions, or model used. At least one optional parameter - what to change - must be provided, otherwise the tool will return an error. The ID required can be retrieved from the list_assistants tool. """ if not manager: raise ToolError("AssistantManager not initialized.") if not any([name, instructions, model]): raise ToolError("You must provide at least one field to update (name, instructions, or model).") try: result = await manager.update_assistant(assistant_id, name, instructions, model) return f"Successfully updated assistant '{result.name}' (ID: {result.id})." except Exception as e: raise ToolError(f"Failed to update assistant {assistant_id}: {e}")