@ebitex/mcp 0.0.0-stage → 1.1.313

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.
Files changed (79) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +143 -2
  3. package/dist/app.d.ts +57 -0
  4. package/dist/app.d.ts.map +1 -0
  5. package/dist/app.js +8 -0
  6. package/dist/app.js.map +1 -0
  7. package/dist/apps/content/app.d.ts +23 -0
  8. package/dist/apps/content/app.d.ts.map +1 -0
  9. package/dist/apps/content/app.js +95 -0
  10. package/dist/apps/content/app.js.map +1 -0
  11. package/dist/apps/content/client.d.ts +34 -0
  12. package/dist/apps/content/client.d.ts.map +1 -0
  13. package/dist/apps/content/client.js +68 -0
  14. package/dist/apps/content/client.js.map +1 -0
  15. package/dist/apps/content/config.d.ts +29 -0
  16. package/dist/apps/content/config.d.ts.map +1 -0
  17. package/dist/apps/content/config.js +30 -0
  18. package/dist/apps/content/config.js.map +1 -0
  19. package/dist/apps/content/errors.d.ts +59 -0
  20. package/dist/apps/content/errors.d.ts.map +1 -0
  21. package/dist/apps/content/errors.js +122 -0
  22. package/dist/apps/content/errors.js.map +1 -0
  23. package/dist/apps/content/resources/helpCorpus.generated.d.ts +7 -0
  24. package/dist/apps/content/resources/helpCorpus.generated.d.ts.map +1 -0
  25. package/dist/apps/content/resources/helpCorpus.generated.js +162 -0
  26. package/dist/apps/content/resources/helpCorpus.generated.js.map +1 -0
  27. package/dist/apps/content/resources/register.d.ts +8 -0
  28. package/dist/apps/content/resources/register.d.ts.map +1 -0
  29. package/dist/apps/content/resources/register.js +81 -0
  30. package/dist/apps/content/resources/register.js.map +1 -0
  31. package/dist/apps/content/routes.d.ts +67 -0
  32. package/dist/apps/content/routes.d.ts.map +1 -0
  33. package/dist/apps/content/routes.js +163 -0
  34. package/dist/apps/content/routes.js.map +1 -0
  35. package/dist/apps/content/session.d.ts +60 -0
  36. package/dist/apps/content/session.d.ts.map +1 -0
  37. package/dist/apps/content/session.js +81 -0
  38. package/dist/apps/content/session.js.map +1 -0
  39. package/dist/apps/content/tools/catalog.d.ts +58 -0
  40. package/dist/apps/content/tools/catalog.d.ts.map +1 -0
  41. package/dist/apps/content/tools/catalog.js +81 -0
  42. package/dist/apps/content/tools/catalog.js.map +1 -0
  43. package/dist/apps/content/tools/cursor.d.ts +62 -0
  44. package/dist/apps/content/tools/cursor.d.ts.map +1 -0
  45. package/dist/apps/content/tools/cursor.js +94 -0
  46. package/dist/apps/content/tools/cursor.js.map +1 -0
  47. package/dist/apps/content/tools/register.d.ts +36 -0
  48. package/dist/apps/content/tools/register.d.ts.map +1 -0
  49. package/dist/apps/content/tools/register.js +470 -0
  50. package/dist/apps/content/tools/register.js.map +1 -0
  51. package/dist/apps/content/tools/result.d.ts +28 -0
  52. package/dist/apps/content/tools/result.d.ts.map +1 -0
  53. package/dist/apps/content/tools/result.js +26 -0
  54. package/dist/apps/content/tools/result.js.map +1 -0
  55. package/dist/apps/content/tools/whoami.d.ts +36 -0
  56. package/dist/apps/content/tools/whoami.d.ts.map +1 -0
  57. package/dist/apps/content/tools/whoami.js +39 -0
  58. package/dist/apps/content/tools/whoami.js.map +1 -0
  59. package/dist/apps/index.d.ts +8 -0
  60. package/dist/apps/index.d.ts.map +1 -0
  61. package/dist/apps/index.js +8 -0
  62. package/dist/apps/index.js.map +1 -0
  63. package/dist/config.d.ts +46 -0
  64. package/dist/config.d.ts.map +1 -0
  65. package/dist/config.js +69 -0
  66. package/dist/config.js.map +1 -0
  67. package/dist/index.d.ts +19 -0
  68. package/dist/index.d.ts.map +1 -0
  69. package/dist/index.js +20 -0
  70. package/dist/index.js.map +1 -0
  71. package/dist/main.d.ts +3 -0
  72. package/dist/main.d.ts.map +1 -0
  73. package/dist/main.js +51 -0
  74. package/dist/main.js.map +1 -0
  75. package/dist/server.d.ts +51 -0
  76. package/dist/server.d.ts.map +1 -0
  77. package/dist/server.js +104 -0
  78. package/dist/server.js.map +1 -0
  79. package/package.json +44 -4
@@ -0,0 +1,470 @@
1
+ import { z } from 'zod';
2
+ import { query } from '../client.js';
3
+ import { ContentApiError, permissionHint } from '../errors.js';
4
+ import { routesFor, withId, WRITABLE_KINDS } from '../routes.js';
5
+ import { AUTHENTICATED, KIND_PERMISSIONS, sessionCanUse, TOOL_CATALOG } from './catalog.js';
6
+ import { decodeCursor, nextSearchCursor } from './cursor.js';
7
+ import { fail, guard, ok } from './result.js';
8
+ import { describeSession } from './whoami.js';
9
+ const KIND = z.enum(WRITABLE_KINDS);
10
+ /**
11
+ * Why a write or delete of this kind would be refused for the acting role, or null to send it.
12
+ *
13
+ * Refused here rather than sent: the role is known from `/whoami`, so the request can only come back
14
+ * `403`, and an agent that is told the permission and the remedy up front does not spend a turn
15
+ * learning it. The tool itself stays registered, because the key's other kinds are unaffected.
16
+ */
17
+ function refusedForPermission(session, kind) {
18
+ const permission = KIND_PERMISSIONS[kind];
19
+ if (!permission || !session.lacksPermission(permission))
20
+ return null;
21
+ return `Not sent. ${permissionHint(permission)}`;
22
+ }
23
+ /** The kinds this role cannot write, for `content_whoami`, each with the permission it lacks. */
24
+ function withheldKinds(session) {
25
+ return Object.entries(KIND_PERMISSIONS)
26
+ .filter(([, permission]) => permission && session.lacksPermission(permission))
27
+ .map(([kind, requires]) => ({ kind, requires: requires }));
28
+ }
29
+ export function registerTools(server, context) {
30
+ const { client, session, target, serverVersion } = context;
31
+ // Everything below is gated on a scope, and an absent tool is the point: an agent that cannot see
32
+ // a tool will not plan around it, where a tool that is present and always 403s costs it a turn
33
+ // and a re-plan (§4).
34
+ //
35
+ // Each boolean and `withheld[]` below both read `catalog.ts`'s `TOOL_CATALOG` rather than
36
+ // separately restating which scope gates which tool (spec 887-shared-tool-catalogue) — the
37
+ // previous version of this file encoded that mapping twice (these four `session.has(...)` calls,
38
+ // and a second, independent list inside `withheld[]`'s construction), which is exactly the
39
+ // "hand-kept mirror" shape that let content_transfer's own scope go stale (spec #792; this
40
+ // codebase has had that failure twice, and both times the forgotten copy was the reader).
41
+ const canRead = sessionCanUse(session, 'content_describe');
42
+ const canAuthor = sessionCanUse(session, 'content_write');
43
+ const canPublish = sessionCanUse(session, 'content_publish');
44
+ const canTransfer = sessionCanUse(session, 'content_transfer');
45
+ const withheld = TOOL_CATALOG.filter((tool) => tool.requiredScope !== AUTHENTICATED && !session.has(tool.requiredScope)).map((tool) => ({ tool: tool.name, requires: tool.requiredScope }));
46
+ // Gated on NOTHING, and registered before every scope block so that is visible at a glance.
47
+ //
48
+ // It mirrors the server route's own scope exemption (ContentManagementRouteScopes.AuthenticatedOnly)
49
+ // and for the same reason spec #511 gave for it: a key minted with only `publish` must be able to
50
+ // discover that that is all it holds, which it could not if the answer itself required `read`. The
51
+ // MCP surface made that worse than the HTTP one — such a key watches five tools vanish with nothing
52
+ // to ask about it. It also costs nothing: `resolveSession` already called `/whoami` at startup, so
53
+ // this answers from memory and issues no request.
54
+ server.registerTool('content_whoami', {
55
+ title: 'Where am I scoped?',
56
+ description: 'What this credential is: the organization and authoring environment it is bound to, the ' +
57
+ 'role it acts as, its scopes, this server\'s version, and which tools were withheld and the ' +
58
+ 'scope each needs. Read it before concluding that something does not exist — every result ' +
59
+ 'from this server is scoped to one environment, so an empty list means nothing matched ' +
60
+ 'there, not that nothing exists anywhere.',
61
+ inputSchema: {},
62
+ // openWorldHint is false here and true on every other tool: this one reaches no external
63
+ // system at all, answering from the credential resolved when the server started.
64
+ annotations: { readOnlyHint: true, openWorldHint: false },
65
+ }, async () => ok(describeSession(session, withheld, serverVersion, withheldKinds(session))));
66
+ if (canRead) {
67
+ server.registerTool('content_describe', {
68
+ title: 'Describe what can exist here',
69
+ description: 'What this environment can hold: every field type with its own settings JSON Schema, ' +
70
+ 'and the Contracts and Templates that already exist. Call this first — it is where the ' +
71
+ 'shape of everything you are about to write comes from, and it is answered live by the ' +
72
+ 'server rather than from anything this tool knows.',
73
+ inputSchema: {
74
+ include: z
75
+ .array(z.enum(['fieldTypes', 'contracts', 'templates']))
76
+ .optional()
77
+ .describe('Defaults to all three.'),
78
+ },
79
+ annotations: { readOnlyHint: true, openWorldHint: true },
80
+ }, async ({ include }) => guard(async () => {
81
+ const wanted = new Set(include ?? ['fieldTypes', 'contracts', 'templates']);
82
+ const [fieldTypes, contracts, templates] = await Promise.all([
83
+ wanted.has('fieldTypes') ? client.request('GET', '/field-types') : undefined,
84
+ wanted.has('contracts') ? client.request('GET', '/contracts') : undefined,
85
+ wanted.has('templates') ? client.request('GET', '/templates') : undefined,
86
+ ]);
87
+ const result = { fieldTypes, contracts, templates };
88
+ return ok(result, readContext(session, result));
89
+ }));
90
+ server.registerTool('content_find', {
91
+ title: 'Find entities',
92
+ description: 'Locate entities in this environment. With no kind, returns a paged inventory of ' +
93
+ 'everything; with a kind, only that kind. Use it to check whether something already ' +
94
+ 'exists before creating a duplicate.',
95
+ inputSchema: {
96
+ kind: z.string().optional().describe('contract, template, component, adapter, stream, categoryGroup, category, folder, node'),
97
+ search: z.string().optional().describe('Free-text search. Components only.'),
98
+ externalId: z.string().optional().describe('Exact match. Components only.'),
99
+ limit: z.number().int().min(1).max(200).optional(),
100
+ cursor: z.string().optional().describe('From a previous call\'s nextCursor.'),
101
+ },
102
+ annotations: { readOnlyHint: true, openWorldHint: true },
103
+ }, async ({ kind, search, externalId, limit, cursor }) => guard(async () => {
104
+ // Two listings, one tool, because both answer "what is already here" and an agent asking
105
+ // that should not have to know which of them can filter. The components listing is the
106
+ // only one that takes a query at all; /items is a flat inventory across every kind.
107
+ //
108
+ // They also PAGE differently, and not merely by parameter name: /items is cursor-paged,
109
+ // /components is offset-paged (page/pageSize, answering totalCount) and returns no cursor at
110
+ // all. This tool's schema promises `limit` and `cursor` for both, and the search branch
111
+ // used to forward neither — so an agent paginating a search got page one forever, with
112
+ // nothing saying its parameters had been discarded (spec #793). `cursor.ts` normalizes the
113
+ // two into one contract; the branch an agent is on is never its problem.
114
+ const decoded = decodeCursor(cursor);
115
+ if (decoded.kind === 'malformed') {
116
+ return fail('That cursor is not one this tool issued, or it has been altered. Drop it to start ' +
117
+ 'from the first page, or pass the exact nextCursor from a previous call.');
118
+ }
119
+ if (search !== undefined || externalId !== undefined) {
120
+ if (kind !== undefined && kind !== 'component') {
121
+ return fail('search and externalId filter components only; drop them, or pass kind: "component".');
122
+ }
123
+ if (decoded.kind === 'passthrough' && cursor !== undefined) {
124
+ return fail('That cursor came from the inventory listing and cannot page a components search. ' +
125
+ 'Drop search/externalId to keep paging the inventory, or drop the cursor to search ' +
126
+ 'from the first page.');
127
+ }
128
+ const page = decoded.kind === 'search' ? decoded.page : 1;
129
+ const found = await client.request('GET',
130
+ // `page` only once past the first, so a search with no paging asked for is the exact
131
+ // request this tool has always sent.
132
+ `/components${query({ search, externalId, page: page > 1 ? page : undefined, pageSize: limit })}`);
133
+ return ok({ ...found, nextCursor: nextSearchCursor(found) }, readContext(session, found));
134
+ }
135
+ if (decoded.kind === 'search') {
136
+ return fail('That cursor came from a components search and cannot page the inventory listing. ' +
137
+ 'Keep search/externalId to continue that search, or drop the cursor to list from the ' +
138
+ 'first page.');
139
+ }
140
+ const listed = await client.request('GET', `/items${query({ kind, limit, cursor })}`);
141
+ return ok(listed, readContext(session, listed));
142
+ }));
143
+ server.registerTool('content_get', {
144
+ title: 'Read one entity',
145
+ description: 'Read a single entity in full, by id. Not every kind supports this — folders, ' +
146
+ 'sites and taxonomy are read by listing them with content_find instead, and this tool ' +
147
+ 'will say so rather than guess at a route.',
148
+ inputSchema: { kind: KIND, id: z.string() },
149
+ annotations: { readOnlyHint: true, openWorldHint: true },
150
+ }, async ({ kind, id }) => guard(async () => {
151
+ const routes = routesFor(kind);
152
+ if (!routes.readOne) {
153
+ return fail(`${routes.label} has no single-entity read on this API. Use content_find` +
154
+ (routes.list ? ` (kind: "${kind}")` : '') +
155
+ ' instead.');
156
+ }
157
+ try {
158
+ return ok(await client.request('GET', withId(routes.readOne, id)), session.contextLine());
159
+ }
160
+ catch (error) {
161
+ // A 404 here always means "not found *in this key's environment*", and the relayed body
162
+ // cannot say so — it is the server's answer about a route, not about a binding. So the
163
+ // binding is ADDED after it, never substituted for it: §3's verbatim relay is what closes
164
+ // the agent's try → read → fix loop, and this is the same shape `errors.ts` already uses
165
+ // to add a `Request id:` line without touching the body.
166
+ if (error instanceof ContentApiError && error.status === 404) {
167
+ return fail(`${error.message}\n${session.contextLine()} — not found in this environment, which is ` +
168
+ 'the only one this key can read.');
169
+ }
170
+ throw error;
171
+ }
172
+ }));
173
+ // Its own tool rather than another `include` value on content_describe (spec 748): describe
174
+ // answers "what can this environment hold", this answers "where does it sit", and an agent
175
+ // deciding whether to publish should find the second without paying for every field type's
176
+ // settings schema. Fetched per call, never at startup: an edge can change mid-session, and a
177
+ // stale answer about where a publish lands is the worst kind of stale.
178
+ server.registerTool('content_topology', {
179
+ title: 'Where this environment sits',
180
+ description: "This environment's direct neighbours. publishesTo: the delivery environments a publish " +
181
+ 'from here can land in — with two or more, a publish must name which one. promotesTo: ' +
182
+ 'where this content goes when someone promotes it. promotedFrom: environments whose ' +
183
+ 'promotion into here can overwrite what you write. Call it before publishing. It ' +
184
+ 'reports one hop only, and nothing about which environment is production — judge ' +
185
+ 'that from the names. (An inherited_read_only refusal is about realms, not ' +
186
+ 'environments: the item is owned by a realm above the one you act in.)',
187
+ inputSchema: {},
188
+ annotations: { readOnlyHint: true, openWorldHint: true },
189
+ }, async () => guard(async () => {
190
+ try {
191
+ return ok(await client.request('GET', '/topology'), session.contextLine());
192
+ }
193
+ catch (error) {
194
+ // The one refusal worth rewording, because its remedy is not in the body: routing
195
+ // answers an unmapped path with a bodiless 404, and an API deployed before this route
196
+ // existed is the only way to get one here. Everything else is relayed verbatim (§3).
197
+ if (error instanceof ContentApiError && error.status === 404) {
198
+ return fail(`${client.baseUrl} does not serve GET /content/management/v1/topology. The API ` +
199
+ 'predates it: upgrade the API, or point EBITEX_API_BASE at one that ' +
200
+ 'serves it. Nothing about this key is wrong.');
201
+ }
202
+ throw error;
203
+ }
204
+ }));
205
+ }
206
+ if (canAuthor) {
207
+ server.registerTool('content_write', {
208
+ title: 'Create or update an entity',
209
+ description: 'Create (omit id) or update (supply id) one entity. The payload is whatever that kind\'s ' +
210
+ 'API takes — run content_describe first to learn it. The server validates what you send ' +
211
+ 'and refuses an invalid document naming the failing field, so a refusal tells you exactly ' +
212
+ 'what to change; correct it and call again.\n\n' +
213
+ 'One update is not a partial update: a category PUT always applies parentCategoryId, so ' +
214
+ 'renaming a category without sending its current parentCategoryId moves it to the top of ' +
215
+ 'its group. Send the parent you want it to keep. (This is the only such field; everything ' +
216
+ 'else omitted stays as it is.)',
217
+ inputSchema: {
218
+ kind: KIND,
219
+ id: z.string().optional().describe('Omit to create.'),
220
+ payload: z.record(z.string(), z.unknown()).describe('The request body, as this kind\'s API defines it.'),
221
+ },
222
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
223
+ }, async ({ kind, id, payload }) => guard(async () => {
224
+ const routes = routesFor(kind);
225
+ const refused = refusedForPermission(session, kind);
226
+ if (refused)
227
+ return fail(refused);
228
+ if (!id) {
229
+ if (!routes.create) {
230
+ return fail(`${routes.label} cannot be created on its own; it is written by updating its owner.`);
231
+ }
232
+ return ok(await client.request('POST', routes.create, payload), session.contextLine());
233
+ }
234
+ if (!routes.update) {
235
+ return fail(`${routes.label} cannot be updated once created.`);
236
+ }
237
+ // PATCH for an Adapter, PUT for everything else. Read from the table rather than assumed
238
+ // uniform — see routes.ts's header for why that distinction is load-bearing.
239
+ return ok(await client.request(routes.update.method, withId(routes.update.path, id), payload), session.contextLine());
240
+ }));
241
+ server.registerTool('content_delete', {
242
+ title: 'Delete an entity',
243
+ description: 'Permanently delete one entity. Requires confirm: true. Content refuses to delete ' +
244
+ 'anything still in use and will name what depends on it, so a refusal here is the ' +
245
+ 'product protecting you rather than an error to work around.',
246
+ inputSchema: {
247
+ kind: KIND,
248
+ id: z.string(),
249
+ confirm: z.boolean().describe('Must be true. There is no undo.'),
250
+ },
251
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: true },
252
+ }, async ({ kind, id, confirm }) => guard(async () => {
253
+ // Refused locally rather than sent. An unconfirmed delete is not a request the server
254
+ // should have to judge, and asking it would mean the confirmation could be satisfied by
255
+ // a retry that happened to succeed.
256
+ if (!confirm)
257
+ return fail('Not deleted. Pass confirm: true to delete this permanently.');
258
+ const routes = routesFor(kind);
259
+ const refused = refusedForPermission(session, kind);
260
+ if (refused)
261
+ return fail(refused);
262
+ if (!routes.remove)
263
+ return fail(`${routes.label} cannot be deleted through this API.`);
264
+ await client.request('DELETE', withId(routes.remove, id));
265
+ return ok(`Deleted ${routes.label} ${id}.`, session.contextLine());
266
+ }));
267
+ }
268
+ if (canPublish) {
269
+ server.registerTool('content_publish', {
270
+ title: 'Publish content',
271
+ description: 'Publishing is two calls, and deliberately so. Pass roots to get a plan: it resolves the ' +
272
+ 'whole dependency closure and reports blockers — an unresolved reference, a workflow ' +
273
+ 'state, a validation failure. Read the plan, then call again with items to publish them. ' +
274
+ 'Both phases are jobs: poll the returned operationId with content_operation_status.',
275
+ inputSchema: {
276
+ roots: z
277
+ .array(z.record(z.string(), z.unknown()))
278
+ .optional()
279
+ .describe('Plan phase: the entities to publish, each { kind, id }.'),
280
+ items: z
281
+ .array(z.record(z.string(), z.unknown()))
282
+ .optional()
283
+ .describe("Execute phase: the finished plan's own items, passed straight through. To skip one, " +
284
+ 'set include:false on it rather than removing it.'),
285
+ deliveryEnvironmentId: z.string().optional().describe('Required only when several delivery targets are mapped.'),
286
+ },
287
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
288
+ }, async ({ roots, items, deliveryEnvironmentId }) => guard(async () => {
289
+ if ((roots === undefined) === (items === undefined)) {
290
+ return fail('Pass exactly one of roots (to plan) or items (to publish).');
291
+ }
292
+ if (roots) {
293
+ return ok(await client.request('POST', '/publish-plan', { roots, deliveryEnvironmentId }), session.contextLine());
294
+ }
295
+ return ok(await client.request('POST', '/publish', {
296
+ items: items.map(toPublishItem),
297
+ deliveryEnvironmentId,
298
+ }), session.contextLine());
299
+ }));
300
+ }
301
+ if (canRead) {
302
+ server.registerTool('content_operation_status', {
303
+ title: 'Check a job',
304
+ description: 'Poll a publish plan or publish job by its operationId. A finished job carries its ' +
305
+ 'result — for a plan, that result is the plan itself.',
306
+ inputSchema: { operationId: z.string() },
307
+ annotations: { readOnlyHint: true, openWorldHint: true },
308
+ }, async ({ operationId }) => guard(async () => ok(await client.request('GET', `/operations/${encodeURIComponent(operationId)}`), session.contextLine())));
309
+ }
310
+ if (canTransfer) {
311
+ server.registerTool('content_transfer', {
312
+ title: 'Move a model between environments',
313
+ description: 'Export this environment (or a set of roots) as a bundle, and — when a target key is ' +
314
+ 'configured — import it into that target atomically. This is the one operation bundles ' +
315
+ 'are uniquely good at: forty per-entity writes are forty transactions, and one import is ' +
316
+ 'one. The bundle is produced and consumed by the server; nothing here builds it.\n\n' +
317
+ 'Importing is a job, like publishing: with apply, this returns the plan and an ' +
318
+ 'operationId, and the import is NOT finished when this returns. Poll it with ' +
319
+ 'content_operation_status until it succeeds or fails — a failed run says why, including ' +
320
+ 'every invalid document when that is the reason.',
321
+ inputSchema: {
322
+ roots: z.array(z.record(z.string(), z.unknown())).optional(),
323
+ wholeEnvironment: z.boolean().optional(),
324
+ apply: z
325
+ .boolean()
326
+ .optional()
327
+ .describe('Import into the target environment. Without it, the bundle is only returned.'),
328
+ // The server's own three modes (Content.Api.Transfer.TransferIdentityModes), held in step
329
+ // by src/test/transfer-identity-modes.json, which the C# side asserts too. This offered
330
+ // `existing` — a value the server has never accepted — and hid `preserve` entirely, so an
331
+ // agent could pick a mode guaranteed to 400 and could not pick a working one (spec
332
+ // 760-mcp-transfer-identity-modes). The descriptions matter more than usual here: an agent
333
+ // cannot inspect the server to learn what a mode means, and confusing `preserve` with
334
+ // `externalId` imports successfully into the wrong shape rather than failing.
335
+ identityMode: z
336
+ .enum(['preserve', 'fresh', 'externalId'])
337
+ .optional()
338
+ .describe('How the bundle\'s items are matched to what the target already holds. ' +
339
+ '"externalId" (the default) matches each item by its own natural key — its external ' +
340
+ 'id, or a key/slug/name path for the kinds that have none — which is what a model ' +
341
+ 'held in source control needs, since it can never know the target\'s ids. ' +
342
+ '"preserve" keeps the bundle\'s ids, for moving between environments you control. ' +
343
+ '"fresh" gives every item a new id, and is required when importing into a different ' +
344
+ 'organization.'),
345
+ },
346
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
347
+ }, async ({ roots, wholeEnvironment, apply, identityMode }) => guard(async () => {
348
+ const bundle = await client.request('POST', '/export', {
349
+ roots,
350
+ wholeEnvironment: wholeEnvironment ?? roots === undefined,
351
+ });
352
+ if (!apply)
353
+ return ok(bundle);
354
+ if (!target) {
355
+ return fail('No target environment is configured. Set EBITEX_CONTENT_TARGET_MANAGEMENT_KEY to a ' +
356
+ 'key bound to the environment this should import into.');
357
+ }
358
+ const mode = identityMode ?? 'externalId';
359
+ const plan = (await target.request('POST', '/import-plan', { bundle, identityMode: mode }));
360
+ // The plan's own items are echoed back as the selection. `items[]` selects what is
361
+ // written (spec #623), so sending the plan unchanged is "apply everything this plan
362
+ // describes" — and it is the plan, not this code, that decided what that is.
363
+ //
364
+ // Spec 775-management-import-async-job: this answers 202 `{ id, status }` and the import
365
+ // runs as a job. Returned as `operation` rather than polled here, matching content_publish
366
+ // in this same file — the agent polls with content_operation_status. The naming is
367
+ // load-bearing: returning a kick-off envelope under `result` is precisely how an agent
368
+ // would report a finished import that had not run yet.
369
+ const selection = (plan.items ?? []).map((item) => ({ kind: item.kind, id: item.id }));
370
+ // `items[]` SELECTS what is written (spec #623), so an empty selection is not "import
371
+ // everything" — it is an import that writes nothing and answers `succeeded`, which an agent
372
+ // then reports as content that exists. Exactly the failure `toPublishItem` below was written
373
+ // to prevent on the publish path; this path had no guard at all (spec #793).
374
+ //
375
+ // Refused BEFORE the call, not after on the operation's result: starting a job that provably
376
+ // writes nothing spends a write quota and leaves an operation record implying an import
377
+ // happened. And `fail()` rather than a success carrying a warning, because a
378
+ // successful-looking result indistinguishable from a real import is the whole defect.
379
+ //
380
+ // Note an empty plan is not necessarily the server being wrong: a bundle whose every item
381
+ // already matches the target legitimately plans to nothing. What is wrong is calling that an
382
+ // import — so this says which of the two happened.
383
+ if (selection.length === 0) {
384
+ return fail('Nothing would be imported. The plan selected 0 items, and items[] is what an import ' +
385
+ 'writes — so this would start a job, import nothing, and report success. Nothing was ' +
386
+ 'sent. If the target already matches the source, that is the plan saying so.');
387
+ }
388
+ const operation = await target.request('POST', '/import', {
389
+ bundle,
390
+ identityMode: mode,
391
+ items: selection,
392
+ });
393
+ return ok({ plan, operation, pollWith: 'content_operation_status' });
394
+ }));
395
+ }
396
+ }
397
+ /**
398
+ * The context line a read result carries, and the stronger sentence an empty one gets.
399
+ *
400
+ * Spec #792: an agent could not tell **"none exist"** from **"none in this key's scope"**, because
401
+ * neither `[]` nor a relayed `404` named the environment it was answered in. That is the same
402
+ * ambiguity spec #790 found one layer out, where it cost a long misdiagnosis — an empty array that
403
+ * meant "nothing selected" read as "nothing exists".
404
+ *
405
+ * An empty read stays a **success**. A brand-new environment genuinely has no Contracts, so marking
406
+ * it an error would send an agent hunting a fault that does not exist; what was missing is what the
407
+ * emptiness is *of*.
408
+ */
409
+ function readContext(session, result) {
410
+ return looksEmpty(result)
411
+ ? `${session.contextLine()} 0 of 0 — this key reads only this environment.`
412
+ : session.contextLine();
413
+ }
414
+ /**
415
+ * Whether a response carries no content at all.
416
+ *
417
+ * Deliberately conservative: it answers `false` whenever it is unsure, because claiming "0 of 0"
418
+ * about a result that did contain something would be a new way of saying the wrong thing. `null` and
419
+ * `undefined` members are ignored rather than counted (`{items: [], nextCursor: null}` is empty; so
420
+ * is a `content_describe` narrowed by `include` to one empty list).
421
+ */
422
+ function looksEmpty(result) {
423
+ if (Array.isArray(result))
424
+ return result.length === 0;
425
+ if (typeof result !== 'object' || result === null)
426
+ return false;
427
+ // Both listings answer with an `items` array, and that member alone decides for them. Checked
428
+ // before the general rule below because a paged `/components` body also carries `totalCount`, `page`
429
+ // and `pageSize` — numbers, which are not evidence of content either way, and which the general
430
+ // rule would read as "this result contains something".
431
+ const items = result.items;
432
+ if (Array.isArray(items))
433
+ return items.length === 0;
434
+ const present = Object.values(result).filter((value) => value !== undefined && value !== null);
435
+ return present.length > 0 && present.every((value) => Array.isArray(value) && value.length === 0);
436
+ }
437
+ /**
438
+ * Normalizes one execute item.
439
+ *
440
+ * `POST /publish` takes `{ kind, id, versionNumber, include }`, and **both of the last two are load
441
+ * bearing in a way nothing reports**: an item arriving without `include` is skipped by design, and
442
+ * one without `versionNumber` pins version 0. Send the obvious `{ kind, id }` — which is what an
443
+ * agent echoing "the plan's items" naturally reduces them to — and the job answers **`succeeded`
444
+ * with an empty result array, having published nothing**. No error, no warning, and an agent reports
445
+ * success to the person who asked.
446
+ *
447
+ * So this maps the plan's own item shape onto the execute shape, and treats an absent `include` as
448
+ * `true` — because naming an item in an execute call *is* asking for it to be published. An
449
+ * explicit `include: false` is untouched, which is what keeps the "echo the plan, deselect some"
450
+ * idiom working.
451
+ *
452
+ * It **projects** rather than spreads: a plan item also carries `name`, `path` and `publishStatus`,
453
+ * and this API rejects unknown properties rather than ignoring them (deliberately — for a mutation,
454
+ * silently ignoring a misspelled property is data loss reported as success). So passing a plan item
455
+ * through untouched is `400 unknown_property`. Between that and the silent no-op above, *neither*
456
+ * obvious move works, which is exactly why this function exists instead of a sentence in a tool
457
+ * description.
458
+ *
459
+ * This is not content-model knowledge (the drift guard's concern) — it is this one endpoint's
460
+ * request shape, the same category as knowing a Contract lives at `/contracts`.
461
+ */
462
+ function toPublishItem(item) {
463
+ return {
464
+ kind: item.kind,
465
+ id: item.id,
466
+ versionNumber: item.versionNumber ?? item.headVersionNumber,
467
+ include: item.include ?? true,
468
+ };
469
+ }
470
+ //# sourceMappingURL=register.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.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KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAA;AACnG,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,SAAS,aAAa,CAAC,IAA6B;IAClD,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,aAAa,EAAE,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,iBAAiB;QAC3D,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,IAAI;KAC9B,CAAA;AACH,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * The shape every tool returns, and the one place a refusal is turned into text.
3
+ *
4
+ * MCP's own result type has an `isError` flag and a content array; what matters here is what goes
5
+ * into the array. The rule: a validation failure is the agent's
6
+ * control loop, so it is relayed whole, with its field paths intact, and never summarized. That is
7
+ * implemented by `ContentApiError.message` already carrying the whole body, so this module simply
8
+ * does not get in its way.
9
+ */
10
+ export type ToolResult = {
11
+ content: {
12
+ type: 'text';
13
+ text: string;
14
+ }[];
15
+ isError?: boolean;
16
+ [key: string]: unknown;
17
+ };
18
+ export declare function ok(value: unknown, context?: string): ToolResult;
19
+ export declare function fail(text: string): ToolResult;
20
+ /**
21
+ * Runs a tool body, turning any thrown error into a result rather than a transport-level failure.
22
+ *
23
+ * A thrown error reaches the agent as a protocol error rather than a tool result in some clients,
24
+ * which is a worse place for a message it is meant to act on — so everything lands in `isError`
25
+ * instead, where the text is unambiguously part of the conversation.
26
+ */
27
+ export declare function guard(run: () => Promise<ToolResult>): Promise<ToolResult>;
28
+ //# sourceMappingURL=result.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../../../../src/apps/content/tools/result.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IACzC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB,CAAA;AAED,wBAAgB,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,UAAU,CAG/D;AAED,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAE7C;AAED;;;;;;GAMG;AACH,wBAAsB,KAAK,CAAC,GAAG,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAO/E"}
@@ -0,0 +1,26 @@
1
+ import { ContentApiError } from '../errors.js';
2
+ export function ok(value, context) {
3
+ const body = typeof value === 'string' ? value : JSON.stringify(value ?? null, null, 2);
4
+ return { content: [{ type: 'text', text: context ? `${context}\n${body}` : body }] };
5
+ }
6
+ export function fail(text) {
7
+ return { content: [{ type: 'text', text }], isError: true };
8
+ }
9
+ /**
10
+ * Runs a tool body, turning any thrown error into a result rather than a transport-level failure.
11
+ *
12
+ * A thrown error reaches the agent as a protocol error rather than a tool result in some clients,
13
+ * which is a worse place for a message it is meant to act on — so everything lands in `isError`
14
+ * instead, where the text is unambiguously part of the conversation.
15
+ */
16
+ export async function guard(run) {
17
+ try {
18
+ return await run();
19
+ }
20
+ catch (error) {
21
+ if (error instanceof ContentApiError)
22
+ return fail(error.message);
23
+ return fail(error instanceof Error ? error.message : String(error));
24
+ }
25
+ }
26
+ //# sourceMappingURL=result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.js","sourceRoot":"","sources":["../../../../src/apps/content/tools/result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAkB9C,MAAM,UAAU,EAAE,CAAC,KAAc,EAAE,OAAgB;IACjD,MAAM,IAAI,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,IAAI,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IACvF,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,CAAA;AACtF,CAAC;AAED,MAAM,UAAU,IAAI,CAAC,IAAY;IAC/B,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;AAC7D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,GAA8B;IACxD,IAAI,CAAC;QACH,OAAO,MAAM,GAAG,EAAE,CAAA;IACpB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,eAAe;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QAChE,OAAO,IAAI,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;IACrE,CAAC;AACH,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { Session } from '../session.js';
2
+ /**
3
+ * What `content_whoami` answers.
4
+ *
5
+ * **Why this is a tool and not only the resource that already exists.** `ebitex-content://whoami`
6
+ * has been served since this server's first release, and many MCP clients surface resources to the
7
+ * *user* and never to the *model*. A resource the agent cannot read is, for this purpose, not an
8
+ * answer: it has no self-service way to ask "where am I scoped?" before interpreting an empty list,
9
+ * which is exactly when it needs to. Both read `session.who`, so the two can never disagree.
10
+ *
11
+ * **Why it costs nothing.** `resolveSession` already called `GET /whoami` at startup to decide which
12
+ * tools to register at all. This renders that same resolution; it issues no request.
13
+ */
14
+ /** One tool this key cannot see, and the scope that would have shown it. */
15
+ export type WithheldTool = {
16
+ tool: string;
17
+ requires: string;
18
+ };
19
+ /** One entity kind the acting role may not write, and the permission that would allow it. */
20
+ export type WithheldKind = {
21
+ kind: string;
22
+ requires: string;
23
+ };
24
+ /**
25
+ * The one genuinely new fact this tool reports.
26
+ *
27
+ * Tool *absence* is otherwise indistinguishable from "this server has no such capability" — an agent
28
+ * offered no `content_write` cannot tell a read-scoped key from a server that simply cannot write.
29
+ *
30
+ * The list is **derived** by the caller from the same booleans that gate registration, never
31
+ * enumerated in a table here. A second list of tool→scope is a copy of a fact the `if` blocks already
32
+ * state, and it goes stale the first time a tool moves scope — a failure this codebase has had twice
33
+ * elsewhere, both times in the *reader* rather than the writer.
34
+ */
35
+ export declare function describeSession(session: Session, withheld: readonly WithheldTool[], serverVersion: string, withheldKinds?: readonly WithheldKind[]): Record<string, unknown>;
36
+ //# sourceMappingURL=whoami.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"whoami.d.ts","sourceRoot":"","sources":["../../../../src/apps/content/tools/whoami.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAE5C;;;;;;;;;;;GAWG;AAEH,4EAA4E;AAC5E,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,6FAA6F;AAC7F,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,SAAS,YAAY,EAAE,EACjC,aAAa,EAAE,MAAM,EACrB,aAAa,GAAE,SAAS,YAAY,EAAO,GAC1C,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA4BzB"}