Skip to content

Chat sidebar: external MCP connectors (OpenEvidence, cBioPortal MCP), off by default #128

Open

Description

@jjgao

Goal

Let the chat sidebar use external MCP servers ("connectors") the reader switches on, off by default. First two:

  • OpenEvidence — https://oe-playground-723124486874.us-central1.run.app/mcp: one tool, ask_openevidence(question, model?, follow_up_to?), a clinical question answered with cited literature.
  • cBioPortal MCP — https://mcp.cbioportal.org/db/mcp: ClickHouse query tools and guides over cBioPortal's public data.

What I found (probed, no calls made to either tool)

  • OpenEvidence answered initialize and tools/list with no token. If it asks the reader to authenticate, that is at a call, or on their account; to confirm.
  • cBioPortal MCP returns 401 invalid_token with a resource_metadata pointer, and its authorization server publishes discovery metadata at /.well-known/oauth-authorization-server: the standard MCP OAuth flow.
  • @ai-sdk/mcp is already in node_modules (the AI SDK's MCP client, with OAuth support). Not yet checked: that its OAuth API fits the browser-token design below, and that cBioPortal's server accepts dynamic client registration for this app's callback.
  • Outside assistants (claude.ai, Claude Desktop) can already carry both connectors next to this app's WebMCP tools, with no change here. This issue is about the built-in sidebar.

Decisions (agreed)

Question Decision
Where connector calls run The chat route connects to the connectors the reader has on and runs their calls (a browser can't call these servers directly, and a token must be added).
Authentication Per-reader OAuth, token kept in the browser and sent with each chat request. Nothing is stored on our server; it works signed-out. Open servers (OpenEvidence) need no sign-in.
Safeguard against patient data leaving Approve each call: the sidebar shows the server and exact arguments, and the reader clicks Approve or Deny before it runs. The model is also told not to put patient identifiers in a call.
Default Off; the reader switches each connector on.

Rule change this needs

docs/ARCHITECTURE.md says the sidebar "holds no tool of its own", that the route declares page tools without an implementation and the browser runs each call. A connector tool is run by the route. The rule is amended, not dropped: connectors are remote servers the reader switches on; they reach only what the model puts in an approved call, never the app's data, the engine or the page; page tools still run in the browser through window.cohortLab. The CLAUDE.md line (and ARCHITECTURE.md) get the same words, and docs/DATA-BOUNDARY.md gets a paragraph: a connector call sends whatever the model writes to a third party, and the app cannot check it.

Spec

1. Registry

One list in the repo (lib/chat-connectors.ts): { id, name, url, auth: "none" | "oauth", what, sendsFreeText }, holding the two above. A deployment adds or removes entries with an env var (CHAT_CONNECTORS, JSON), validated at startup; a malformed entry is a loud error, not skipped. Only https URLs.

2. The reader's side

  • A "Connectors" menu in the sidebar header: each connector with a switch, what it is for, a notice that calls go to that server, and, for OAuth ones, Connect / Disconnect with the signed-in state.
  • Switches and tokens are kept in the browser (localStorage), and cleared by Disconnect. A connector that needs sign-in and has none cannot be switched on, and says why.
  • The model is told, per request, which connectors are on and what each is for.

3. OAuth

  • Standard MCP OAuth (discovery, dynamic client registration if the server offers it, authorization code with PKCE) through @ai-sdk/mcp, with the browser holding the tokens. A callback page in the app finishes the flow and returns to the sidebar.
  • Expired token: the route says so, the connector shows "sign in again"; the conversation carries on without it.

4. The route

  • /api/chat receives the list of connectors that are on, with their tokens, and connects to each for that request (and closes the connection when the response ends). A connector that cannot be reached, or refuses the token, is reported to the reader and left out for that turn. It never blocks the chat.
  • Connector tools are namespaced (openevidence__ask_openevidence) so they cannot shadow a page tool.
  • Tokens are used for the call and never logged, never cached (lib/next-cache.ts is not involved), never put in a response.

5. Approval

  • A connector tool is declared with needs-approval. The stream stops at the call; the sidebar shows server, tool and exact arguments with Approve and Deny; the model carries on with the result, or with "the reader denied this call".
  • No "always allow".
  • An approval is for one call. A denied call is not retried by the model with the same arguments.

6. Verification

  • Unit tests: registry validation; namespacing; the instructions name only what is on; a token never appears in a response or a log line.
  • E2E (a stub MCP server in the test, not the real ones): off by default; switching on exposes its tools; a call waits for approval; Deny sends nothing.
  • By hand against both real servers, including a full OAuth sign-in to cBioPortal MCP and a call to OpenEvidence.

Out of scope

A server-side token store, connectors for signed-in users across devices, "always allow", and connectors in the outside-assistant path (they already have their own).

Open

  • Does OpenEvidence require a sign-in at call time? (Probe with a real call from a reader's session.)
  • Does mcp.cbioportal.org accept dynamic client registration for this app's origins, including localhost? If not, it needs a registered client id from the cBioPortal team.
  • Does the connector call count toward maxDuration and the 64-tool cap on the request? Tools from a connector with many tools may need an allow-list.
  • Whose approval does a deployment-added connector need? (This design: every reader's, every call.)

Done when

A reader can switch on OpenEvidence and cBioPortal MCP in the sidebar, sign in to the second, and have the assistant use both, with every call shown and approved first, nothing on by default, and the rule change and its data-boundary paragraph written down.

Activity

  1. jjgao commented on Nov 3, 2026

    @jjgao
    MemberAuthor

    Implemented in #129 (stacked on #127). Corrections to the spec above, from the real servers:

    • OpenEvidence does need a credential. Its initialize and tools/list are open, but a call returns send yours in the x-api-token header. So it is not an open connector: there is now a third auth kind, token (the reader pastes an API token, sent in a header the registry names). Resolves the "does OpenEvidence require a sign-in at call time?" open question.
    • mcp.cbioportal.org accepted dynamic client registration with a localhost redirect, but only for confidential clients and with both authorization_code and refresh_token grants. Registration now follows what each server advertises. Resolves the registration open question for localhost; a deployed origin is untested.
    • OpenEvidence holds the server-push GET stream open and answers nothing else while it is, so the client declines that stream.

    Still open: a successful OpenEvidence answer (needs a real token), the full cBioPortal sign-in (needs a person in the browser), and an e2e test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions