DEV Community

Cover image for Locking the Doors: How ByteChef Secures Its MCP Servers
ByteChef
ByteChef

Posted on Originally published at blog.bytechef.io AI-assisted

Locking the Doors: How ByteChef Secures Its MCP Servers

TL;DR: The secret in a ByteChef MCP server URL is a routing detail, not a credential. Every server can also require authentication, and does by default: either an API key sent as a Bearer token, or an OAuth2 JWT from an issuer the installation trusts, checked for scope and bound to that one endpoint (RFC 8707), with standard discovery (RFC 9728). ByteChef ships its own authorization server with dynamic client registration too, so Claude and other MCP clients connect with a single Sign in. The Management MCP server follows the same model with tighter defaults, and v0.38 lets each member hook a coding agent up to it with their own key, limited to one workspace and one environment.

In the MCP server post we made a slightly scary idea sound simple: hand an AI a URL and it can run your workflows. Those workflows send email, update CRMs and shuffle customer data around. A door like that is worth exactly as much as its lock, so this post is about the lock.

First, a misunderstanding we see a lot. An address like /api/automation/{secretKey}/mcp makes it look as if the long random string is the security. It isn't, and understanding why explains everything that follows.

The URL secret routes, it doesn't authenticate

The secret in the path does one thing: it tells ByteChef which MCP server a request is meant for and, on multi-tenant installations, which tenant owns that server. It says nothing about who is calling.

That distinction matters because URLs leak more easily than any other kind of secret. They land in browser history, proxy logs, screenshots and config files pasted into chat. So each MCP server has a Require authentication switch, which the UI describes as "Require an API key or OAuth token in addition to the server URL." It is on by default. While it's on, a request without a valid Authorization: Bearer header gets a 401 no matter how correct the URL is. A leaked URL by itself gets an attacker nowhere.

You should still tidy up after a leak, which is why the server page labels its connection snippets Sensitive and lets you regenerate the URL. The difference is that a leak is now a chore instead of a breach.

What goes into that Bearer header depends on how far up the ladder you need to climb.

Step one: API keys

The simplest credential is an API key used as the Bearer token. Create one in the Automation workspace under Settings → API Keys and hand it to your client. If the client lets you set request headers, that is one line:

Authorization: Bearer YOUR_API_KEY
Enter fullscreen mode Exit fullscreen mode

Manual connection steps in ByteChef: paste the server URL, then add an authorization request header with the value Bearer YOUR_API_KEY

Some clients have nowhere to put request headers, Claude Desktop's config file being one example. For those, the Connect tab gives you a snippet that runs mcp-remote and passes the same header on the command line.

The server side is boring on purpose. ByteChef reads the tenant from the URL secret, then checks that the key is valid and belongs to that same tenant, environment and workspace. A key from one workspace does not open a server in another. Only after that does the request run, inside that tenant, so everything downstream is scoped by construction. Without a valid key you get no tools, and not even a tool list.

For a team connecting its own Claude to its own ByteChef, this is a perfectly reasonable place to stop: two secrets you can rotate independently, and a clean 401 for everybody else.

Step two: tokens from your own identity provider

Bigger organizations ask harder questions. Can our identity provider issue the credentials? Can tokens expire and carry scopes? ByteChef's OAuth2 resource server covers part of that: an automation MCP server can accept JWTs from an identity provider your installation trusts.

That trust is configuration, owned by whoever operates ByteChef. Each trusted issuer is an entry under bytechef.oauth2.resource-server.issuers. The shipped configuration already contains one, ByteChef's own authorization server (more on it below). Add your identity provider as an additional entry and keep the existing one, because setting the list replaces it. Note that identity providers added under Settings → Identity Providers are a separate thing: those are for signing in to ByteChef, and MCP servers don't accept their tokens.

Five details are worth knowing:

  • It lives next to API keys, not instead of them. ByteChef only treats a Bearer token as OAuth2 when it arrives on an MCP path and actually looks like a JWT. API key clients keep working, JWT clients get the richer model, and the rest of the API is untouched.
  • More than one issuer can be trusted. Tokens are checked against every configured issuer, so your corporate identity provider and a second one can be trusted side by side. Federation is just another entry in the list, not a special mode.
  • Scope and audience are checked per endpoint. After the signature verifies, ByteChef confirms the token carries the scope for the endpoint it is calling (mcp:automation for automation servers) and that its audience is bound to that exact endpoint, as RFC 8707 describes. The audience check is the quiet hero here: a perfectly valid token issued for one server is rejected by every other one. A stolen token doesn't travel.
  • In v0.37 this applies to automation MCP servers. The Management MCP server's address, /api/management/mcp, accepts only tokens ByteChef issued itself, so your identity provider's tokens can't reach the builder's tools. v0.38 adds a way in, covered below.
  • The issuer entry decides the permissions. ByteChef doesn't look up the token's subject as a ByteChef user. The subject names the caller, and the permissions come from the issuer entry: a fixed authorities list, or an authorities-claim naming the token claim that holds them. If you set a tenant-claim, it has to match the server's tenant.

Discovery: tell clients how to get in, and nothing more

Modern MCP clients don't want you configuring authentication by hand. They expect to discover it. ByteChef follows RFC 9728: when OAuth2 is on and an unauthenticated request arrives, the 401 carries a WWW-Authenticate: Bearer header with a resource_metadata link. That link points to a document describing the endpoint and naming one authorization server: the first trusted issuer, which in the shipped configuration is ByteChef's own. One round trip and the client knows where to get a token.

With no trusted issuer configured, ByteChef replies with a plain 401: no hint, no metadata, nothing for an attacker to learn. The server doesn't advertise machinery it doesn't have.

Step three: ByteChef's own authorization server

Bringing your own identity provider is great when you have one. Plenty of teams don't, or don't feel like registering a new app for every assistant they try out. So ByteChef can issue tokens as well as check them.

It ships a full authorization server built on Spring Authorization Server. It is on by default (bytechef.oauth2.authorization-server.enabled: true) and needs bytechef.public-url, which becomes the token issuer. The shipped configuration trusts its own tokens through a self issuer entry, so they go through the same resource server checks as tokens from your identity provider. A few things make it a good fit for MCP:

  • Clients register themselves. Dynamic client registration is on for MCP, which is how the MCP specification expects onboarding to work. A compliant client such as Claude registers itself and runs the OAuth flow. No administrator creates client IDs and nobody sends secrets over Slack. Administrators can still review and manage registered clients in the settings.
  • Tokens know where they're going. The client names the MCP endpoint it wants (the RFC 8707 resource parameter), and the token is bound to that endpoint from the moment it is issued. Trying to switch it to a different endpoint later fails with invalid_target.
  • Signing in is one click. This is what powers the One click path in the Connect tab of every MCP server. In Claude you add ByteChef as a custom connector, paste the URL, click Sign in and approve access on ByteChef's consent page. There is no key to copy anywhere.

API keys remain available alongside all of this, for clients and scripts that prefer them.

The Management MCP server gets stricter defaults

The automation MCP server lets an AI run your workflows. The Management MCP server, at /api/management/mcp, sits a level above that and gives an AI the builder's tools: searching components, creating projects, writing workflows, publishing them. That is a lot more power, so the defaults are stricter.

Its URL contains no secret at all, so the credential alone decides which account a request belongs to. Authentication is always required, with no switch to turn it off, and OAuth2 tokens need their own mcp:management scope. Because of audience binding, a token issued for an automation server is useless against it.

In v0.37 it accepts two credentials: signing in with ByteChef, or an admin API key (an Enterprise Edition feature).

Coming in v0.38: a key per member, workspace and environment

An admin key is the wrong thing to paste into a coding agent. The agent stores it in a config file and runs it next to untrusted input, and if it leaks, the whole account leaks with it. v0.38 adds a narrower option and makes the admin key's role clearer.

  • Members can use their own workspace API key. The same kind of key you create under Settings → API Keys now works on the Management MCP server too, and every member can copy its address, /api/management/mcp, from Settings → MCP Server. The key is bound to its own workspace and environment: tools default to them, and naming another workspace, another environment or an object from another workspace is refused. listWorkspaces returns only that workspace, and an X-ENVIRONMENT header has to match the key's environment or the request gets a 401.
  • It carries your permissions, never more. The tools act with the member's own role in that workspace, and an admin's own workspace key doesn't carry tenant administration rights either. The key stops working when its owner leaves the workspace. Embedded API keys are rejected with a 401.
  • Your identity provider reaches the Management MCP server too. Its tokens don't say which ByteChef account they belong to, so the shared /api/management/mcp address still refuses them. When your installation trusts an issuer other than ByteChef's own, Settings → MCP Server now shows admins a second address for those tokens, /api/management/<secret>/mcp, whose secret names your account. The token still needs the mcp:management scope and an audience bound to that address, and Regenerate replaces the address if it leaks.
  • Admin keys span every environment. An admin key already worked in every environment, but it was still created under one. In v0.38 it has no environment of its own, and the Admin API Keys page lists every key whichever environment you're in. A script picks the environment per request with the X-ENVIRONMENT header, and the Enterprise Edition audit log records the environment each call used. Admin keys are meant for administration scripts, not agents.

So the advice for a coding agent is short: sign in with ByteChef, or give it your own Development workspace key. If that key leaks, the damage stays inside one workspace in one environment.

The ladder at a glance

API key OAuth2, your identity provider OAuth2, built-in server
Credential Workspace API key as Bearer JWT from an issuer in the installation config JWT issued by ByteChef
URL secret Routes only Routes only Routes only
Tenant From the URL, key must match From the URL, optional tenant claim must match From the URL and token claims
Scope The key's workspace mcp:automation mcp:automation, mcp:management
Stolen credential Revoke the key Audience binding (RFC 8707) Audience bound at issue time
Client setup Paste URL and key Client gets the token from your identity provider Dynamic registration and one-click Sign in
Unauthenticated request Plain 401 401 with discovery link 401 with discovery link

Read the table as a whole and the pattern is well-known standards, stacked carefully: Bearer tokens, resource indicators, protected resource metadata, dynamic registration. No home-made cryptography and no clever proprietary handshakes, just the RFCs the MCP ecosystem is converging on, plus the tenant awareness a multi-tenant platform needs.

A checklist for your own MCP servers

Exposing your automations to AI is only a good idea if the door has a real lock. You climb the ladder as far as your requirements take you: a URL that only routes, a credential on every server by default, and scoped, endpoint-bound OAuth2 once the enterprise questions show up, issued by your identity provider or by ByteChef itself.

Setting up an MCP server? Here is the short version:

  1. Keep Require authentication on.
  2. Connect Claude with Sign in, or give your client a workspace API key.
  3. Regenerate the URL if it ever leaks.
  4. If your organization runs an identity provider and wants its tokens accepted on automation MCP servers, add it under bytechef.oauth2.resource-server.issuers.

The MCP Servers docs cover each option in detail.


Originally published on the ByteChef blog.

Top comments (1)

Collapse
 
lycore profile image
Lycore Development •

Treating the URL secret as routing rather than authentication is the right framing, since URLs leak into logs and screenshots all the time. Binding the JWT to one endpoint with RFC 8707 resource indicators also stops a token for one MCP server from being replayed against another. How do you handle revocation for the per-member keys, for example when someone leaves a workspace? Is it immediate on the next request, or does it wait for a cache or token expiry?