DEV Community

BlaBlaPrice
BlaBlaPrice

Posted on

OAuth or an API key for your MCP server? What we picked for each kind of client

An MCP server usually gets two very different kinds of callers. One is an interactive client where a person sits in front of the screen: Claude, Cursor, ChatGPT in developer mode. The other is a script or a workflow tool that runs without anybody watching, such as n8n. We ended up supporting both on the same server, and the rule that worked is simple: OAuth where a human can press "Allow", a personal key where nobody can.

Why one method is not enough

OAuth sign-in is the right thing for interactive clients. The client opens a sign-in page, the person logs in and presses Allow, and the server issues a token tied to that person. Nobody copies a secret into a config file.

A scheduled workflow cannot do that. There is no screen, no person, and often no browser. For those callers we added a key that belongs to one account. The user creates it in their account settings (in our case a section called "My AI agent") and pastes it into the tool.

The important part is that both paths end in the same place: a normal account with the same limits and the same permissions. We did not build a separate, more powerful "machine" role. That keeps the security review to one question: what can this account do?

What the setup looks like

For interactive clients the config is almost empty, because the sign-in does the work. In Cursor, for example:

{
  "mcpServers": {
    "blablaprice": {
      "url": "https://blablaprice.com/api/mcp"
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Cursor opens the sign-in page on the first call. Claude Code needs one command:

claude mcp add --transport http blablaprice https://blablaprice.com/api/mcp
Enter fullscreen mode Exit fullscreen mode

For n8n we use the MCP Client Tool node: the endpoint is the same URL, the transport is HTTP Streamable, and authentication is Header Auth with Authorization set to Bearer YOUR_KEY.

Things that bit us

  • The key is bound to an account and a country. Our service keeps data per country, so a key belongs to one account in one country. If your server has any kind of tenant boundary, decide early whether a key carries it.
  • Keys leak more easily than tokens. They get pasted into screenshots and shared workflows. Make them revocable in one click and show the user where each one was last used.
  • Both paths need the same rate limits. Otherwise the key becomes the loophole: a loop in a workflow can send far more calls than a person with an assistant ever would.
  • Menu names change. Developer mode in ChatGPT, for example, is only on some plans, and the labels move around. Write your connection guide with the address and the method first and screenshots last.

A checklist before you add keys

  1. Can the same action be done through OAuth? If not, you have created a second, weaker audit trail.
  2. Is the key shown once, stored hashed, and listed with a revoke button?
  3. Does a revoked key stop working immediately, including for long-running workflows?
  4. Do key calls and token calls hit the same limits?
  5. Does the tool description tell the model which actions need a human's confirmation, regardless of how it signed in?

Where this leaves us

Today both methods work on our server and give an assistant the same abilities: post a request, read the answers, write in the chat, and open contacts after the person's explicit yes. We have not tried to make keys safer by giving them a smaller set of tools, and I am not sure that would be the right call. If you have split permissions by credential type, I would like to know how you handled it.

The server described here belongs to BlaBlaPrice, a request-for-quotes service and a meeting point for buyers' and sellers' AI agents. This article was written with the help of an AI assistant by the BlaBlaPrice team.

Top comments (0)