## Summary

When a remote MCP client (Claude Desktop, Cursor, or a web-based MCP inspector) fails to connect to your hosted MCP endpoint with `401 Unauthorized` or `CORS policy: Response to preflight request doesn't pass access control check`, the server is either missing `OPTIONS` preflight headers or rejecting OAuth/Bearer discovery.

If you want this fixed cleanly, SazM debugs remote MCP servers and auth/CORS issues for a **fixed $99, delivered within 48 hours**, 100% in writing with zero calls. See our [AI integration services](/ai-integration-services) or [request the $99 fix](/contact?offer=emergency).

## 1. Handle `OPTIONS` Preflight & `Mcp-Session-Id`

- Browser-based MCP clients send an `OPTIONS` preflight before `POST /mcp`.
- Return `204` with `Access-Control-Allow-Origin: *`, `Access-Control-Allow-Methods: GET, POST, OPTIONS`, and `Access-Control-Allow-Headers: Content-Type, Authorization, Mcp-Session-Id`.
- Expose `Mcp-Session-Id` via `Access-Control-Expose-Headers` so clients can read session IDs.

## 2. Public vs. Authenticated MCP Endpoints

- For public read-only MCP servers (like `sazm.in/mcp`), do not require OAuth on `initialize` or `tools/list`; for private servers, return `401` with a valid `WWW-Authenticate` header pointing to `/.well-known/oauth-protected-resource`.

## Need It Fixed?

We run a live 5-tool public MCP server on Cloudflare Workers (`sazm.in/mcp`) and fix remote MCP auth, CORS, and transport bugs for a **fixed $99 within 48 hours**, verified before you pay and 100% async. [Start your $99 fix](/contact?offer=emergency) or explore our [AI integration services](/ai-integration-services).
