MCP Server Debugging Summary
Problem
Receiving “something went wrong” error when trying to connect from ChatGPT.
Root Cause Analysis
✅ What’s Working
- Server starts successfully on port 3000
- MCP endpoint responds correctly when proper headers are sent
- OAuth metadata endpoints are configured and working
- Client registration endpoint is functional
- 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:
Option 1: Cloudflare Tunnel (Recommended for Development)
# 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:
- Go to ChatGPT Settings
- Find MCP/Apps SDK section
- Add your MCP server URL:
https://your-actual-url.com - 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
- Discover your OAuth metadata at
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
- ✅ Server is working correctly locally
- ⏭️ Deploy with public HTTPS access (use Cloudflare Tunnel for quick testing)
- ⏭️ Update .env with public URL
- ⏭️ Restart server
- ⏭️ Add server URL to ChatGPT
- ⏭️ 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