Skip to main content
Glama

ask_chatgpt_tool

Send prompts to ChatGPT via the MCP server to receive AI-generated responses, enabling integration with MCP-compatible assistants for dynamic interactions.

Instructions

Send a prompt to ChatGPT and return the response.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYes

Implementation Reference

  • The handler function for the 'ask_chatgpt_tool' MCP tool. It is decorated with @mcp.tool() which registers it with the FastMCP server and delegates the logic to the ask_chatgpt helper function.
    @mcp.tool() async def ask_chatgpt_tool(prompt: str) -> str: """Send a prompt to ChatGPT and return the response.""" return await ask_chatgpt(prompt)
  • The core helper function that implements the logic for sending a prompt to ChatGPT via AppleScript automation on macOS, cleaning the prompt, activating the app, sending keystrokes, waiting for response, and retrieving it.
    async def ask_chatgpt(prompt: str) -> str: """Send a prompt to ChatGPT and return the response. Args: prompt: The text to send to ChatGPT Returns: ChatGPT's response """ await check_chatgpt_access() try: # 프롬프트에서 개행 문자 제거 및 더블쿼츠를 싱글쿼츠로 변경 cleaned_prompt = prompt.replace('\n', ' ').replace('\r', ' ').replace('"', "'").strip() # Activate ChatGPT and send message using keystroke automation = ChatGPTAutomation() automation.activate_chatgpt() automation.send_message_with_keystroke(cleaned_prompt) # Get the response response = await get_chatgpt_response() return response except Exception as e: raise Exception(f"Failed to send message to ChatGPT: {str(e)}")
  • The FastMCP server instance is created and setup_mcp_tools is called to register all tools, including ask_chatgpt_tool.
    mcp = FastMCP("chatgpt") # Setup MCP tools setup_mcp_tools(mcp)

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