CorpusIQ

ChatGPT Integration Steps

✅ IMPORTANT: OAuth Storage Now Enabled!

Your server now has persistent OAuth storage that saves:

  • ✅ Registered OAuth clients
  • ✅ Authorization codes
  • ✅ Access tokens

See OAUTH_STORAGE_SETUP.md for details on the OAuth implementation.

✅ IMPORTANT: Use This URL

When adding the app in ChatGPT, try these URLs in order:

Option 1: Plugin Manifest (Try This First):

https://mcp.sqltrainer.com/.well-known/ai-plugin.json

Option 2: OpenAPI Spec:

https://mcp.sqltrainer.com/openapi.json

Option 3: Base Domain (for MCP):

https://mcp.sqltrainer.com

Current Status ✅

Your server is properly configured and accessible:

All endpoints now support both GET and POST methods!

Why the App Isn’t Created Yet

ChatGPT has successfully:

  1. ✅ Discovered your OAuth metadata
  2. ✅ Registered as a client (you see the 201 response in logs)

But the app won’t appear in ChatGPT until you manually add it in the ChatGPT interface.

Steps to Add Your App in ChatGPT

Option 1: Add via ChatGPT Settings

  1. Open ChatGPT (https://chat.openai.com)

  2. Go to Settings:

    • Click your profile picture (bottom left)
    • Click “Settings”
  3. Navigate to Apps/Extensions:

    • Look for “Apps” or “Extensions” or “Integrations” section
    • This may also be under “Beta features” or “Labs”
  4. Add New App:

    • Click “Add App” or “Connect App” or similar button
    • Enter your server URL: https://mcp.sqltrainer.com
  5. ChatGPT Will:

    • Discover your OAuth endpoints automatically
    • Use the already-registered client credentials
    • Connect to your MCP endpoint
    • Show your tools: corpus_search and open_connectors
  1. Create a Custom GPT:

  2. Configure Actions:

    • Click “Configure” tab (top)
    • Scroll down to “Actions” section
    • Click “Create new action”
  3. Import OpenAPI Schema:

    • Click “Import from URL”
    • Try these URLs in order:
      1. https://mcp.sqltrainer.com/.well-known/ai-plugin.json (Plugin format)
      2. https://mcp.sqltrainer.com/openapi.json (OpenAPI format)
    • Click “Import”
  4. Configure OAuth (should auto-configure from the spec):

  5. Test the Integration:

    • Use the preview panel on the right
    • Try: “Search my corpus for information about X”
    • You should see the action being called

Option 3: Direct API Key Configuration (if supported)

Some ChatGPT interfaces allow you to add an MCP server directly:

  1. Look for “MCP Servers” or “Model Context Protocol” settings
  2. Add server URL: https://mcp.sqltrainer.com
  3. The OAuth flow will happen automatically

Troubleshooting

If App Still Doesn’t Appear

  1. Check ChatGPT Plus/Team/Enterprise Subscription:

    • Custom apps/MCP might require a paid subscription
    • Free tier may not support custom integrations
  2. Verify OAuth Flow:

    • Watch your server logs when you try to add the app
    • You should see:
      • GET to /.well-known/oauth-protected-resource
      • POST to /register (already working)
      • GET to /authorize
      • POST to /token
  3. Check for Errors in ChatGPT:

    • Look for error messages when adding the app
    • Common issues:
      • “Invalid OAuth configuration”
      • “Could not verify server”
      • “Connection failed”
  4. Verify HTTPS Certificate:

Expected Behavior After Adding

Once added successfully, you should be able to:

  1. Ask ChatGPT questions that trigger your tools:

    • “Search my corpus for information about X”
    • “What did we decide about Y?”
    • “Open connectors”
  2. See the Widget:

    • ChatGPT should display your custom CorpusIQ widget
    • Widget shows search interface and connector management
  3. View Tool Calls in Logs:

    INFO - Tool call: corpus_search
    INFO - Search completed: 5 results found
    

Testing Without ChatGPT

You can test your MCP server using the test scripts:

# Test MCP endpoint
.\test_mcp_proper.ps1

# Test OAuth metadata
Invoke-RestMethod https://mcp.sqltrainer.com/.well-known/oauth-protected-resource

# Test client registration
Invoke-RestMethod https://mcp.sqltrainer.com/register -Method POST -Body '{"client_name":"Test"}' -ContentType "application/json"

Next Steps

  1. ✅ Your server is ready
  2. ⏭️ Add the app in ChatGPT interface (see options above)
  3. ⏭️ Test the integration
  4. ⏭️ Monitor server logs for any errors

Important URLs

All endpoints are working correctly! ✅