Skip to main content
Glama

new_chatgpt_chat_tool

Initiate a fresh chat conversation with ChatGPT through the MCP server, enabling prompt interactions from any compatible AI assistant.

Instructions

Start a new chat conversation in ChatGPT.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The MCP tool handler for 'new_chatgpt_chat_tool'. Decorated with @mcp.tool() for registration and executes the tool logic by delegating to the new_chatgpt_chat helper function.
    @mcp.tool() async def new_chatgpt_chat_tool() -> str: """Start a new chat conversation in ChatGPT.""" return await new_chatgpt_chat()
  • Helper function implementing the core logic for starting a new ChatGPT chat. Checks access, creates ChatGPTAutomation instance, calls new_chat(), and handles the result.
    async def new_chatgpt_chat() -> str: """Start a new chat conversation in ChatGPT. Returns: Success message or error """ await check_chatgpt_access() try: automation = ChatGPTAutomation() result = automation.new_chat() if isinstance(result, tuple): success, method = result if success: return f"Successfully opened a new ChatGPT chat window using: {method}" else: return f"Failed to open a new chat window. Last tried method: {method}" else: # 이전 버전과의 호환성 if result: return "Successfully opened a new ChatGPT chat window." else: return "Failed to open a new chat window. Please check if ChatGPT window is in the foreground." except Exception as e: raise Exception(f"Failed to create new chat: {str(e)}")
  • Core automation helper in ChatGPTAutomation class. Uses AppleScript via subprocess to attempt opening new chat via English menu, Korean menu, or Cmd+N shortcut, returning success status and method used.
    def new_chat(self): """새 ChatGPT 채팅창 열기""" # ChatGPT 앱을 활성화 self.activate_chatgpt() # 메뉴를 통해 새 채팅 열기 시도 script = ''' tell application "System Events" tell process "ChatGPT" try -- 메뉴바에서 File > New Chat 클릭 click menu item "New Chat" of menu "File" of menu bar 1 return "success_menu" on error try -- 한국어 메뉴 시도 click menu item "새 채팅" of menu "파일" of menu bar 1 return "success_menu_kr" on error -- 그래도 안되면 Cmd+N 시도 keystroke "n" using {command down} return "success_shortcut" end try end try end tell end tell ''' result = subprocess.run(['osascript', '-e', script], capture_output=True, text=True) time.sleep(0.5) # 새 채팅창이 열릴 때까지 대기 # 디버깅을 위한 출력 print(f"[DEBUG] new_chat result: returncode={result.returncode}, stdout='{result.stdout}', stderr='{result.stderr}'") # 성공 여부와 사용된 방법 반환 if result.returncode == 0 and result.stdout.strip(): method = result.stdout.strip() if method == "success_menu": return (True, "File > New Chat menu") elif method == "success_menu_kr": return (True, "파일 > 새 채팅 메뉴") elif method == "success_shortcut": return (True, "Cmd+N shortcut") return (False, "unknown")
  • The setup_mcp_tools function defines and registers all MCP tools including new_chatgpt_chat_tool using the @mcp.tool() decorator.
    def setup_mcp_tools(mcp: FastMCP): """MCP 도구들을 설정""" @mcp.tool() async def ask_chatgpt_tool(prompt: str) -> str: """Send a prompt to ChatGPT and return the response.""" return await ask_chatgpt(prompt) @mcp.tool() async def get_chatgpt_response_tool() -> str: """Get the latest response from ChatGPT after sending a message.""" return await get_chatgpt_response() @mcp.tool() async def new_chatgpt_chat_tool() -> str: """Start a new chat conversation in ChatGPT.""" return await new_chatgpt_chat()

Other Tools

Related 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/xncbf/chatgpt-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server