@objectstack/connector-mcp 16.1.0 → 17.0.0-rc.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 CHANGED
@@ -1,5 +1,341 @@
1
1
  # @objectstack/connector-mcp
2
2
 
3
+ ## 17.0.0-rc.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 2e836de: chore(packaging): CHANGELOG.md ships in every npm tarball (#4261)
8
+
9
+ The AGENTS.md post-task checklist requires breaking changesets to carry their
10
+ FROM → TO migration because "this text ships to consumers as `CHANGELOG.md`
11
+ inside the npm package and is what an upgrading agent greps after the tombstone
12
+ error." That delivery path was severed for 68 of the 69 publishable packages:
13
+ npm packs `package.json` / `README*` / `LICENSE*` unconditionally but — unlike
14
+ older npm versions — not `CHANGELOG.md`, and the canonical
15
+ `"files": ["dist", "README.md"]` whitelist never named it. Measured on npm
16
+ 10.9.7: `npm pack --dry-run` on `@objectstack/types` shipped 3 files while its
17
+ 70KB `CHANGELOG.md` stayed behind. Only `@objectstack/spec` listed it
18
+ explicitly.
19
+
20
+ The tombstone-error scenario is precisely the one where the repo is out of
21
+ reach — the upgrading agent has `node_modules` and nothing else — so the
22
+ migration text has to ride in the tarball. Every publishable package now
23
+ declares `CHANGELOG.md` in `files`, and the canonical whitelist is
24
+ `["dist", "README.md", "CHANGELOG.md"]`.
25
+
26
+ The other half is the gate: `check:published-files` gains a fifth invariant,
27
+ COMPLETE — a whitelist that fails to cover `CHANGELOG.md` fails the
28
+ always-required lint job, so the next package cannot silently sever the path
29
+ again. `@objectstack/spec`'s per-package EXTRA_ENTRIES exemption dissolves
30
+ into the canonical set.
31
+
32
+ Consumer-visible change: one more file per install (the package's changelog,
33
+ e.g. 70.8KB for `@objectstack/types`), and `grep -r "removed key"
34
+ node_modules/@objectstack/*/CHANGELOG.md` now finds the migration it was
35
+ promised.
36
+
37
+ - cc2de0e: chore(packaging): 20 packages stop publishing their sources, tests and build tooling (#4248)
38
+
39
+ These 20 packages declared no `files` field, so npm fell back to packing the
40
+ whole package directory. `npm pack --dry-run` on `@objectstack/plugin-webhooks`
41
+ listed **21 files** — 15 under `src/`, three of them unit tests
42
+ (`auto-enqueuer.test.ts`, `bootstrap-declared-webhooks.test.ts`, …), plus the
43
+ build-time `scripts/i18n-extract.config.ts`. `dist/` lands on top of that at
44
+ publish time rather than instead of it, so consumers were installing the
45
+ TypeScript sources and the test suite alongside the artifact they asked for.
46
+
47
+ Each now declares `"files": ["dist", "README.md"]`, matching the 29 packages
48
+ that already did. Nothing a consumer imports moves: every `main` / `types` /
49
+ `exports` target in all 20 already resolved inside `dist/`, which the new
50
+ `check:published-files` guard verifies rather than assumes. The visible change
51
+ is a smaller install and a smaller dependency-scanning surface — `npm pack` on
52
+ `@objectstack/plugin-webhooks` now yields 2 files plus `dist/`.
53
+
54
+ The other half of the fix is the gate. Half the packages declaring `files` and
55
+ half not was the #3786 shape — a hand-copied convention with nothing enforcing
56
+ it, where whoever forgets the line gets no signal at all. `check:published-files`
57
+ (new, wired into the always-required `lint` job) holds every non-private
58
+ workspace package to four invariants: `files` is **declared**; it is
59
+ **sufficient** (covers every entry point, so tightening a whitelist cannot ship
60
+ a package that fails to resolve); it is **minimal** (admits no test, test-harness
61
+ config or build script); and anything beyond `dist` + `README.md` is
62
+ **registered** with a reason, reconciled in both directions so a stale exemption
63
+ is an error rather than dead text. `@objectstack/spec` is the one package with
64
+ registered extras — its `.zod.ts` sources, JSON Schemas, liveness ledgers and
65
+ `CHANGELOG.md` are product, not build input.
66
+
67
+ This also closes an assumption #4206 was resting on. Excluding `<pkg>/scripts/**`
68
+ from the docs-drift implementation test is sound only while no package publishes
69
+ `scripts/` as runtime code; that held, but it held because someone read all three
70
+ offenders by hand. It is now checked on every PR.
71
+
72
+ - Updated dependencies [6a67d7a]
73
+ - Updated dependencies [0ecc656]
74
+ - Updated dependencies [06772eb]
75
+ - Updated dependencies [270650f]
76
+ - Updated dependencies [3aef718]
77
+ - Updated dependencies [1ea6bce]
78
+ - Updated dependencies [c1dcacd]
79
+ - Updated dependencies [ad303ed]
80
+ - Updated dependencies [32ccb23]
81
+ - Updated dependencies [f5a4ef0]
82
+ - Updated dependencies [2d3e255]
83
+ - Updated dependencies [7d7521f]
84
+ - Updated dependencies [5dc4d02]
85
+ - Updated dependencies [05154a1]
86
+ - Updated dependencies [9b6fe7c]
87
+ - Updated dependencies [8c711fb]
88
+ - Updated dependencies [09e4547]
89
+ - Updated dependencies [91f4c78]
90
+ - Updated dependencies [820eff9]
91
+ - Updated dependencies [8d895ff]
92
+ - Updated dependencies [f6472d7]
93
+ - Updated dependencies [78caf51]
94
+ - Updated dependencies [62a789b]
95
+ - Updated dependencies [789ad63]
96
+ - Updated dependencies [2af1988]
97
+ - Updated dependencies [0af50a3]
98
+ - Updated dependencies [2e836de]
99
+ - Updated dependencies [12a19a8]
100
+ - Updated dependencies [41dcda3]
101
+ - Updated dependencies [c8124e5]
102
+ - Updated dependencies [a1a4140]
103
+ - Updated dependencies [217e2e6]
104
+ - Updated dependencies [86a71d1]
105
+ - Updated dependencies [d5c75e2]
106
+ - Updated dependencies [03d26f7]
107
+ - Updated dependencies [4384921]
108
+ - Updated dependencies [3c628ce]
109
+ - Updated dependencies [7cb922e]
110
+ - Updated dependencies [1d22114]
111
+ - Updated dependencies [b5f9397]
112
+ - Updated dependencies [ed77493]
113
+ - Updated dependencies [58a03d2]
114
+ - Updated dependencies [dc530b4]
115
+ - Updated dependencies [e59786e]
116
+ - Updated dependencies [bcf1112]
117
+ - Updated dependencies [9774b78]
118
+ - Updated dependencies [b07d829]
119
+ - Updated dependencies [a648e96]
120
+ - Updated dependencies [a47ac06]
121
+ - Updated dependencies [e4c61a7]
122
+ - Updated dependencies [cc60165]
123
+ - Updated dependencies [081aa6f]
124
+ - Updated dependencies [91f4c78]
125
+ - Updated dependencies [e8d0c21]
126
+ - Updated dependencies [45dc446]
127
+ - Updated dependencies [c1d44f7]
128
+ - Updated dependencies [ab9fb5c]
129
+ - Updated dependencies [f985b3f]
130
+ - Updated dependencies [9a4932a]
131
+ - Updated dependencies [f9fc874]
132
+ - Updated dependencies [011b386]
133
+ - Updated dependencies [7777e8f]
134
+ - Updated dependencies [507b92a]
135
+ - Updated dependencies [7309c81]
136
+ - Updated dependencies [20bc1ec]
137
+ - Updated dependencies [90c2b15]
138
+ - Updated dependencies [42eeb7d]
139
+ - Updated dependencies [01e124d]
140
+ - Updated dependencies [7ce02eb]
141
+ - Updated dependencies [a13827e]
142
+ - Updated dependencies [7733604]
143
+ - Updated dependencies [40e420f]
144
+ - Updated dependencies [d13004a]
145
+ - Updated dependencies [be7360c]
146
+ - Updated dependencies [5b47ab5]
147
+ - Updated dependencies [b09d8d9]
148
+ - Updated dependencies [b09d8d9]
149
+ - Updated dependencies [8675db6]
150
+ - Updated dependencies [b09d8d9]
151
+ - Updated dependencies [3eb1b2b]
152
+ - Updated dependencies [59b85c0]
153
+ - Updated dependencies [6e357ed]
154
+ - Updated dependencies [d6938bf]
155
+ - Updated dependencies [31e0be9]
156
+ - Updated dependencies [4bfd455]
157
+ - Updated dependencies [ffd2ce2]
158
+ - Updated dependencies [62f8017]
159
+ - Updated dependencies [a831df1]
160
+ - Updated dependencies [f752ee3]
161
+ - Updated dependencies [a1b61e0]
162
+ - Updated dependencies [cd6b9f2]
163
+ - Updated dependencies [2cb6d3c]
164
+ - Updated dependencies [af2a095]
165
+ - Updated dependencies [ec796d5]
166
+ - Updated dependencies [e87fea1]
167
+ - Updated dependencies [c65e529]
168
+ - Updated dependencies [3ca34c1]
169
+ - Updated dependencies [239c3a3]
170
+ - Updated dependencies [94a0bbc]
171
+ - Updated dependencies [d6bfb3d]
172
+ - Updated dependencies [a2266a6]
173
+ - Updated dependencies [d25a0ec]
174
+ - Updated dependencies [667b83e]
175
+ - Updated dependencies [627b188]
176
+ - Updated dependencies [8d4eae7]
177
+ - Updated dependencies [857a6cf]
178
+ - Updated dependencies [65a3a84]
179
+ - Updated dependencies [ccd9397]
180
+ - Updated dependencies [bca935b]
181
+ - Updated dependencies [d92c72d]
182
+ - Updated dependencies [c54c822]
183
+ - Updated dependencies [8dcc0f5]
184
+ - Updated dependencies [75b9e51]
185
+ - Updated dependencies [0a2f233]
186
+ - Updated dependencies [8621cdd]
187
+ - Updated dependencies [6f23667]
188
+ - Updated dependencies [5d21a48]
189
+ - Updated dependencies [19365b7]
190
+ - Updated dependencies [b7ed26d]
191
+ - Updated dependencies [b3a3d83]
192
+ - Updated dependencies [7a55913]
193
+ - Updated dependencies [35accbf]
194
+ - Updated dependencies [6038de7]
195
+ - Updated dependencies [eb95d97]
196
+ - Updated dependencies [e4c2dc8]
197
+ - Updated dependencies [1bd2795]
198
+ - Updated dependencies [8186a70]
199
+ - Updated dependencies [a329cca]
200
+ - Updated dependencies [6eec18c]
201
+ - Updated dependencies [4d7bebf]
202
+ - Updated dependencies [821ac7a]
203
+ - Updated dependencies [8f81731]
204
+ - Updated dependencies [8b50cb3]
205
+ - Updated dependencies [8c2db68]
206
+ - Updated dependencies [22b5e54]
207
+ - Updated dependencies [0166bd5]
208
+ - Updated dependencies [9b702dc]
209
+ - Updated dependencies [ab16331]
210
+ - @objectstack/spec@17.0.0-rc.1
211
+ - @objectstack/core@17.0.0-rc.1
212
+
213
+ ## 17.0.0-rc.0
214
+
215
+ ### Patch Changes
216
+
217
+ - Updated dependencies [50616d9]
218
+ - Updated dependencies [08b5a3d]
219
+ - Updated dependencies [d99aeb3]
220
+ - Updated dependencies [4727eb8]
221
+ - Updated dependencies [f63cd09]
222
+ - Updated dependencies [fa3d0cf]
223
+ - Updated dependencies [af5a224]
224
+ - Updated dependencies [71f76e1]
225
+ - Updated dependencies [37b1346]
226
+ - Updated dependencies [99736a0]
227
+ - Updated dependencies [fe67e34]
228
+ - Updated dependencies [fdb4f50]
229
+ - Updated dependencies [1bd5652]
230
+ - Updated dependencies [14252d3]
231
+ - Updated dependencies [7fb436c]
232
+ - Updated dependencies [879ea13]
233
+ - Updated dependencies [201b31f]
234
+ - Updated dependencies [e2616e0]
235
+ - Updated dependencies [6fdc5c6]
236
+ - Updated dependencies [8b9d71e]
237
+ - Updated dependencies [33f5e23]
238
+ - Updated dependencies [259af21]
239
+ - Updated dependencies [587fc91]
240
+ - Updated dependencies [1986594]
241
+ - Updated dependencies [ad4af62]
242
+ - Updated dependencies [d44dbfa]
243
+ - Updated dependencies [474fe39]
244
+ - Updated dependencies [0bc685a]
245
+ - Updated dependencies [b949059]
246
+ - Updated dependencies [be1c52c]
247
+ - Updated dependencies [c5ff96d]
248
+ - Updated dependencies [84e7be9]
249
+ - Updated dependencies [a6c3f38]
250
+ - Updated dependencies [debc23a]
251
+ - Updated dependencies [0f8ad09]
252
+ - Updated dependencies [8f9689f]
253
+ - Updated dependencies [57a3bb3]
254
+ - Updated dependencies [5f9a987]
255
+ - Updated dependencies [db02d47]
256
+ - Updated dependencies [0bfdf46]
257
+ - Updated dependencies [376a061]
258
+ - Updated dependencies [7c7e246]
259
+ - Updated dependencies [f35cdc5]
260
+ - Updated dependencies [9ea2bc5]
261
+ - Updated dependencies [c2d9098]
262
+ - Updated dependencies [a227ed7]
263
+ - Updated dependencies [9613396]
264
+ - Updated dependencies [e47b342]
265
+ - Updated dependencies [4ed7ed4]
266
+ - Updated dependencies [2fa4ca1]
267
+ - Updated dependencies [f5a2320]
268
+ - Updated dependencies [deb538f]
269
+ - Updated dependencies [5b89711]
270
+ - Updated dependencies [0c8a22f]
271
+ - Updated dependencies [763931e]
272
+ - Updated dependencies [de9af8a]
273
+ - Updated dependencies [c4df271]
274
+ - Updated dependencies [a41ba5c]
275
+ - Updated dependencies [189854c]
276
+ - Updated dependencies [0e3a226]
277
+ - Updated dependencies [1d4756e]
278
+ - Updated dependencies [720c5ad]
279
+ - Updated dependencies [a8d1e24]
280
+ - Updated dependencies [41642b0]
281
+ - Updated dependencies [4cca74c]
282
+ - Updated dependencies [88ef03e]
283
+ - Updated dependencies [9e2caf3]
284
+ - Updated dependencies [81ce41a]
285
+ - Updated dependencies [85e1e4e]
286
+ - Updated dependencies [dac6a08]
287
+ - Updated dependencies [394b7a1]
288
+ - Updated dependencies [677b591]
289
+ - Updated dependencies [d77d1b7]
290
+ - Updated dependencies [5b79a34]
291
+ - Updated dependencies [c757854]
292
+ - Updated dependencies [0045682]
293
+ - Updated dependencies [2a5f04a]
294
+ - Updated dependencies [4f740b0]
295
+ - Updated dependencies [67452d1]
296
+ - Updated dependencies [0fc6219]
297
+ - Updated dependencies [605e190]
298
+ - Updated dependencies [c6c59f1]
299
+ - Updated dependencies [b0e78a8]
300
+ - Updated dependencies [f31cc8d]
301
+ - Updated dependencies [f343dc4]
302
+ - Updated dependencies [8269e32]
303
+ - Updated dependencies [74f7339]
304
+ - Updated dependencies [a6c35a2]
305
+ - Updated dependencies [c2f1002]
306
+ - Updated dependencies [f163028]
307
+ - Updated dependencies [f07808c]
308
+ - Updated dependencies [7ffc3d3]
309
+ - Updated dependencies [88346ba]
310
+ - Updated dependencies [4631592]
311
+ - Updated dependencies [32ff033]
312
+ - Updated dependencies [5ac93d4]
313
+ - Updated dependencies [93f267f]
314
+ - Updated dependencies [0024abf]
315
+ - Updated dependencies [acbf364]
316
+ - Updated dependencies [7687f7b]
317
+ - Updated dependencies [1659072]
318
+ - Updated dependencies [abceb0d]
319
+ - Updated dependencies [0c302a7]
320
+ - Updated dependencies [6633337]
321
+ - Updated dependencies [f00d8d4]
322
+ - Updated dependencies [503be86]
323
+ - Updated dependencies [cde1975]
324
+ - Updated dependencies [0bc685a]
325
+ - Updated dependencies [11949fc]
326
+ - Updated dependencies [b098b0e]
327
+ - Updated dependencies [4d00b13]
328
+ - Updated dependencies [57bab76]
329
+ - Updated dependencies [b90086a]
330
+ - Updated dependencies [b95577a]
331
+ - Updated dependencies [83c161f]
332
+ - Updated dependencies [d8c4957]
333
+ - Updated dependencies [f24cb83]
334
+ - Updated dependencies [5dbbb92]
335
+ - Updated dependencies [69f1dfd]
336
+ - @objectstack/spec@17.0.0-rc.0
337
+ - @objectstack/core@17.0.0-rc.0
338
+
3
339
  ## 16.1.0
4
340
 
5
341
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@objectstack/connector-mcp",
3
- "version": "16.1.0",
3
+ "version": "17.0.0-rc.1",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Model Context Protocol (MCP) connector for ObjectStack — a generic adapter that turns any MCP server's tools into a connector's actions on the automation engine's connector registry (ADR-0024).",
6
6
  "main": "dist/index.js",
@@ -14,14 +14,14 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "@modelcontextprotocol/sdk": "^1.29.0",
17
- "@objectstack/core": "16.1.0",
18
- "@objectstack/spec": "16.1.0"
17
+ "@objectstack/core": "17.0.0-rc.1",
18
+ "@objectstack/spec": "17.0.0-rc.1"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@types/node": "^26.1.1",
22
22
  "typescript": "^6.0.3",
23
23
  "vitest": "^4.1.10",
24
- "@objectstack/service-automation": "16.1.0"
24
+ "@objectstack/service-automation": "17.0.0-rc.1"
25
25
  },
26
26
  "keywords": [
27
27
  "objectstack",
@@ -32,8 +32,14 @@
32
32
  "ai",
33
33
  "tools"
34
34
  ],
35
+ "files": [
36
+ "dist",
37
+ "README.md",
38
+ "CHANGELOG.md"
39
+ ],
35
40
  "scripts": {
36
41
  "build": "tsup --config ../../../tsup.config.ts",
37
- "test": "vitest run --passWithNoTests"
42
+ "test": "vitest run --passWithNoTests",
43
+ "typecheck": "tsc --noEmit"
38
44
  }
39
45
  }
@@ -1,22 +0,0 @@
1
-
2
- > @objectstack/connector-mcp@16.1.0 build /home/runner/work/objectstack/objectstack/packages/connectors/connector-mcp
3
- > tsup --config ../../../tsup.config.ts
4
-
5
- CLI Building entry: src/index.ts
6
- CLI Using tsconfig: tsconfig.json
7
- CLI tsup v8.5.1
8
- CLI Using tsup config: /home/runner/work/objectstack/objectstack/tsup.config.ts
9
- CLI Target: es2020
10
- CLI Cleaning output folder
11
- ESM Build start
12
- CJS Build start
13
- ESM dist/index.mjs 10.44 KB
14
- ESM dist/index.mjs.map 32.67 KB
15
- ESM ⚡️ Build success in 64ms
16
- CJS dist/index.js 12.20 KB
17
- CJS dist/index.js.map 34.21 KB
18
- CJS ⚡️ Build success in 66ms
19
- DTS Build start
20
- DTS ⚡️ Build success in 15586ms
21
- DTS dist/index.d.mts 10.93 KB
22
- DTS dist/index.d.ts 10.93 KB
@@ -1,127 +0,0 @@
1
- // Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
2
-
3
- import { describe, it, expect } from 'vitest';
4
- import { LiteKernel } from '@objectstack/core';
5
- import { AutomationServicePlugin, type AutomationEngine } from '@objectstack/service-automation';
6
- import { ConnectorMcpPlugin } from './connector-mcp-plugin.js';
7
- import type { McpClientLike, McpToolDescriptor } from './mcp-connector.js';
8
-
9
- const TOOLS: McpToolDescriptor[] = [
10
- {
11
- name: 'create_issue',
12
- description: 'Create a GitHub issue',
13
- inputSchema: {
14
- type: 'object',
15
- properties: { repo: { type: 'string' }, title: { type: 'string' } },
16
- required: ['repo', 'title'],
17
- },
18
- },
19
- ];
20
-
21
- /** A fake MCP client recording calls; injected via the plugin's clientFactory. */
22
- function fakeClient() {
23
- const calls: Array<{ name: string; args: Record<string, unknown> }> = [];
24
- let closed = false;
25
- const client: McpClientLike = {
26
- listTools: async () => TOOLS,
27
- callTool: async (name, args) => {
28
- calls.push({ name, args });
29
- return { content: [{ type: 'text', text: 'created #42' }], structuredContent: { number: 42 } };
30
- },
31
- close: async () => { closed = true; },
32
- };
33
- return { client, calls, isClosed: () => closed };
34
- }
35
-
36
- describe('ConnectorMcpPlugin — end to end with the automation engine', () => {
37
- it('registers the MCP-backed connector so a connector_action flow dispatches to tools/call', async () => {
38
- const { client, calls, isClosed } = fakeClient();
39
-
40
- const kernel = new LiteKernel();
41
- kernel.use(new AutomationServicePlugin());
42
- kernel.use(
43
- new ConnectorMcpPlugin({
44
- // NOTE deliberately no `declarativeStdio`: the #3055 default-deny
45
- // policy gates DECLARATIVE instances only — this hand-wired stdio
46
- // transport (host code, not metadata) must keep working un-gated.
47
- name: 'github_mcp',
48
- label: 'GitHub MCP',
49
- transport: { kind: 'stdio', command: 'noop' },
50
- clientFactory: async () => client,
51
- }),
52
- );
53
- await kernel.bootstrap();
54
-
55
- const engine = kernel.getService<AutomationEngine>('automation');
56
-
57
- // The baseline node and the MCP-backed connector are both present; to the
58
- // registry it is an ordinary connector.
59
- expect(engine.getRegisteredNodeTypes()).toContain('connector_action');
60
- expect(engine.getRegisteredConnectors()).toContain('github_mcp');
61
-
62
- engine.registerFlow('open_issue', {
63
- name: 'open_issue',
64
- label: 'Open an issue via MCP',
65
- type: 'autolaunched',
66
- variables: [{ name: 'call.structuredContent', type: 'json', isOutput: true }],
67
- nodes: [
68
- { id: 'start', type: 'start', label: 'Start' },
69
- {
70
- id: 'call',
71
- type: 'connector_action',
72
- label: 'create_issue',
73
- connectorConfig: {
74
- connectorId: 'github_mcp',
75
- actionId: 'create_issue',
76
- input: { repo: 'acme/app', title: 'Bug' },
77
- },
78
- },
79
- { id: 'end', type: 'end', label: 'End' },
80
- ],
81
- edges: [
82
- { id: 'e1', source: 'start', target: 'call' },
83
- { id: 'e2', source: 'call', target: 'end' },
84
- ],
85
- });
86
-
87
- const result = await engine.execute('open_issue');
88
-
89
- expect(result.success).toBe(true);
90
- // The MCP connector handled the dispatch: one tools/call with the input.
91
- expect(calls).toEqual([{ name: 'create_issue', args: { repo: 'acme/app', title: 'Bug' } }]);
92
- // The normalised structuredContent propagated back into the flow.
93
- expect(result.output).toEqual({ 'call.structuredContent': { number: 42 } });
94
-
95
- // Shutdown tears the MCP connection down.
96
- await kernel.shutdown();
97
- expect(isClosed()).toBe(true);
98
- });
99
-
100
- it('plumbs declarativeStdio through to the registered provider factory (#3055)', async () => {
101
- const { client } = fakeClient();
102
- let registered: ((ctx: unknown) => Promise<unknown>) | undefined;
103
- const automationStub = {
104
- registerConnector: () => {},
105
- unregisterConnector: () => {},
106
- registerConnectorProvider: (_key: string, factory: never) => { registered = factory; },
107
- };
108
- const plugin = new ConnectorMcpPlugin({
109
- clientFactory: async () => client,
110
- declarativeStdio: ['trusted-mcp'],
111
- });
112
- await plugin.init({
113
- getService: () => automationStub,
114
- logger: { info: () => {}, warn: () => {} },
115
- } as never);
116
- expect(registered).toBeDefined();
117
-
118
- const provider = registered!;
119
- const declarativeCtx = (command: string) => ({
120
- name: 'x', label: 'X', type: 'api',
121
- providerConfig: { transport: { kind: 'stdio', command } },
122
- });
123
- // Allowlisted command materializes; anything else is denied by policy.
124
- await expect(provider(declarativeCtx('trusted-mcp'))).resolves.toBeDefined();
125
- await expect(provider(declarativeCtx('bash'))).rejects.toThrow(/declarativeStdio allowlist/);
126
- });
127
- });
@@ -1,149 +0,0 @@
1
- // Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
2
-
3
- import type { Plugin, PluginContext } from '@objectstack/core';
4
- import type { Connector, ConnectorProviderFactory } from '@objectstack/spec/integration';
5
- import { createMcpConnector, type McpConnectorOptions } from './mcp-connector.js';
6
- import {
7
- createMcpProviderFactory,
8
- MCP_PROVIDER_KEY,
9
- type McpDeclarativeStdioPolicy,
10
- } from './mcp-provider.js';
11
-
12
- /**
13
- * Minimal surface of the automation engine this plugin depends on — the
14
- * connector registry (ADR-0018 §Addendum) plus the provider registry (ADR-0097).
15
- * Kept structural so the plugin needs no runtime dependency on
16
- * `@objectstack/service-automation`.
17
- */
18
- export interface ConnectorRegistrySurface {
19
- registerConnector(
20
- def: Connector,
21
- handlers: Record<
22
- string,
23
- (input: Record<string, unknown>, ctx: unknown) => Promise<Record<string, unknown>>
24
- >,
25
- ): void;
26
- unregisterConnector(name: string): void;
27
- registerConnectorProvider(providerKey: string, factory: ConnectorProviderFactory): void;
28
- }
29
-
30
- /**
31
- * Options for {@link ConnectorMcpPlugin}. All optional (ADR-0097): with no
32
- * `transport` the plugin contributes only the `mcp` provider factory — so a
33
- * stack can declare `provider: 'mcp'` instances as pure metadata. Supply a
34
- * `transport` to ALSO connect one hand-wired MCP server at `start()`.
35
- */
36
- export interface ConnectorMcpPluginOptions extends Partial<McpConnectorOptions> {
37
- /**
38
- * Policy for stdio transports on **declarative** `provider: 'mcp'`
39
- * instances (#3055). Default **deny**: metadata (including a runtime Studio
40
- * publish) must not spawn local processes unless the host opts in.
41
- * `string[]` allowlists specific commands; `true` allows any. Hand-wired
42
- * connectors configured via these plugin options are not subject to it —
43
- * their command lives in host code, not metadata.
44
- */
45
- declarativeStdio?: McpDeclarativeStdioPolicy;
46
- }
47
-
48
- /**
49
- * ConnectorMcpPlugin — contributes the generic MCP adapter (ADR-0024) in two forms:
50
- *
51
- * 1. **Provider factory** (`mcp`, ADR-0097): registered at `init()` so the
52
- * automation service can materialize declarative `provider: 'mcp'`
53
- * `connectors:` entries — connecting to the server and mapping its tools to
54
- * connector actions — at boot.
55
- * 2. **Hand-wired instance** (optional, back-compat): when constructed with a
56
- * `transport`, it also connects that one server at `start()` and registers
57
- * the resulting connector.
58
- *
59
- * Lifecycle: on `start()` a configured instance connects and builds the
60
- * connector once; on `destroy()` it tears the MCP connection down. If no
61
- * automation engine is present — or the server is unreachable at boot — the
62
- * hand-wired path logs and skips: a missing optional connector is not fatal
63
- * (unlike a *declarative* provider-bound instance, which fails boot loudly).
64
- */
65
- export class ConnectorMcpPlugin implements Plugin {
66
- name = 'com.objectstack.connector.mcp';
67
- version = '1.0.0';
68
- type = 'standard' as const;
69
- // Ensure the automation engine (and its connector/provider registries) exist first.
70
- dependencies = ['com.objectstack.service-automation'];
71
-
72
- private readonly options: ConnectorMcpPluginOptions;
73
- private connectorName?: string;
74
- private automation?: ConnectorRegistrySurface;
75
- private close?: () => Promise<void>;
76
-
77
- constructor(options: ConnectorMcpPluginOptions = {}) {
78
- this.options = options;
79
- }
80
-
81
- async init(ctx: PluginContext): Promise<void> {
82
- // Contribute the `mcp` provider factory (ADR-0097) before the automation
83
- // service materializes declarative instances during its start().
84
- const automation = this.tryGetAutomation(ctx);
85
- if (automation && typeof automation.registerConnectorProvider === 'function') {
86
- automation.registerConnectorProvider(
87
- MCP_PROVIDER_KEY,
88
- createMcpProviderFactory({
89
- clientFactory: this.options.clientFactory,
90
- declarativeStdio: this.options.declarativeStdio,
91
- }),
92
- );
93
- ctx.logger.info("ConnectorMcpPlugin: registered 'mcp' connector provider");
94
- }
95
- }
96
-
97
- async start(ctx: PluginContext): Promise<void> {
98
- // Provider-only usage (no transport) contributes just the factory in init().
99
- if (!this.options.transport) return;
100
-
101
- const automation = this.tryGetAutomation(ctx);
102
- if (!automation || typeof automation.registerConnector !== 'function') {
103
- ctx.logger.info('ConnectorMcpPlugin: no automation engine — MCP connector not registered');
104
- return;
105
- }
106
-
107
- let bundle;
108
- try {
109
- bundle = await createMcpConnector(this.options as McpConnectorOptions);
110
- } catch (err) {
111
- // The MCP server is unreachable / failed discovery at boot. Skip the
112
- // optional connector rather than failing the whole bootstrap.
113
- ctx.logger.warn(
114
- `ConnectorMcpPlugin: could not connect to MCP server — connector not registered: ${(err as Error).message}`,
115
- );
116
- return;
117
- }
118
-
119
- automation.registerConnector(bundle.def, bundle.handlers);
120
- this.automation = automation;
121
- this.connectorName = bundle.def.name;
122
- this.close = bundle.close;
123
- ctx.logger.info(
124
- `ConnectorMcpPlugin: MCP connector '${bundle.def.name}' registered with ${bundle.def.actions?.length ?? 0} action(s)`,
125
- );
126
- }
127
-
128
- /**
129
- * Destroy phase — the kernel's shutdown hook (the `Plugin` lifecycle exposes
130
- * `destroy()`, not `stop()`). Unregister the connector and tear the MCP
131
- * connection down so no child process / socket is leaked.
132
- */
133
- async destroy(): Promise<void> {
134
- if (this.automation && this.connectorName) {
135
- try { this.automation.unregisterConnector(this.connectorName); } catch { /* ignore */ }
136
- }
137
- if (this.close) {
138
- try { await this.close(); } catch { /* ignore */ }
139
- }
140
- }
141
-
142
- private tryGetAutomation(ctx: PluginContext): ConnectorRegistrySurface | undefined {
143
- try {
144
- return ctx.getService<ConnectorRegistrySurface>('automation');
145
- } catch {
146
- return undefined;
147
- }
148
- }
149
- }