feat(client): add credentials: 'include' toggle for cookie-auth servers - #1580
feat(client): add credentials: 'include' toggle for cookie-auth servers#1580SarthakB11 wants to merge 1 commit into
Conversation
Cookie is a forbidden request header, so JS cannot set it manually. The only standards path to send cookies cross-origin is credentials: 'include' on the fetch call. The inspector never set it, so cookie-auth MCP servers were unreachable from the UI without patching the built bundle. Add a client-side toggle in connection settings, persisted to localStorage, applied at both SSE and streamable-http fetch call sites. Off by default. Tooltip notes the server-side CORS requirements (Access-Control-Allow-Credentials + non-wildcard origin). Closes modelcontextprotocol#1454 Signed-off-by: SarthakB11 <sarthak.bhardwaj21b@iiitg.ac.in>
|
Closing: reviewed and declined on security grounds. Thank you for this contribution, and apologies for the long wait for a response. This PR was included in a security review of the full v1 backlog before bulk-closing it (#1819). Unlike most of that backlog — which is closed simply because v1 is deprecated — this change was read closely and is being declined on its merits: as written, it would weaken a security control the Inspector's threat model depends on. Specifically: a The Inspector's backend spawns local processes and proxies outbound requests on the developer's behalf, so it defends in layers: session-token auth, origin validation, loopback-only binding, and an SSRF block-list on the proxy. A change that removes or widens any one of those is a net loss even when it fixes a real usability problem — and several PRs in this group were framed as fixes or improvements, which is exactly why we're recording the decision explicitly rather than closing silently. We're labeling this If the underlying need is real, we'd like to solve it in a way that preserves those controls. Please open an issue against v2 describing the problem you hit (not the patch), and we'll look at it. Note that we accept external contributions as issues rather than pull requests — see |
Title:
feat(web): add "Send cookies" toggle for direct Streamable HTTP connections (closes #1454)Closes #1454.
Summary
Adds a "Send cookies (credentials: include)" checkbox to the connection settings
panel. When enabled, the direct transport passes
credentials: 'include'on itsfetch calls so the browser attaches cookies stored for the target origin. Feature is default-off and follows the same UI+localStorage pattern used in the recently-merged connection-settings additions (#1553, #1551).
The browser treats
Cookieas a forbidden header, so JavaScript cannot set itmanually.
credentials: 'include'is the only standards-compliant way to sendcookies on a cross-origin request. Without it, MCP servers that rely on
cookie-based auth or session routing are unreachable from the inspector UI
unless the built bundle is patched by hand.
Changes
Type is Direct (the option does not apply to the proxy transport, which
forwards cookies server-side).
credentialsIncludeplumbed throughAppintouseConnection; both directfetch call sites (SSE and Streamable HTTP) add
credentials: 'include'onlywhen the toggle is on.
localStorageunderlastCredentialsInclude,matching the existing
lastConnectionTypepersistence.Access-Control-Allow-Credentials: true, a non-wildcardAccess-Control-Allow-Origin, andSameSite=None; Securefor cross-site cookies.Behavior
credentials: 'include'is added to the direct-connection fetchoptions.
Acceptance criteria
transport.
credentials: 'include'to both direct-connection fetch sites.localStorage.Test plan
npm test(client) passes; added twouseConnectiontests covering the enabled and unset cases for the direct transporttsc --noEmit, eslint, andprettier --checkclean on the changed filesCookieheader sent and session established (screenshot / GIF happy to add on request)