delete-file
Remove files from OpenAI Assistant storage by specifying their unique file ID to manage storage and maintain organized assistant resources.
Instructions
Delete a file
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_id | Yes | The ID of the file to delete |
Implementation Reference
- src/mcp_server_openai/server.py:204-207 (handler)The MCP tool handler for 'delete-file' that extracts the file_id argument and delegates to the LLMConnector's delete_file method, returning a formatted response.elif name == "delete-file": file_id = arguments["file_id"] response = await connector.delete_file(file_id) return [types.TextContent(type="text", text=f"File deleted: {response.id}, status: {'deleted' if response.deleted else 'not deleted'}")]
- src/mcp_server_openai/server.py:117-127 (registration)Registers the 'delete-file' tool in the list_tools() decorator, including its name, description, and input schema.types.Tool( name="delete-file", description="Delete a file", inputSchema={ "type": "object", "properties": { "file_id": {"type": "string", "description": "The ID of the file to delete"} }, "required": ["file_id"] } )
- src/mcp_server_openai/llm.py:104-110 (helper)Implementation of the delete_file method in LLMConnector class, which calls the OpenAI client's files.delete API.async def delete_file(self, file_id: str): try: response = await self.client.files.delete(file_id) return response except Exception as e: logger.error(f"Failed to delete file {file_id}: {str(e)}") raise