@backstage/plugin-mcp-actions-backend 0.1.9-next.0 → 0.1.9

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # @backstage/plugin-mcp-actions-backend
2
2
 
3
+ ## 0.1.9
4
+
5
+ ### Patch Changes
6
+
7
+ - 31de2c9: Added OAuth Protected Resource Metadata endpoint (`/.well-known/oauth-protected-resource`) per RFC 9728. This allows MCP clients to discover the authorization server for the resource.
8
+
9
+ Also enabled OAuth well-known endpoints when CIMD (Client ID Metadata Documents) is configured, not just when DCR is enabled.
10
+
11
+ - 8148621: Moved `@backstage/backend-defaults` from `dependencies` to `devDependencies`.
12
+ - 69d880e: Bump to latest zod to ensure it has the latest features
13
+ - Updated dependencies
14
+ - @backstage/plugin-catalog-node@2.0.0
15
+ - @backstage/backend-plugin-api@1.7.0
16
+ - @backstage/catalog-client@1.13.0
17
+
18
+ ## 0.1.9-next.1
19
+
20
+ ### Patch Changes
21
+
22
+ - 8148621: Moved `@backstage/backend-defaults` from `dependencies` to `devDependencies`.
23
+ - Updated dependencies
24
+ - @backstage/plugin-catalog-node@2.0.0-next.1
25
+ - @backstage/catalog-client@1.12.2-next.0
26
+ - @backstage/backend-plugin-api@1.7.0-next.1
27
+
3
28
  ## 0.1.8-next.0
4
29
 
5
30
  ### Patch Changes
package/README.md CHANGED
@@ -75,7 +75,7 @@ export const myPlugin = createBackendPlugin({
75
75
 
76
76
  When errors are thrown from MCP actions, the backend will handle and surface error message for any error from `@backstage/errors`. Unknown errors will be handled by `@modelcontextprotocol/sdk`'s default error handling, which may result in a generic `500 Server Error` being returned. As a result, we recommend using errors from `@backstage/errors` when applicable.
77
77
 
78
- See https://backstage.io/docs/reference/errors/ for a full list of supported errors.
78
+ See https://backstage.io/api/stable/modules/_backstage_errors.html for a full list of supported errors.
79
79
 
80
80
  When writing MCP tools, use the appropriate error from `@backstage/errors` when applicable:
81
81
 
@@ -53,9 +53,12 @@ const mcpPlugin = backendPluginApi.createBackendPlugin({
53
53
  router.use("/v1/sse", sseRouter);
54
54
  router.use("/v1", streamableRouter);
55
55
  httpRouter.use(router);
56
- if (config.getOptionalBoolean(
56
+ const oauthEnabled = config.getOptionalBoolean(
57
57
  "auth.experimentalDynamicClientRegistration.enabled"
58
- )) {
58
+ ) || config.getOptionalBoolean(
59
+ "auth.experimentalClientIdMetadataDocuments.enabled"
60
+ );
61
+ if (oauthEnabled) {
59
62
  rootRouter.use(
60
63
  "/.well-known/oauth-authorization-server",
61
64
  async (_, res) => {
@@ -66,6 +69,19 @@ const mcpPlugin = backendPluginApi.createBackendPlugin({
66
69
  res.json(await oidcResponse.json());
67
70
  }
68
71
  );
72
+ rootRouter.use(
73
+ "/.well-known/oauth-protected-resource",
74
+ async (_, res) => {
75
+ const [authBaseUrl, mcpBaseUrl] = await Promise.all([
76
+ discovery.getBaseUrl("auth"),
77
+ discovery.getBaseUrl("mcp-actions")
78
+ ]);
79
+ res.json({
80
+ resource: mcpBaseUrl,
81
+ authorization_servers: [authBaseUrl]
82
+ });
83
+ }
84
+ );
69
85
  }
70
86
  }
71
87
  });
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs.js","sources":["../src/plugin.ts"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n coreServices,\n createBackendPlugin,\n} from '@backstage/backend-plugin-api';\nimport { json } from 'express';\nimport Router from 'express-promise-router';\nimport { McpService } from './services/McpService';\nimport { createStreamableRouter } from './routers/createStreamableRouter';\nimport { createSseRouter } from './routers/createSseRouter';\nimport {\n actionsRegistryServiceRef,\n actionsServiceRef,\n} from '@backstage/backend-plugin-api/alpha';\n\n/**\n * mcpPlugin backend plugin\n *\n * @public\n */\nexport const mcpPlugin = createBackendPlugin({\n pluginId: 'mcp-actions',\n register(env) {\n env.registerInit({\n deps: {\n logger: coreServices.logger,\n auth: coreServices.auth,\n httpAuth: coreServices.httpAuth,\n httpRouter: coreServices.httpRouter,\n actions: actionsServiceRef,\n registry: actionsRegistryServiceRef,\n rootRouter: coreServices.rootHttpRouter,\n discovery: coreServices.discovery,\n config: coreServices.rootConfig,\n },\n async init({\n actions,\n logger,\n httpRouter,\n httpAuth,\n rootRouter,\n discovery,\n config,\n }) {\n const mcpService = await McpService.create({\n actions,\n });\n\n const sseRouter = createSseRouter({\n mcpService,\n httpAuth,\n });\n\n const streamableRouter = createStreamableRouter({\n mcpService,\n httpAuth,\n logger,\n });\n\n const router = Router();\n router.use(json());\n\n router.use('/v1/sse', sseRouter);\n router.use('/v1', streamableRouter);\n\n httpRouter.use(router);\n\n if (\n config.getOptionalBoolean(\n 'auth.experimentalDynamicClientRegistration.enabled',\n )\n ) {\n // This should be replaced with throwing a WWW-Authenticate header, but that doesn't seem to be supported by\n // many of the MCP client as of yet. So this seems to be the oldest version of the spec thats implemented.\n rootRouter.use(\n '/.well-known/oauth-authorization-server',\n async (_, res) => {\n const authBaseUrl = await discovery.getBaseUrl('auth');\n const oidcResponse = await fetch(\n `${authBaseUrl}/.well-known/openid-configuration`,\n );\n\n res.json(await oidcResponse.json());\n },\n );\n }\n },\n });\n },\n});\n"],"names":["createBackendPlugin","coreServices","actionsServiceRef","actionsRegistryServiceRef","McpService","createSseRouter","createStreamableRouter","Router","json"],"mappings":";;;;;;;;;;;;;;AAkCO,MAAM,YAAYA,oCAAA,CAAoB;AAAA,EAC3C,QAAA,EAAU,aAAA;AAAA,EACV,SAAS,GAAA,EAAK;AACZ,IAAA,GAAA,CAAI,YAAA,CAAa;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UAAA,CAAW,MAAM,CAAA;AACrD,cAAA,MAAM,eAAe,MAAM,KAAA;AAAA,gBACzB,GAAG,WAAW,CAAA,iCAAA;AAAA,eAChB;AAEA,cAAA,GAAA,CAAI,IAAA,CAAK,MAAM,YAAA,CAAa,IAAA,EAAM,CAAA;AAAA,YACpC;AAAA,WACF;AAAA,QACF;AAAA,MACF;AAAA,KACD,CAAA;AAAA,EACH;AACF,CAAC;;;;"}
1
+ {"version":3,"file":"plugin.cjs.js","sources":["../src/plugin.ts"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n coreServices,\n createBackendPlugin,\n} from '@backstage/backend-plugin-api';\nimport { json } from 'express';\nimport Router from 'express-promise-router';\nimport { McpService } from './services/McpService';\nimport { createStreamableRouter } from './routers/createStreamableRouter';\nimport { createSseRouter } from './routers/createSseRouter';\nimport {\n actionsRegistryServiceRef,\n actionsServiceRef,\n} from '@backstage/backend-plugin-api/alpha';\n\n/**\n * mcpPlugin backend plugin\n *\n * @public\n */\nexport const mcpPlugin = createBackendPlugin({\n pluginId: 'mcp-actions',\n register(env) {\n env.registerInit({\n deps: {\n logger: coreServices.logger,\n auth: coreServices.auth,\n httpAuth: coreServices.httpAuth,\n httpRouter: coreServices.httpRouter,\n actions: actionsServiceRef,\n registry: actionsRegistryServiceRef,\n rootRouter: coreServices.rootHttpRouter,\n discovery: coreServices.discovery,\n config: coreServices.rootConfig,\n },\n async init({\n actions,\n logger,\n httpRouter,\n httpAuth,\n rootRouter,\n discovery,\n config,\n }) {\n const mcpService = await McpService.create({\n actions,\n });\n\n const sseRouter = createSseRouter({\n mcpService,\n httpAuth,\n });\n\n const streamableRouter = createStreamableRouter({\n mcpService,\n httpAuth,\n logger,\n });\n\n const router = Router();\n router.use(json());\n\n router.use('/v1/sse', sseRouter);\n router.use('/v1', streamableRouter);\n\n httpRouter.use(router);\n\n const oauthEnabled =\n config.getOptionalBoolean(\n 'auth.experimentalDynamicClientRegistration.enabled',\n ) ||\n config.getOptionalBoolean(\n 'auth.experimentalClientIdMetadataDocuments.enabled',\n );\n\n if (oauthEnabled) {\n // OAuth Authorization Server Metadata (RFC 8414)\n // This should be replaced with throwing a WWW-Authenticate header, but that doesn't seem to be supported by\n // many of the MCP clients as of yet. So this seems to be the oldest version of the spec that's implemented.\n rootRouter.use(\n '/.well-known/oauth-authorization-server',\n async (_, res) => {\n const authBaseUrl = await discovery.getBaseUrl('auth');\n const oidcResponse = await fetch(\n `${authBaseUrl}/.well-known/openid-configuration`,\n );\n res.json(await oidcResponse.json());\n },\n );\n\n // Protected Resource Metadata (RFC 9728)\n // https://datatracker.ietf.org/doc/html/rfc9728\n // This allows MCP clients to discover the authorization server for this resource\n rootRouter.use(\n '/.well-known/oauth-protected-resource',\n async (_, res) => {\n const [authBaseUrl, mcpBaseUrl] = await Promise.all([\n discovery.getBaseUrl('auth'),\n discovery.getBaseUrl('mcp-actions'),\n ]);\n res.json({\n resource: mcpBaseUrl,\n authorization_servers: [authBaseUrl],\n });\n },\n );\n }\n },\n });\n },\n});\n"],"names":["createBackendPlugin","coreServices","actionsServiceRef","actionsRegistryServiceRef","McpService","createSseRouter","createStreamableRouter","Router","json"],"mappings":";;;;;;;;;;;;;;AAkCO,MAAM,YAAYA,oCAAA,CAAoB;AAAA,EAC3C,QAAA,EAAU,aAAA;AAAA,EACV,SAAS,GAAA,EAAK;AACZ,IAAA,GAAA,CAAI,YAAA,CAAa;AAAA,MACf,IAAA,EAAM;AAAA,QACJ,QAAQC,6BAAA,CAAa,MAAA;AAAA,QACrB,MAAMA,6BAAA,CAA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M,CAAA;AACrD,cAAA,MAAM,eAAe,MAAM,KAAA;AAAA,gBACzB,GAAG,WAAW,CAAA,iCAAA;AAAA,eAChB;AACA,cAAA,GAAA,CAAI,IAAA,CAAK,MAAM,YAAA,CAAa,IAAA,EAAM,CAAA;AAAA,YACpC;AAAA,WACF;AAKA,UAAA,UAAA,CAAW,GAAA;AAAA,YACT,uCAAA;AAAA,YACA,OAAO,GAAG,GAAA,KAAQ;AAChB,cAAA,MAAM,CAAC,WAAA,EAAa,UAAU,CAAA,GAAI,MAAM,QAAQ,GAAA,CAAI;AAAA,gBAClD,SAAA,CAAU,WAAW,MAAM,CAAA;AAAA,gBAC3B,SAAA,CAAU,WAAW,aAAa;AAAA,eACnC,CAAA;AACD,cAAA,GAAA,CAAI,IAAA,CAAK;AAAA,gBACP,QAAA,EAAU,UAAA;AAAA,gBACV,qBAAA,EAAuB,CAAC,WAAW;AAAA,eACpC,CAAA;AAAA,YACH;AAAA,WACF;AAAA,QACF;AAAA,MACF;AAAA,KACD,CAAA;AAAA,EACH;AACF,CAAC;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-mcp-actions-backend",
3
- "version": "0.1.9-next.0",
3
+ "version": "0.1.9",
4
4
  "backstage": {
5
5
  "role": "backend-plugin",
6
6
  "pluginId": "mcp-actions",
@@ -37,12 +37,11 @@
37
37
  "test": "backstage-cli package test"
38
38
  },
39
39
  "dependencies": {
40
- "@backstage/backend-defaults": "0.15.2-next.1",
41
- "@backstage/backend-plugin-api": "1.7.0-next.1",
42
- "@backstage/catalog-client": "1.12.1",
43
- "@backstage/errors": "1.2.7",
44
- "@backstage/plugin-catalog-node": "1.21.0-next.0",
45
- "@backstage/types": "1.2.2",
40
+ "@backstage/backend-plugin-api": "^1.7.0",
41
+ "@backstage/catalog-client": "^1.13.0",
42
+ "@backstage/errors": "^1.2.7",
43
+ "@backstage/plugin-catalog-node": "^2.0.0",
44
+ "@backstage/types": "^1.2.2",
46
45
  "@cfworker/json-schema": "^4.1.1",
47
46
  "@modelcontextprotocol/sdk": "^1.25.2",
48
47
  "express": "^4.22.0",
@@ -50,9 +49,12 @@
50
49
  "zod": "^3.25.76"
51
50
  },
52
51
  "devDependencies": {
53
- "@backstage/backend-test-utils": "1.10.5-next.0",
54
- "@backstage/cli": "0.35.4-next.1",
55
- "@types/express": "^4.17.6"
52
+ "@backstage/backend-defaults": "^0.15.2",
53
+ "@backstage/backend-test-utils": "^1.11.0",
54
+ "@backstage/cli": "^0.35.4",
55
+ "@types/express": "^4.17.6",
56
+ "@types/supertest": "^2.0.8",
57
+ "supertest": "^7.0.0"
56
58
  },
57
59
  "typesVersions": {
58
60
  "*": {