> ## Documentation Index
> Fetch the complete documentation index at: https://supastack.dev/llms.txt
> Use this file to discover all available pages before exploring further.
> For the full documentation corpus in one file, fetch: https://supastack.dev/llms-full.txt

# How to add an MCP server to your SaaS so Claude and ChatGPT can use it

Design a remote Streamable HTTP MCP server with per-user OAuth, workspace permissions, small tool schemas, and limits that hold up outside the demo.

_Published 2026-11-25._
_Updated 2026-11-25._

> **What does a SaaS need for Claude and ChatGPT to call its MCP tools?**
> It depends on which clients you need to support. For a user-facing remote integration, start with a Streamable HTTP endpoint and per-user OAuth. Expose a small set of actions with schemas that say what each action does. On every call, check the user's live workspace access and rate limits on the server. Test the connection and authorization flow in each client before promising support.

## Start with one read tool over Streamable HTTP

Put a remote MCP endpoint on HTTPS and choose Streamable HTTP, not the old HTTP+SSE transport with separate endpoints. Streamable HTTP can still use an SSE response when streaming is useful. For a first tool that lists overdue invoices, a normal JSON response is enough.

Use an MCP SDK for protocol handling. Get a real client through initialization, tool discovery, and a call before adding more actions. Claude and ChatGPT have their own connector setup and availability rules. A request working in the MCP Inspector is a good protocol check, not proof that both clients can connect.


## Authorize the person, not the assistant

For a customer-facing connector, follow the [MCP authorization spec](https://modelcontextprotocol.io/specification/2025-11-25/basic/authorization) and use an OAuth 2.1 authorization code flow with PKCE. Publish protected resource metadata so the client can find the authorization server; advertise it in the unauthorized response. Keep consent in your normal sign-in flow, with the selected workspace and requested access visible to the user.

Validate the access token on the MCP server: issuer, expiry, audience for this resource, and scopes. The token identifies the user; it is not a replacement for live membership checks. Try the connection with an ordinary member and test reconnect and revocation. If targeting ChatGPT, check the [Apps SDK auth guidance](https://developers.openai.com/apps-sdk/build/auth/) for its discovery and tool requirements.


## Name tools for what the user is trying to do

Call the tool `list_overdue_invoices`, not `query_billing`. Give it a bounded page size, an optional cursor, and a description of which invoices it reads. Return only the fields required to answer the question. Avoid an arbitrary SQL parameter or a generic filter object that lets the model invent fields.

If customers need to send reminders, make the write a separate tool with a write scope. A preview can return the recipient and amount; sending is a decision a person can confirm. Use idempotency for repeat calls and enforce confirmation on the server where the action needs it. A reassuring tool description cannot enforce either.


## Treat tool arguments like any other untrusted input

Resolve the workspace from the authorized context. If the client can select among workspaces, check that selection against the caller's current membership and permissions. Look up invoice IDs inside that workspace, not across the whole table. Apply the same rule to resources and prompts as to tools. The [workspace boundaries article](https://supastack.dev/blog/workspace-boundaries.md) explains why a valid record ID is not an access grant.

Use limits keyed to the caller or workspace, plus an unauthenticated limit before expensive work. Bound page sizes and concurrency, particularly for reports and exports. Log the tool name, workspace, and outcome so you can spot loops without saving tokens or full customer records in request logs.


## Where to add a tool in supastack

Supastack ships a stateless Streamable HTTP route at `/api/mcp`. Its built-in authentication is scoped workspace API keys from Settings → Developers, not per-user OAuth. The route reuses workspace tools backed by the v1 API permission checks and applies the v1 rate limiter. Start by looking at the existing content and usage tools to see how a bounded operation gets exposed.

That is useful if you control a client that can send an API key. For direct customer connections in Claude or ChatGPT, plan to add the OAuth flow and test it in each target client. The [developer API guide](https://supastack.dev/docs/modules/api.md) covers the key-based setup that is already there.
