Building an MCP server for your SaaS: what we learned shipping one

An MCP server lets your customers use their own AI assistant (Claude, ChatGPT, a coding tool) with the data in your SaaS product, without you building a separate integration for each assistant. The protocol part is small. The work is in the same places as any public API, with a few twists: sign-in that chat assistants can complete on their own, a short list of narrow tools the model cannot misuse, long-running jobs and repeated requests that must not cause duplicate work or charges, and a record of every call. We built one for a database-performance SaaS that is live in production; this article is what that build taught us.

Key takeaways

  • Build a remote server over HTTP and keep it stateless. The current MCP specification (dated 28 July 2026) removed protocol sessions, so any instance can answer any request.
  • Sign-in is the largest piece of work. Chat assistants expect standard OAuth 2.1 with a consent screen; coding tools and scripts are easier with scoped keys. Make both resolve to one customer identity.
  • Expose a few narrow tools, most of them read-only, and enforce limits on the server. The specification says clients must treat a tool's own description of its behaviour as untrusted.
  • Plan for slow work and retries from day one: queue long jobs, return a reference the assistant can check back on, and make repeated requests safe.
  • Reuse the product's existing pipeline, billing and rate limits instead of building a second copy for the MCP route.

If you need the basics first (what MCP is, hosts, clients and servers, and the security questions to ask a vendor), read our plain-English MCP explainer.

Does your SaaS need an MCP server?

It is worth building when your customers already work inside an AI assistant or coding tool and keep asking questions your product can answer: their reports, records, findings or account status. Typical signs:

  • Customers paste data from your product into an assistant to ask about it.
  • You already have, or plan, an in-app AI chat, so the analysis exists and only the route in is new.
  • Enterprise buyers ask whether your product "works with" Claude, ChatGPT or Copilot.

It is not worth building yet if your product has no clean internal API to sit behind it, or if the only thing customers would do through it is the one task your web interface already does well. An MCP server is another front door to your product; it reuses what is behind the door.

What we built

The client runs a SaaS platform that analyses customers' databases and recommends fixes; we built the platform and then an MCP server for it. A customer connects their assistant once, signs in, and can then ask about their projects, databases and recommendations, or send a slow query to the platform for analysis, without leaving the assistant. The client and product stay anonymous at the owner's request, so the rest of this article describes decisions, not tool names or settings.

The decisions below are the ones we would make again, in the order they came up.

Decision 1: a remote, stateless server on its own hostname

A server can run locally on the user's machine (the "stdio" transport) or remotely over "Streamable HTTP". For a SaaS product, remote is the only sensible choice: customers connect by URL, you deploy and update it like the rest of your product, and nothing runs on their machines.

We put the server on its own hostname and made it stateless, so any instance can answer any request and there is no session store to run. The protocol has since moved the same way. The 28 July 2026 revision of the specification removed protocol-level sessions and the Mcp-Session-Id header, dropped the start-up handshake, and has every request carry its own protocol version and client capabilities; servers that need state across calls pass explicit handles as ordinary tool arguments (MCP specification changelog).

Two practical consequences:

  • Deploy it with the product. It is one more service in the same container and continuous-integration pipeline, with the same monitoring and rollback.
  • Name the version you target. The specification has had five dated revisions since November 2024 and the latest changed the transport substantially. Write the target version into the brief and plan who updates the server when the next one lands.

Decision 2: sign-in that assistants can complete, resolving to one identity

This was the largest single piece of work, and it is where a quick prototype differs most from something you can put customer data behind.

What the specification asks for. Authorisation is optional in MCP, but once a server holds customer data you need it. When it is used, the authorisation server "MUST implement OAuth 2.1", the MCP server "MUST implement OAuth 2.0 Protected Resource Metadata" (RFC 9728) so assistants can discover where to sign in, and the server "MUST validate that access tokens were issued specifically for them as the intended audience" (MCP authorization). Clients register in one of three ways: pre-registration, Client ID Metadata Documents (recommended when there is no prior relationship) or Dynamic Client Registration as a fallback (MCP client registration).

What we did. The platform acts as the OAuth 2.1 authorisation server for assistants, with PKCE. That meant building:

  • a consent screen that says plainly what the assistant will be able to do and what it will not;
  • a page in the customer's settings listing connected assistants, each with a revoke button;
  • sign-up in the middle of sign-in, so a new user who arrives through their assistant can create an account without starting over.

Coding tools and scripts use scoped keys instead, which are simpler to paste into a configuration file. Both routes resolve to the same customer identity, so permissions, limits and billing are applied once.

What to watch. The security best practices name "token passthrough" (accepting a token and passing it straight to another service) as explicitly forbidden, and describe the "confused deputy" problem for servers that proxy to third-party APIs (MCP security best practices). If your product already has a mature sign-in system, extend it rather than adding a second one.

Decision 3: a few narrow tools, mostly read-only

An MCP server offers tools (functions the model can call), resources (data it can read) and prompts (templates). Tools are where the risk is.

We exposed a small set of narrowly scoped tools for projects, databases, recommendations, usage and analysis, most of them read-only. The one tool that starts work (sending a query for analysis) goes through the same checks and billing as the web interface. Nothing can change a customer's database or reveal stored credentials.

Three rules shaped the design:

  • Enforce on the server, not in the description. The specification lets a tool declare hints such as readOnlyHint and destructiveHint, but says clients "MUST consider tool annotations to be untrusted unless they come from trusted servers" (MCP tools). The server checks scope and ownership on every call, whatever the tool claims about itself.
  • Write results for a model. Return compact, labelled results with only the fields needed, and cap what can come back in one call. A model reads every word you send and pays for it in tokens.
  • Make errors useful. Tool errors are reported with isError: true so the model can see them; we wrote each one as a plain sentence that says what went wrong and what to try, so the assistant can recover without the user reading a stack trace.

The specification also says there "SHOULD always be a human in the loop with the ability to deny tool invocations", and that applications should show which tools are exposed and ask for confirmation. That is the host's job, not yours: design the server as if a host skipped it.

Decision 4: long-running work and repeated requests

Some useful work takes longer than a normal request. An analysis in this product does, and assistants and network proxies do not wait long.

We queue the work, return a reference immediately, and let the assistant check back for the result. The specification now has an official extension for this pattern, MCP Tasks, whose documentation lists the same reasons: no long-lived connections, a durable handle that survives a disconnect, and status the client can show (MCP Tasks extension).

Retries need the same care. Under the current transport, a broken response stream loses the in-flight request and the client "MUST re-issue it as a new request" (MCP changelog); assistants also retry on their own when they think a call failed. So we made repeated requests safe: a retry of the same request is recognised and does not start, or charge for, a second job.

Decision 5: one pipeline for the web app and the MCP route

The product already had an in-app AI chat built on the same analysis. Rather than copy it, both the web chat and the MCP tools call one shared pipeline, so rate limits, locking, live updates and billing behave the same whichever way the customer arrives. When pricing or limits change, they change in one place.

This is the main reason an MCP server for an existing product is a contained project rather than a second product: most of the value already exists, and the server is a careful new entrance to it.

Decision 6: limits and an audit record for every call

Every credential has its own rate limit, and every call leaves an audit record. A record that shows who, which assistant, which tool, when and with what result answers the questions customers and their security teams ask ("what did the assistant read?"), helps support, and shows which tools are actually used. Combined with the revoke button, it lets a customer cut off an assistant and see exactly what it did.

Decision 7: test each tool and each security rule

We wrote a test for each tool and each security rule, plus a browser end-to-end test of the full sign-in from an assistant's point of view. In any MCP server, the rules worth a test are the ones that protect customers from each other: another customer's data, a missing scope, a revoked connection, an expired sign-in and a repeated request should each fail or behave safely. The MCP project also publishes the MCP Inspector for trying a server by hand, which is useful during development but not a substitute for automated tests in the pipeline.

Should you list the server in the MCP Registry?

Optional. The official MCP Registry is a public catalogue that verifies who owns a namespace; it is "currently in preview", and it "delegates security scanning" to package registries and marketplaces. A listing helps people find a public server; it is not an audit, and a server that only your own customers can sign in to gains little from it. Your own setup guide, one per kind of assistant, matters more: we published one with the product.

What to decide before you start

  1. Which questions customers will ask through an assistant, and which existing internal API answers each.
  2. Which tools are read-only, which start work, and which you will never expose.
  3. How assistants sign in (OAuth 2.1 with consent and revoke) and how scripts sign in (scoped keys), and which identity they resolve to.
  4. What happens with slow work and retries, and how usage is billed.
  5. What is logged, for how long, and who can see it.
  6. Which protocol version you target and who keeps the server current.

Our MCP server development service covers this work for SaaS products and internal systems, and our AI agents work uses the same approach when the assistant is one we build.

FAQ

Do we need our own OAuth authorisation server?

You need one; it does not have to be new. If your product already runs sign-in on a standards-based identity provider, it may be able to act as the authorisation server for MCP, as long as it supports OAuth 2.1 with PKCE and the discovery and client-registration options the specification lists. We extended the product's own sign-in so customers see one consent screen and one list of connected apps.

Can an MCP server change data in our product?

Yes, if you expose tools that do. We recommend starting read-only, adding tools that start work through the same checks and billing as your web interface, and leaving destructive actions out until you have the audit record and approval steps to support them.

Does an MCP server replace our public API?

No. It usually sits on top of the same internal services and exposes fewer, simpler operations shaped for a model. Developers integrating your product directly will still want your normal API.

Which assistants can connect to it?

Any host that implements the protocol's remote transport and sign-in, which as of November 2026 includes the major chat assistants and coding tools; our MCP explainer lists them with sources. Test with each assistant your customers use, because sign-in flows differ in the details.

What does it cost to run?

Mostly what your product already costs per request, plus the work done by the tools. The server itself is a small stateless service; the analysis, storage and model usage behind the tools are where the cost is, which is why we bill MCP usage through the same pipeline as the web app.

Sources (10 links)
Share this article