@acarmisc/backstage-plugin-litellm-backend 0.21.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -149,6 +149,13 @@ function registerOpencodeRoutes(router, ctx) {
149
149
  .catch(() => []);
150
150
  // Find a healthy existing key (not blocked).
151
151
  const reusable = existing.find(k => k.key_alias === alias && !k.blocked && k.user_id === userId);
152
+ // The gateway requires MCP access on the key itself (require_key_mcp_access_defined), and a
153
+ // key may only list what its team has: copy the team's MCP servers so local clients get
154
+ // the team's tools. A team lookup failure only costs the tools, never the connection.
155
+ const teamPerm = teamId ? (await client.getTeamInfo(teamId).catch(() => undefined))?.object_permission : undefined;
156
+ const mcp = teamPerm?.mcp_servers?.length || teamPerm?.mcp_access_groups?.length
157
+ ? { mcp_servers: teamPerm.mcp_servers ?? [], mcp_access_groups: teamPerm.mcp_access_groups ?? [] }
158
+ : undefined;
152
159
  // Mint a brand-new key bound to this user (and team) under the slot alias.
153
160
  const mintNewKey = async () => {
154
161
  const profile = await (0, provisioning_1.resolveUserProfile)(tokenEntityRef, catalogClient, auth, logger);
@@ -166,6 +173,7 @@ function registerOpencodeRoutes(router, ctx) {
166
173
  ...(teamId && { opencode_team: teamId }),
167
174
  },
168
175
  user_id: userId,
176
+ ...(mcp && { object_permission: mcp }),
169
177
  });
170
178
  return result.key;
171
179
  };
@@ -177,6 +185,10 @@ function registerOpencodeRoutes(router, ctx) {
177
185
  // Rotate the existing key in place via LiteLLM's key regeneration.
178
186
  key = (await client.regenerateKey(keyHashOrId)).key;
179
187
  rotated = true;
188
+ // Rotation keeps the old permissions: refresh them so team MCP changes arrive too.
189
+ // object_permission is not in the shared UpdateKeyRequest type yet (common 0.2.0).
190
+ if (key && mcp)
191
+ await client.updateKey({ key, object_permission: mcp });
180
192
  }
181
193
  catch (err) {
182
194
  // Key regeneration isn't available on every LiteLLM edition. Only
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acarmisc/backstage-plugin-litellm-backend",
3
- "version": "0.21.0",
3
+ "version": "0.22.0",
4
4
  "description": "The Backstage backend plugin for LiteLLM governance",
5
5
  "backstage": {
6
6
  "role": "backend-plugin",