Configuration

MCP

Connect MCP clients to a self-hosted ctxpipe origin. Then diagnose routing and OAuth with ctxpipe doctor mcp and the MCP Inspector.

Self-hosted ctxpipe exposes the same organization-scoped Streamable HTTP endpoint as hosted ctxpipe:

{AUTH_BASE_URL}/mcp

Every client uses this one URL. During authorization, the user chooses the organizations that the client can read. Each tool call names one organization in the org argument. The server accepts the old ?orgSlug= parameter and ignores it.

AUTH_BASE_URL must be the public origin clients use, including TLS. Client JSON shapes and OAuth install paths are the same as on hosted ctxpipe. See Connect your agent and Authentication.

This page is for operators. Confirm that the endpoint is reachable. Then debug OAuth and tools on a test organization.

Ready for OAuth is not authenticated proof

npx ctxpipe doctor mcp checks HTTP routing, TLS or reachability, the unauthenticated Bearer challenge, and OAuth discovery. A ready-for-oauth result does not prove that browser OAuth works. The command does not accept OAuth bearer tokens and does not test STDIO servers. When CTXPIPE_API_KEY is set, it sends the key as x-api-key and reads through MCP: tools/list and a list_workspaces call (ctxpipe 0.6.0 and later).

Connect a client

Use the same config as Quickstart, with your deployment origin:

{
  "mcpServers": {
    "ctxpipe": {
      "type": "http",
      "url": "https://ctx.example.com/mcp"
    }
  }
}

The MCP client must complete OAuth against this deployment. CLI setup sign-in and MCP client OAuth are separate flows.

Diagnose discovery

Run the lightweight doctor against the public MCP URL:

npx ctxpipe doctor mcp \
  --url "$AUTH_BASE_URL/mcp"

npx ctxpipe doctor mcp \
  --url "$AUTH_BASE_URL/mcp" \
  --json

--json is machine-readable. Failures set a non-zero exit code. Loopback HTTP works. Remote endpoints must use HTTPS. The --url path must be /mcp.

From ctxpipe 0.6.0, the doctor runs the target checks of the origin. They are the same checks that the ctxpipe/checks export gives to code:

CheckPasses when
target.statusGET /.status returns JSON with status: "ok"
target.uiGET / serves the module bundle of the UI
target.oauth_metadataRFC 9728 metadata names this origin's /mcp as the resource, and names an authorization server
target.oauth_serverRFC 8414 metadata of that server exposes authorization, token, and registration endpoints
target.mcp_challengeUnauthenticated Streamable HTTP initialize returns 401 with a Bearer challenge that names this origin's resource metadata
target.openapiGET /.docs/openapi returns an OpenAPI 3.1 spec
target.mcp_readWith CTXPIPE_API_KEY: tools/list has list_workspaces, and a call of it answers. Without the key, the check is skip

Overall status is ready-for-oauth, ready-for-api-key (the MCP read passed), or failed. A failed check can carry fix.say, the action to take. Version 0.5 and earlier show the checks Target, Backend status, OAuth challenge, Protected resource and Authorization server, and can give the status warning.

If TLS fails from a Node CLI against a local CA (Portless or a private CA), set NODE_EXTRA_CA_CERTS to the CA file. Do not disable TLS verification.

Authenticated checks with the MCP Inspector

The official MCP Inspector is an external diagnostic client. It is not bundled into ctxpipe or the self-hosted backend. Pin its version. Do not use @latest. Use a test organization. Do not use a customer organization.

npx @modelcontextprotocol/inspector@2.16.0

In the Inspector, select the Streamable HTTP transport, enter $AUTH_BASE_URL/mcp, and connect. The Inspector runs OAuth in the browser. Then list the tools, and call list_workspaces with no arguments. The Inspector shows each JSON-RPC message.

Credentials

Keep OAuth credentials and debug traces out of Git. Review files before sharing. A saved credentials file can include an access token, refresh token, client id, and client secret.

The ctxpipe doctor never accepts or prints OAuth bearer tokens, and never prints an API key. Do not put access_token on the MCP URL.

The Inspector does not prove token refresh races, dropped-session recovery, or concurrent clients. Do not gate CI on interactive OAuth.

Common failures

  • org_not_found or org_required — the tool call named an organization that is not in the connection, an organization that the user is not a member of, or no organization. Pass the right slug in org. For an OAuth connection, add the organization on Connected apps, or reconnect the client and select the organization during authorization.
  • AUTH_BASE_URL mismatch — issuer, callbacks, and MCP discovery must use the same public origin clients see.
  • Remote HTTP — production MCP must be HTTPS.
  • Status unreachable or timed out — backend, DNS, TLS, or an untrusted CA.
  • HTTP 401 without resource_metadata — clients cannot start OAuth discovery.
  • Protected-resource audience mismatch — RFC 9728 resource canonicalizes to /mcp without the query string.
  • Authorization-server metadata missing registration — dynamic client registration cannot proceed.
  • CLI setup sign-in worked, but the MCP client still asks for authorization — expected. Setup auth and MCP OAuth are separate.