@backstage/plugin-mcp-actions-backend 0.1.14 → 0.2.0-next.1
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 +15 -0
- package/README.md +2 -5
- package/config.schema.json +117 -0
- package/dist/plugin.cjs.js +0 -8
- package/dist/plugin.cjs.js.map +1 -1
- package/package.json +12 -12
- package/config.d.ts +0 -90
- package/dist/routers/createSseRouter.cjs.js +0 -57
- package/dist/routers/createSseRouter.cjs.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @backstage/plugin-mcp-actions-backend
|
|
2
2
|
|
|
3
|
+
## 0.2.0-next.1
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 567bc4c: **BREAKING**: Removed the deprecated Server-Sent Events (SSE) MCP transport. MCP clients must use the Streamable HTTP endpoint at `/api/mcp-actions/v1` or a configured named-server endpoint.
|
|
8
|
+
|
|
9
|
+
## 0.1.15-next.0
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
- @backstage/backend-plugin-api@1.9.3-next.0
|
|
15
|
+
- @backstage/plugin-catalog-node@2.2.3-next.0
|
|
16
|
+
- @backstage/catalog-client@1.16.1-next.0
|
|
17
|
+
|
|
3
18
|
## 0.1.14
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -217,14 +217,11 @@ auth:
|
|
|
217
217
|
|
|
218
218
|
## Configuring MCP Clients
|
|
219
219
|
|
|
220
|
-
The MCP server
|
|
221
|
-
|
|
222
|
-
The SSE protocol is deprecated, and should be avoided as it will be removed in a future release.
|
|
220
|
+
The MCP server uses the Streamable HTTP protocol.
|
|
223
221
|
|
|
224
222
|
### Single Server (default)
|
|
225
223
|
|
|
226
|
-
|
|
227
|
-
- `SSE`: `http://localhost:7007/api/mcp-actions/v1/sse`
|
|
224
|
+
Use `http://localhost:7007/api/mcp-actions/v1` for the default single server.
|
|
228
225
|
|
|
229
226
|
```json
|
|
230
227
|
{
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"mcpActions": {
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"name": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "Display name for the MCP server. Defaults to \"backstage\". Used when running a single bundled server without mcpActions.servers."
|
|
11
|
+
},
|
|
12
|
+
"description": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"description": "Description of the MCP server. Used when running a single bundled server without mcpActions.servers."
|
|
15
|
+
},
|
|
16
|
+
"namespacedToolNames": {
|
|
17
|
+
"type": "boolean",
|
|
18
|
+
"description": "When true, MCP tool names include the plugin ID prefix to avoid collisions across plugins. For example an action registered as \"get-entity\" by the catalog plugin becomes \"catalog.get-entity\". Defaults to true."
|
|
19
|
+
},
|
|
20
|
+
"tracing": {
|
|
21
|
+
"type": "object",
|
|
22
|
+
"properties": {
|
|
23
|
+
"capture": {
|
|
24
|
+
"type": "object",
|
|
25
|
+
"properties": {
|
|
26
|
+
"toolPayload": {
|
|
27
|
+
"type": "boolean",
|
|
28
|
+
"description": "When true, the MCP tool call's input arguments and output result are included on the MCP `tools/call` server span as `gen_ai.tool.call.arguments` and `gen_ai.tool.call.result`. These attributes are marked Opt-In by the OpenTelemetry GenAI semantic conventions because they may contain sensitive information (entity payloads, scaffolder inputs, free-form text). Defaults to false."
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"servers": {
|
|
35
|
+
"type": "object",
|
|
36
|
+
"additionalProperties": {
|
|
37
|
+
"type": "object",
|
|
38
|
+
"properties": {
|
|
39
|
+
"name": {
|
|
40
|
+
"type": "string",
|
|
41
|
+
"description": "Display name for the MCP server."
|
|
42
|
+
},
|
|
43
|
+
"description": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"description": "Description of the MCP server."
|
|
46
|
+
},
|
|
47
|
+
"filter": {
|
|
48
|
+
"type": "object",
|
|
49
|
+
"properties": {
|
|
50
|
+
"include": {
|
|
51
|
+
"type": "array",
|
|
52
|
+
"items": {
|
|
53
|
+
"type": "object",
|
|
54
|
+
"properties": {
|
|
55
|
+
"id": {
|
|
56
|
+
"type": "string",
|
|
57
|
+
"description": "Glob pattern matched against action ID."
|
|
58
|
+
},
|
|
59
|
+
"attributes": {
|
|
60
|
+
"type": "object",
|
|
61
|
+
"properties": {
|
|
62
|
+
"destructive": {
|
|
63
|
+
"type": "boolean"
|
|
64
|
+
},
|
|
65
|
+
"readOnly": {
|
|
66
|
+
"type": "boolean"
|
|
67
|
+
},
|
|
68
|
+
"idempotent": {
|
|
69
|
+
"type": "boolean"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"description": "Match actions by their attribute flags."
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"exclude": {
|
|
78
|
+
"type": "array",
|
|
79
|
+
"items": {
|
|
80
|
+
"type": "object",
|
|
81
|
+
"properties": {
|
|
82
|
+
"id": {
|
|
83
|
+
"type": "string",
|
|
84
|
+
"description": "Glob pattern matched against action ID."
|
|
85
|
+
},
|
|
86
|
+
"attributes": {
|
|
87
|
+
"type": "object",
|
|
88
|
+
"properties": {
|
|
89
|
+
"destructive": {
|
|
90
|
+
"type": "boolean"
|
|
91
|
+
},
|
|
92
|
+
"readOnly": {
|
|
93
|
+
"type": "boolean"
|
|
94
|
+
},
|
|
95
|
+
"idempotent": {
|
|
96
|
+
"type": "boolean"
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
"description": "Match actions by their attribute flags."
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"description": "Filter rules to include or exclude specific actions."
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
"required": [
|
|
109
|
+
"name"
|
|
110
|
+
]
|
|
111
|
+
},
|
|
112
|
+
"description": "Named MCP servers, each exposed at /api/mcp-actions/v1/{key}. When not configured, the plugin serves a single server at /api/mcp-actions/v1."
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -5,7 +5,6 @@ var express = require('express');
|
|
|
5
5
|
var PromiseRouter = require('express-promise-router');
|
|
6
6
|
var McpService = require('./services/McpService.cjs.js');
|
|
7
7
|
var createStreamableRouter = require('./routers/createStreamableRouter.cjs.js');
|
|
8
|
-
var createSseRouter = require('./routers/createSseRouter.cjs.js');
|
|
9
8
|
var alpha = require('@backstage/backend-plugin-api/alpha');
|
|
10
9
|
var config = require('./config.cjs.js');
|
|
11
10
|
|
|
@@ -75,12 +74,6 @@ const mcpPlugin = backendPluginApi.createBackendPlugin({
|
|
|
75
74
|
includeRules: [],
|
|
76
75
|
excludeRules: []
|
|
77
76
|
};
|
|
78
|
-
const sseRouter = createSseRouter.createSseRouter({
|
|
79
|
-
mcpService,
|
|
80
|
-
httpAuth,
|
|
81
|
-
tracing,
|
|
82
|
-
serverConfig
|
|
83
|
-
});
|
|
84
77
|
const streamableRouter = createStreamableRouter.createStreamableRouter({
|
|
85
78
|
mcpService,
|
|
86
79
|
httpAuth,
|
|
@@ -89,7 +82,6 @@ const mcpPlugin = backendPluginApi.createBackendPlugin({
|
|
|
89
82
|
tracing,
|
|
90
83
|
serverConfig
|
|
91
84
|
});
|
|
92
|
-
router.use("/v1/sse", sseRouter);
|
|
93
85
|
router.use("/v1", streamableRouter);
|
|
94
86
|
}
|
|
95
87
|
httpRouter.use(router);
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -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 {
|
|
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 {\n actionsRegistryServiceRef,\n actionsServiceRef,\n metricsServiceRef,\n tracingServiceRef,\n} from '@backstage/backend-plugin-api/alpha';\nimport { parseServerConfigs } from './config';\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 metrics: metricsServiceRef,\n tracing: tracingServiceRef,\n },\n async init({\n actions,\n logger,\n httpRouter,\n httpAuth,\n rootRouter,\n discovery,\n config,\n metrics,\n tracing,\n }) {\n const serverConfigs = parseServerConfigs(config);\n const namespacedToolNames = config.getOptionalBoolean(\n 'mcpActions.namespacedToolNames',\n );\n const captureToolPayloads =\n config.getOptionalBoolean('mcpActions.tracing.capture.toolPayload') ??\n false;\n\n const mcpService = await McpService.create({\n actions,\n metrics,\n logger,\n namespacedToolNames,\n tracingService: tracing,\n captureToolPayloads,\n });\n\n const router = Router();\n router.use(json());\n\n if (serverConfigs && serverConfigs.size > 0) {\n for (const [key, serverConfig] of serverConfigs) {\n const streamableRouter = createStreamableRouter({\n mcpService,\n httpAuth,\n logger,\n metrics,\n tracing,\n serverConfig,\n });\n\n router.use(`/v1/${key}`, streamableRouter);\n }\n } else {\n const serverConfig = {\n name: config.getOptionalString('mcpActions.name') ?? 'backstage',\n description: config.getOptionalString('mcpActions.description'),\n includeRules: [],\n excludeRules: [],\n };\n\n const streamableRouter = createStreamableRouter({\n mcpService,\n httpAuth,\n logger,\n metrics,\n tracing,\n serverConfig,\n });\n\n router.use('/v1', streamableRouter);\n }\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 const serverSuffixes = serverConfigs?.size\n ? [...serverConfigs.keys()].map(key => `/v1/${key}`)\n : ['/v1'];\n\n for (const suffix of serverSuffixes) {\n const mcpBasePath = `/api/mcp-actions${suffix}`;\n\n rootRouter.use(\n `/.well-known/oauth-protected-resource${mcpBasePath}`,\n async (_req, res) => {\n const [authBaseUrl, mcpBaseUrl] = await Promise.all([\n discovery.getExternalBaseUrl('auth'),\n discovery.getExternalBaseUrl('mcp-actions'),\n ]);\n\n res.json({\n resource: `${mcpBaseUrl}${suffix}`,\n authorization_servers: [authBaseUrl],\n });\n },\n );\n }\n }\n },\n });\n },\n});\n"],"names":["createBackendPlugin","coreServices","actionsServiceRef","actionsRegistryServiceRef","metricsServiceRef","tracingServiceRef","config","parseServerConfigs","McpService","Router","json","createStreamableRouter"],"mappings":";;;;;;;;;;;;;;AAoCO,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,CAAa,IAAA;AAAA,QACnB,UAAUA,6BAAA,CAAa,QAAA;AAAA,QACvB,YAAYA,6BAAA,CAAa,UAAA;AAAA,QACzB,OAAA,EAASC,uBAAA;AAAA,QACT,QAAA,EAAUC,+BAAA;AAAA,QACV,YAAYF,6BAAA,CAAa,cAAA;AAAA,QACzB,WAAWA,6BAAA,CAAa,SAAA;AAAA,QACxB,QAAQA,6BAAA,CAAa,UAAA;AAAA,QACrB,OAAA,EAASG,uBAAA;AAAA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MAAM,GAAA,KAAQ;AACnB,gBAAA,MAAM,CAAC,WAAA,EAAa,UAAU,CAAA,GAAI,MAAM,QAAQ,GAAA,CAAI;AAAA,kBAClD,SAAA,CAAU,mBAAmB,MAAM,CAAA;AAAA,kBACnC,SAAA,CAAU,mBAAmB,aAAa;AAAA,iBAC3C,CAAA;AAED,gBAAA,GAAA,CAAI,IAAA,CAAK;AAAA,kBACP,QAAA,EAAU,CAAA,EAAG,UAAU,CAAA,EAAG,MAAM,CAAA,CAAA;AAAA,kBAChC,qBAAA,EAAuB,CAAC,WAAW;AAAA,iBACpC,CAAA;AAAA,cACH;AAAA,aACF;AAAA,UACF;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
|
|
3
|
+
"version": "0.2.0-next.1",
|
|
4
4
|
"backstage": {
|
|
5
5
|
"role": "backend-plugin",
|
|
6
6
|
"pluginId": "mcp-actions",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"types": "dist/index.d.ts",
|
|
27
27
|
"files": [
|
|
28
28
|
"dist",
|
|
29
|
-
"config.
|
|
29
|
+
"config.schema.json"
|
|
30
30
|
],
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "backstage-cli package build",
|
|
@@ -38,12 +38,12 @@
|
|
|
38
38
|
"test": "backstage-cli package test"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@backstage/backend-plugin-api": "
|
|
42
|
-
"@backstage/catalog-client": "
|
|
43
|
-
"@backstage/config": "
|
|
44
|
-
"@backstage/errors": "
|
|
45
|
-
"@backstage/plugin-catalog-node": "
|
|
46
|
-
"@backstage/types": "
|
|
41
|
+
"@backstage/backend-plugin-api": "1.9.3-next.0",
|
|
42
|
+
"@backstage/catalog-client": "1.16.1-next.0",
|
|
43
|
+
"@backstage/config": "1.3.8",
|
|
44
|
+
"@backstage/errors": "1.3.1",
|
|
45
|
+
"@backstage/plugin-catalog-node": "2.2.3-next.0",
|
|
46
|
+
"@backstage/types": "1.2.2",
|
|
47
47
|
"@cfworker/json-schema": "^4.1.1",
|
|
48
48
|
"@modelcontextprotocol/sdk": "^1.25.2",
|
|
49
49
|
"express": "^4.22.0",
|
|
@@ -52,14 +52,14 @@
|
|
|
52
52
|
"zod": "^3.25.76 || ^4.0.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@backstage/backend-defaults": "
|
|
56
|
-
"@backstage/backend-test-utils": "
|
|
57
|
-
"@backstage/cli": "
|
|
55
|
+
"@backstage/backend-defaults": "0.17.5-next.1",
|
|
56
|
+
"@backstage/backend-test-utils": "1.11.5-next.0",
|
|
57
|
+
"@backstage/cli": "0.36.4-next.1",
|
|
58
58
|
"@types/express": "^4.17.6",
|
|
59
59
|
"@types/supertest": "^2.0.8",
|
|
60
60
|
"supertest": "^7.0.0"
|
|
61
61
|
},
|
|
62
|
-
"configSchema": "config.
|
|
62
|
+
"configSchema": "config.schema.json",
|
|
63
63
|
"typesVersions": {
|
|
64
64
|
"*": {
|
|
65
65
|
"package.json": [
|
package/config.d.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2026 The Backstage Authors
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
export interface Config {
|
|
18
|
-
mcpActions?: {
|
|
19
|
-
/**
|
|
20
|
-
* Display name for the MCP server. Defaults to "backstage".
|
|
21
|
-
* Used when running a single bundled server without mcpActions.servers.
|
|
22
|
-
*/
|
|
23
|
-
name?: string;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Description of the MCP server.
|
|
27
|
-
* Used when running a single bundled server without mcpActions.servers.
|
|
28
|
-
*/
|
|
29
|
-
description?: string;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* When true, MCP tool names include the plugin ID prefix to avoid
|
|
33
|
-
* collisions across plugins. For example an action registered as
|
|
34
|
-
* "get-entity" by the catalog plugin becomes "catalog.get-entity".
|
|
35
|
-
* Defaults to true.
|
|
36
|
-
*/
|
|
37
|
-
namespacedToolNames?: boolean;
|
|
38
|
-
|
|
39
|
-
tracing?: {
|
|
40
|
-
capture?: {
|
|
41
|
-
/**
|
|
42
|
-
* When true, the MCP tool call's input arguments and output result
|
|
43
|
-
* are included on the MCP `tools/call` server span as
|
|
44
|
-
* `gen_ai.tool.call.arguments` and `gen_ai.tool.call.result`.
|
|
45
|
-
* These attributes are marked Opt-In by the OpenTelemetry GenAI
|
|
46
|
-
* semantic conventions because they may contain sensitive
|
|
47
|
-
* information (entity payloads, scaffolder inputs, free-form
|
|
48
|
-
* text). Defaults to false.
|
|
49
|
-
*/
|
|
50
|
-
toolPayload?: boolean;
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Named MCP servers, each exposed at /api/mcp-actions/v1/{key}.
|
|
56
|
-
* When not configured, the plugin serves a single server at /api/mcp-actions/v1.
|
|
57
|
-
*/
|
|
58
|
-
servers?: {
|
|
59
|
-
[serverKey: string]: {
|
|
60
|
-
/** Display name for the MCP server. */
|
|
61
|
-
name: string;
|
|
62
|
-
/** Description of the MCP server. */
|
|
63
|
-
description?: string;
|
|
64
|
-
/** Filter rules to include or exclude specific actions. */
|
|
65
|
-
filter?: {
|
|
66
|
-
include?: Array<{
|
|
67
|
-
/** Glob pattern matched against action ID. */
|
|
68
|
-
id?: string;
|
|
69
|
-
/** Match actions by their attribute flags. */
|
|
70
|
-
attributes?: {
|
|
71
|
-
destructive?: boolean;
|
|
72
|
-
readOnly?: boolean;
|
|
73
|
-
idempotent?: boolean;
|
|
74
|
-
};
|
|
75
|
-
}>;
|
|
76
|
-
exclude?: Array<{
|
|
77
|
-
/** Glob pattern matched against action ID. */
|
|
78
|
-
id?: string;
|
|
79
|
-
/** Match actions by their attribute flags. */
|
|
80
|
-
attributes?: {
|
|
81
|
-
destructive?: boolean;
|
|
82
|
-
readOnly?: boolean;
|
|
83
|
-
idempotent?: boolean;
|
|
84
|
-
};
|
|
85
|
-
}>;
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
};
|
|
90
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var PromiseRouter = require('express-promise-router');
|
|
4
|
-
var sse_js = require('@modelcontextprotocol/sdk/server/sse.js');
|
|
5
|
-
|
|
6
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
7
|
-
|
|
8
|
-
var PromiseRouter__default = /*#__PURE__*/_interopDefaultCompat(PromiseRouter);
|
|
9
|
-
|
|
10
|
-
const createSseRouter = ({
|
|
11
|
-
mcpService,
|
|
12
|
-
httpAuth,
|
|
13
|
-
tracing,
|
|
14
|
-
serverConfig
|
|
15
|
-
}) => {
|
|
16
|
-
const router = PromiseRouter__default.default();
|
|
17
|
-
const transportsToSessionId = /* @__PURE__ */ new Map();
|
|
18
|
-
router.get("/", async (req, res) => {
|
|
19
|
-
const server = mcpService.getServer({
|
|
20
|
-
credentials: await httpAuth.credentials(req),
|
|
21
|
-
serverConfig
|
|
22
|
-
});
|
|
23
|
-
const transport = new sse_js.SSEServerTransport(
|
|
24
|
-
`${req.originalUrl}/messages`,
|
|
25
|
-
res
|
|
26
|
-
);
|
|
27
|
-
transportsToSessionId.set(transport.sessionId, transport);
|
|
28
|
-
res.on("close", () => {
|
|
29
|
-
transportsToSessionId.delete(transport.sessionId);
|
|
30
|
-
});
|
|
31
|
-
await server.connect(transport);
|
|
32
|
-
});
|
|
33
|
-
router.post("/messages", async (req, res) => {
|
|
34
|
-
const sessionId = req.query.sessionId;
|
|
35
|
-
if (!sessionId) {
|
|
36
|
-
res.status(400).contentType("text/plain").write("sessionId is required");
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const transport = transportsToSessionId.get(sessionId);
|
|
40
|
-
if (transport) {
|
|
41
|
-
const ctx = tracing.propagation.extract(
|
|
42
|
-
tracing.context.active(),
|
|
43
|
-
req.headers
|
|
44
|
-
);
|
|
45
|
-
await tracing.context.with(
|
|
46
|
-
ctx,
|
|
47
|
-
() => transport.handlePostMessage(req, res, req.body)
|
|
48
|
-
);
|
|
49
|
-
} else {
|
|
50
|
-
res.status(400).contentType("text/plain").write(`No transport found for sessionId "${sessionId}"`);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
return router;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
exports.createSseRouter = createSseRouter;
|
|
57
|
-
//# sourceMappingURL=createSseRouter.cjs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createSseRouter.cjs.js","sources":["../../src/routers/createSseRouter.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 PromiseRouter from 'express-promise-router';\nimport { Router } from 'express';\nimport { McpService } from '../services/McpService';\nimport { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';\nimport { HttpAuthService } from '@backstage/backend-plugin-api';\nimport { TracingService } from '@backstage/backend-plugin-api/alpha';\nimport { McpServerConfig } from '../config';\n\n/**\n * Legacy SSE endpoint for older clients, hopefully will not be needed for much longer.\n */\nexport const createSseRouter = ({\n mcpService,\n httpAuth,\n tracing,\n serverConfig,\n}: {\n mcpService: McpService;\n httpAuth: HttpAuthService;\n tracing: TracingService;\n serverConfig?: McpServerConfig;\n}): Router => {\n const router = PromiseRouter();\n const transportsToSessionId = new Map<string, SSEServerTransport>();\n\n router.get('/', async (req, res) => {\n const server = mcpService.getServer({\n credentials: await httpAuth.credentials(req),\n serverConfig,\n });\n\n const transport = new SSEServerTransport(\n `${req.originalUrl}/messages`,\n res,\n );\n\n transportsToSessionId.set(transport.sessionId, transport);\n\n res.on('close', () => {\n transportsToSessionId.delete(transport.sessionId);\n });\n\n await server.connect(transport);\n });\n\n router.post('/messages', async (req, res) => {\n const sessionId = req.query.sessionId as string;\n\n if (!sessionId) {\n res.status(400).contentType('text/plain').write('sessionId is required');\n return;\n }\n\n const transport = transportsToSessionId.get(sessionId);\n if (transport) {\n const ctx = tracing.propagation.extract(\n tracing.context.active(),\n req.headers,\n );\n await tracing.context.with(ctx, () =>\n transport.handlePostMessage(req, res, req.body),\n );\n } else {\n res\n .status(400)\n .contentType('text/plain')\n .write(`No transport found for sessionId \"${sessionId}\"`);\n }\n });\n return router;\n};\n"],"names":["PromiseRouter","SSEServerTransport"],"mappings":";;;;;;;;;AA0BO,MAAM,kBAAkB,CAAC;AAAA,EAC9B,UAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA;AACF,CAAA,KAKc;AACZ,EAAA,MAAM,SAASA,8BAAA,EAAc;AAC7B,EAAA,MAAM,qBAAA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