Skip to main content

Trends, tech news, and tool comparisons.

How to add an MCP server to an existing SaaS

· 7 min read
Dealpuffin
Proof points and live coupons for early adopters

To add an MCP server to an existing SaaS, build a thin layer over the API you already run. Choose a handful of tasks people want an AI assistant to do, expose each as a named tool with a typed input schema, call your own API inside the handler, and protect the HTTP endpoint with OAuth. You do not rewrite your backend, and a first version fits in a few hundred lines.

The protocol details below come from the Model Context Protocol documentation and specification, read on 20 November 2026. If you are still deciding whether to build one, MCP server vs REST API for a SaaS covers that choice.

Step 1: pick a few tasks, not your whole API​

An MCP server describes tools that a model chooses between. A long list makes that choice harder, so do not mirror every endpoint. Write down the five things a customer would ask an assistant to do in your product, then keep the three to five that are most useful and safest.

A good first set for a typical SaaS:

  1. One or two read tools, such as "search invoices" or "get project status".
  2. One write tool that is easy to undo, such as "create a draft".
  3. Nothing that deletes data or spends money until you have watched real usage.

Name tools with a verb and an object (search_invoices, create_draft). The model reads the name and description to decide when to call it, so write the description for the model: what the tool does, when to use it, and what it returns.

Step 2: choose a language and an SDK​

The official build-a-server guide shows the same weather example in Python, TypeScript, Java, Kotlin, C#, Ruby, Rust and Go. Use the one your backend already runs in, so the handlers can import your existing service code instead of calling your API over the network.

In TypeScript a tool is registered with a description and an input schema, followed by a handler. The guide's example looks like this, with the body left for you to fill in:

server.registerTool(
"search_invoices",
{
description: "Search invoices by customer name or status",
inputSchema: z.object({
query: z.string().describe("Customer name or invoice status"),
}),
},
async ({ query }) => {
// call your existing service or API here and return text content
},
);

Describe each argument. The guide does it with .describe(...) in TypeScript and a docstring in Python, because those descriptions are part of what the model sees.

Step 3: use the right transport​

MCP has two common ways to run. A stdio server runs as a local process that a desktop client starts, which suits a developer tool. A server that serves many customers belongs behind HTTP so people connect to a URL. The build guide has one warning for stdio: never write to standard output, because that corrupts the JSON-RPC messages. It says logging to stdout is fine for HTTP-based servers. Send your logs to a file or standard error either way.

For a SaaS with accounts, plan on the HTTP transport. Your customers should not have to install anything.

Step 4: return errors the model can fix​

The tools specification separates two kinds of failure. Protocol errors, such as an unknown tool or a malformed request, come back as standard JSON-RPC errors. Errors from the work itself, such as a failed API call, a bad date format or a business rule, belong in the tool result with isError: true, and the spec says clients should pass those to the model so it can correct itself and retry.

So write error text for the model. "Invalid departure date: must be in the future" is something it can act on. "Error 500" is not.

Step 5: add authentication​

Authorization is optional in the spec, but a SaaS server returns customer data, so treat it as required. For HTTP servers the authorization specification says implementations should follow its OAuth 2.1 based flow, and it adds three requirements:

  1. Servers must implement OAuth 2.0 Protected Resource Metadata (RFC 9728), which is how clients discover your authorization server.
  2. Servers must check that each access token was issued for them as the intended audience.
  3. Stdio servers should not use this flow and should read credentials from the environment instead.

If you already use an identity provider, point the metadata at it rather than building an authorization server. The token should map to the same user and permissions your API already enforces, so a tool can never see more than the person could in your web app.

Step 6: apply the same limits as your API​

The spec says servers must validate all tool inputs, implement access controls, rate limit tool invocations and sanitize tool outputs. An assistant can call a tool far more often than a person clicks a button, so reuse your existing limits. How to add rate limiting to a SaaS API covers the common patterns. The spec also says there should always be a human able to deny a tool call, and that clients should confirm sensitive operations, which is another reason to start with read tools and reversible writes.

If a tool triggers a paid model call or another metered cost, cap it too. How to cap AI API costs in a SaaS shows how.

Step 7: test with a real client​

Connect the server to a desktop or IDE client that supports MCP and try the prompts a customer would type. Watch which tool it picks and whether the arguments are right. When it picks the wrong tool, the fix is almost always a clearer name or description, not more code. Test the failure paths too: an expired token, a missing record, an invalid argument.

A short checklist before you publish​

  • Three to five tools, each with a verb-and-object name.
  • Every argument described.
  • Errors returned with isError: true and a message that says how to fix the call.
  • OAuth with protected resource metadata and audience checks on tokens.
  • The same permissions and rate limits as your web app.
  • Logs that never touch standard output on a stdio server.

When it works, tell people it exists. Put the server URL in your docs and changelog, and list it where assistants and developers look for tools.

Frequently asked questions​

Do I need to rewrite my API to add an MCP server?​

No. The server is a layer that calls your existing API or service code. Tools map to tasks, not endpoints, so you pick the useful ones and leave the rest.

Is authentication required in MCP?​

The specification says authorization is optional for MCP implementations. Any server that returns customer data should still require it, and for HTTP servers the spec recommends following its OAuth 2.1 based approach.

Which language should I build the server in?​

The official guide has examples in Python, TypeScript, Java, Kotlin, C#, Ruby, Rust and Go. Pick the one your backend already uses so handlers can reuse your code.

How many tools should the first version have?​

Three to five is enough for a first release. Fewer tools make it easier for a model to choose correctly, and you can add more after you see how people use them.