DEV Community

Cover image for Building an MCP Server to Use ChatGPT Without API Keys - A Novel Approach Using macOS Shortcuts
Yoshinori Imajo
Yoshinori Imajo

Posted on

Building an MCP Server to Use ChatGPT Without API Keys - A Novel Approach Using macOS Shortcuts

Introduction

Ever wanted to integrate ChatGPT with Claude and other AI tools without dealing with API keys or wasting your monthly subscription?

Instead of the traditional API approach, I solved this challenge using macOS Shortcuts - an unexpected solution that combines existing resource utilization, security, cost efficiency, and simplicity in one innovative approach.

Today, I'll share how I built an MCP server that integrates the Model Context Protocol (MCP) with macOS Shortcuts to solve this exact problem.

What I Built

mcp-server-chatgpt-mac-app

This MCP server enables communication with ChatGPT through the macOS ChatGPT app and Apple Shortcuts, completely bypassing the need for API keys.

The Problems We're Solving

Many developers face these common challenges:

๐Ÿ’ฐ Cost Issues

  • Expensive API usage: Heavy tasks can result in unexpected billing charges
  • Wasted subscriptions: ChatGPT Plus costs $20/month but can't be used via API

๐Ÿ”„ Claude Code Limitations

  • Infinite debugging loops: Weaker LLMs get stuck repeating the same fixes endlessly, never completing tasks

The Core Innovation: Leveraging macOS Shortcuts

The key breakthrough was utilizing macOS Shortcuts functionality.

Mermaid Diagram

Why This Approach is Revolutionary

  1. Leverage Existing Resources: Maximize your already-paid ChatGPT Plus subscription
  2. Enhanced Security: No API key management required
  3. Cost Effective: Zero additional integration costs
  4. Simplicity: Uses only macOS standard functionality

How It Works

The system uses a temporary file-based communication pattern to pass prompts to the shortcuts system, then processes responses back through the MCP protocol.

Key Benefits: Solving Claude Code's Weaknesses

The biggest advantage of this MCP server is compensating for Claude Code's limitations.

Claude Code's Challenges

While Claude Code is an excellent tool, it has some issues:

  • Band-aid coding: Applies quick fixes without considering fundamental design
  • Debug loops: Gets stuck repeating similar fixes indefinitely
  • Rigid thinking: Fixates on one approach, unable to consider alternatives

Rescue with ChatGPT o3

When Claude Code gets stuck in a loop, you can consult ChatGPT o3 via this MCP server:

Ask ChatGPT: "This code has a bug with โ—‹โ—‹, but Claude Code keeps repeating similar fixes. What's the fundamental solution?"
Enter fullscreen mode Exit fullscreen mode

This provides:

  1. Different perspective: Analysis from a different angle than Claude
  2. Root cause identification: Understanding essential problems, not just surface issues
  3. Design-level suggestions: Architectural approaches that rethink the problem

Real Usage Example

When Claude Code gets stuck in loops, using this MCP server to consult ChatGPT o3 gives you:

  1. Different perspective: Analysis from a different angle than Claude
  2. Root cause identification: Understanding essential problems, not just surface issues
  3. Design-level suggestions: Architectural approaches that rethink the problem

Usage

1. Prerequisites

# Install ChatGPT app (official from OpenAI)
# Set up "Ask ChatGPT on Mac" shortcut
Enter fullscreen mode Exit fullscreen mode

2. Global Installation

claude mcp add chatGPTOnMac -s user \
  -- npx mcp-server-chatgpt-mac-app
Enter fullscreen mode Exit fullscreen mode

3. Project-Local Setup

// .mcp.json
{
  "mcpServers": {
    "chatGPTOnMac": {
      "command": "npx",
      "args": ["mcp-server-chatgpt-mac-app"],
      "cwd": ".",
      "env": {}
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

How It Works in Practice

You can give Claude natural instructions like:

Ask ChatGPT: "What's the best way to optimize this code?"
Enter fullscreen mode Exit fullscreen mode

The flow:

  1. MCP server writes prompt to temporary file
  2. macOS shortcut executes
  3. Shortcut sends prompt to ChatGPT app
  4. ChatGPT response returns via Claude

Key Learnings

Power of macOS Automation

macOS Shortcuts proved more powerful than expected:

  • CLI invocation: shortcuts run command available
  • File input: -i option enables file-based input
  • App integration: Tight integration with third-party applications

MCP Protocol Flexibility

I gained real appreciation for the Model Context Protocol design:

  • Pluggable: Easy to add new functionality
  • Type-safe: Robust schema definitions
  • Standardized: Consistency across different AI tools

Conclusion

This project reinforced the importance of "maximizing existing resources through creative engineering." Without using API keys, we achieved cost-effective and secure ChatGPT integration by leveraging Apple Shortcuts - a standard system feature.

If you're paying for monthly subscriptions but still paying separate API fees, this approach is definitely worth trying!


Links

Top comments (0)