Skip to content

🔓 fix: Keep owner as the Default Mode for API Key Runs - #18448

Open
danny-avila wants to merge 1 commit into
devfrom
danny-avila/key-grants-owner-default
Open

danny-avila wants to merge 1 commit into
devfrom
danny-avila/key-grants-owner-default

Conversation

@danny-avila

Copy link
Copy Markdown
Collaborator

Summary

#18377 made delegated the default of endpoints.agents.remoteApi.integrations.mode. On upgrade, a run started with a personal API key had every MCP tool call refused until the operator declared the servers keys may be granted and the key's owner granted them. A deployment that never asked for grants would see its API integrations stop using MCP tools with nothing in the response to say why.

This PR makes owner the default again. A key run uses the MCP servers its owner can, as before grants existed. delegated is unchanged and stays available as an opt-in: set the mode, declare integrations.resources, and owners grant their keys in Settings → API Keys.

The config loader's warning from #18377 is kept for the case it still describes: an operator who sets delegated and declares no server, which leaves key runs with nothing an owner can grant.

Related to #18377, #18280, #13824.

How it works

 export function resolveRemoteIntegrations(appConfig?: AppConfig): RemoteIntegrations {
   const integrations = appConfig?.endpoints?.[EModelEndpoint.agents]?.remoteApi?.integrations;
   return {
-    mode: integrations?.mode ?? 'delegated',
+    mode: integrations?.mode ?? 'owner',
 // packages/api/src/app/loader.ts, reportUngrantableKeyRuns
-  if (integrations?.mode === 'owner' || declared) {
+  if (integrations?.mode !== 'delegated' || declared) {
     return;
   }

Everything that reads the mode goes through resolveRemoteIntegrations: the grant step on each remote request, the consent service's limits for keys, and the flag on GET /api/api-keys that shows the "MCP access" button. With the mode unset, none of them does anything.

Type of change

  • Bug fix

Testing

Tested environments/configuration: WSL2, Node.js 24. No external services.

Automated tests:

  • packages/api/src/apiKeys/grants.spec.ts: with no integrations block, an empty one, or mode: owner, a key run is unrestricted and the view offers nothing; under delegated the existing grant tests apply.
  • packages/api/src/apiKeys/handlers.spec.ts, api/server/routes/__tests__/apiKeys.spec.js: the key list carries grants: true only under delegated.
  • api/server/services/ApiKeys/grants.spec.js: the real wiring leaves a key run untouched when the configuration says nothing.
  • packages/api/src/app/loader.spec.ts: the warning fires for delegated with no declared server; it does not for delegated with servers, for owner, for a configuration that uses the remote API and leaves the mode alone, or for one that does not mention the remote API.

Putting the default back to delegated, or the warning's old condition, fails tests.

npx tsc --noEmit is clean in packages/api and packages/data-provider.

Performance

With the mode unset, a key request no longer reads the key's grant at run start, and MCP tool calls skip the grant check, as before #18377. Nothing is added.

Risk / compatibility

A deployment that upgraded to a build with #18377 and relied on the delegated default goes back to unrestricted key runs unless it sets mode: delegated. Grants already made stay stored on the keys and apply again once the mode is set.

No stored-data change.

#18377 made `delegated` the default of endpoints.agents.remoteApi.integrations.mode, so
on upgrade a run started with a personal API key lost its MCP tools until the operator
declared servers and the key's owner granted them. That is a surprise for deployments
that never asked for grants.

The default is `owner` again: a key run uses the MCP servers its owner can, as before
grants existed. `delegated` stays available as an opt-in. The config loader's warning now
fires only for an operator who sets `delegated` and declares no server to grant.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant