CorpusIQ

MCP Server Debugging Summary

Problem

Receiving “something went wrong” error when trying to connect from ChatGPT.

Root Cause Analysis

✅ What’s Working

  1. Server starts successfully on port 3000
  2. MCP endpoint responds correctly when proper headers are sent
  3. OAuth metadata endpoints are configured and working
  4. Client registration endpoint is functional
  5. CORS is properly configured for https://chat.openai.com

❌ What’s the Issue

The MCP server is running on localhost:3000, which ChatGPT cannot access. ChatGPT needs to connect to your server via HTTPS with a public URL.

Test Results

Successful Test (with proper Accept headers)

.\test_mcp_proper.ps1

Result: ✅ MCP endpoint works correctly

  • Returns SSE formatted responses
  • Tools are listed properly (corpus_search, open_connectors)
  • Widget HTML is included
  • Protocol version: 2024-11-05

Failed Test (without Accept headers)

Error: 406 Not Acceptable: Client must accept both application/json and text/event-stream

This is expected behavior - the MCP protocol requires clients to send:

Accept: application/json, text/event-stream

Solution: Deploy with Public HTTPS Access

You have 3 deployment options:

# Install cloudflared
winget install cloudflare.cloudflared

# Start your MCP server
C:/DevOps/corpusiq-openai-sdk/.venv/Scripts/python.exe -m corpusiq

# In another terminal, create tunnel
cloudflared tunnel --url http://localhost:3000

This will give you a public URL like: https://random-name.trycloudflare.com

Option 2: ngrok

# Install ngrok
winget install ngrok

# Start tunnel
ngrok http 3000

Option 3: Production Deployment

Deploy to a cloud provider with proper SSL/TLS:

  • AWS/Azure/GCP
  • Heroku
  • Fly.io
  • Railway

Configuration Updates Needed

Once you have a public HTTPS URL, update your .env file:

# Replace with your actual public URL
CORPUSIQ_OAUTH_RESOURCE_URL=https://your-actual-url.com
CORPUSIQ_OAUTH_ISSUER=https://your-actual-url.com
CORPUSIQ_OAUTH_AUTHORIZATION_ENDPOINT=https://your-actual-url.com/authorize
CORPUSIQ_OAUTH_TOKEN_ENDPOINT=https://your-actual-url.com/token
CORPUSIQ_OAUTH_JWKS_URI=https://your-actual-url.com/.well-known/jwks.json
CORPUSIQ_OAUTH_REGISTRATION_ENDPOINT=https://your-actual-url.com/register

Connecting to ChatGPT

Once deployed publicly:

  1. Go to ChatGPT Settings
  2. Find MCP/Apps SDK section
  3. Add your MCP server URL: https://your-actual-url.com
  4. ChatGPT will:
    • Discover your OAuth metadata at /.well-known/oauth-protected-resource
    • Register as a client at /register
    • Connect to the MCP endpoint at /mcp

Current Server Status

  • Port: 3000 ✅
  • MCP Endpoint: /mcp
  • OAuth Discovery: /.well-known/oauth-protected-resource
  • Client Registration: /register
  • CORS: Configured for https://chat.openai.com
  • Public Access: ❌ (localhost only)

Quick Start with Cloudflare Tunnel

# Terminal 1: Start server
cd C:\DevOps\corpusiq-openai-sdk
C:/DevOps/corpusiq-openai-sdk/.venv/Scripts/python.exe -m corpusiq

# Terminal 2: Start tunnel
cloudflared tunnel --url http://localhost:3000

# Copy the HTTPS URL from cloudflared output
# Update .env with that URL
# Restart server
# Add URL to ChatGPT

Next Steps

  1. ✅ Server is working correctly locally
  2. ⏭️ Deploy with public HTTPS access (use Cloudflare Tunnel for quick testing)
  3. ⏭️ Update .env with public URL
  4. ⏭️ Restart server
  5. ⏭️ Add server URL to ChatGPT
  6. ⏭️ Test connection from ChatGPT

Additional Notes

  • The 406 error you might have seen initially is normal - it’s the MCP server validating Accept headers
  • ChatGPT will send proper headers automatically
  • The “something went wrong” error is because ChatGPT can’t reach localhost:3000
  • Once publicly accessible, everything should work as designed