@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
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,144 @@
1
- # Temporary Holding Version
1
+ # @ebitex/mcp
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ An [MCP](https://modelcontextprotocol.io) server for the **ebitex suite**. Point an AI agent at it and
4
+ it can work in your apps through your own management keys. Today that is **Content**: it can build a
5
+ content model end to end (Contracts and their fields, Templates, Components, the Experience tree) and
6
+ publish it. Each further app arrives as another set of tools in this same server, so there is one
7
+ package to install and one entry in your MCP client, not one per app.
8
+
9
+ It runs locally, over `stdio`, authenticated by management keys you mint yourself. Nothing is hosted
10
+ by ebitex, so your write-capable keys never leave your machine.
11
+
12
+ > This package was published as `@ebitex/content-mcp` until it became the suite's server. That name
13
+ > still runs this one and is deprecated; change it to `@ebitex/mcp` when convenient. Nothing else
14
+ > changes: the Content tools, resources and environment variables are the same.
15
+
16
+ ## Configure it
17
+
18
+ ```json
19
+ {
20
+ "mcpServers": {
21
+ "ebitex": {
22
+ "command": "npx",
23
+ "args": ["-y", "@ebitex/mcp"],
24
+ "env": { "EBITEX_CONTENT_MANAGEMENT_KEY": "frm_live_..." }
25
+ }
26
+ }
27
+ }
28
+ ```
29
+
30
+ **An app's tools appear when its key is set.** Each app has its own key, minted in that app and bound to
31
+ one organization, so a session that should reach two apps carries two keys. A server with no app key
32
+ set refuses to start and names each variable.
33
+
34
+ Shared by every app:
35
+
36
+ | Variable | |
37
+ |---|---|
38
+ | `EBITEX_API_BASE` | Defaults to `https://api.ebitex.io` |
39
+ | `EBITEX_MCP_READ_ONLY` | Set to `1` to hide every write tool in every app, regardless of the keys' scopes |
40
+
41
+ Content:
42
+
43
+ | Variable | |
44
+ |---|---|
45
+ | `EBITEX_CONTENT_MANAGEMENT_KEY` | **Required to use Content.** Mint one in Content under Settings → API Keys → Management keys |
46
+ | `EBITEX_CONTENT_TARGET_MANAGEMENT_KEY` | A second key, for `content_transfer` to import into |
47
+ | `EBITEX_CONTENT_REALM` | The realm key the management key is expected to act in. Startup stops if it does not (a key is bound to one realm; this checks, it does not select). Unset: not checked |
48
+
49
+ The names from when this server only did Content, `EBITEX_CONTENT_API_BASE` and
50
+ `EBITEX_CONTENT_MCP_READ_ONLY`, are still read. If both spellings of the base URL are set the new one
51
+ wins; if either read-only variable is set, the session is read-only.
52
+
53
+ ## Mint the key deliberately
54
+
55
+ A management key is bound to **one organization and one authoring environment**, and acts as **one
56
+ role**. That binding is the real safety boundary here, and it is the one this server cannot supply
57
+ for you:
58
+
59
+ - **Bind it to a non-production authoring environment.** This server has no way to tell which of
60
+ your environments is production — that is your own topology, and a management key deliberately
61
+ cannot see it. A heuristic would be worse than nothing, because it would be believed.
62
+ - **Leave the authoring scope off unless the agent needs to write.** Without it, the write tools are
63
+ not merely refused; they are not offered at all.
64
+ - **Give it a role with the access it needs and no more.** Branch access rules and workflow gating
65
+ apply to a key exactly as they do to a person.
66
+
67
+ On startup the server prints, to stderr, which organization and environment the key reached and
68
+ which role it acts as. Read it once; if it is not what you expected, stop.
69
+
70
+ ## Content tools
71
+
72
+ Ten, shaped around what an agent does rather than around REST routes.
73
+
74
+ | | |
75
+ |---|---|
76
+ | `content_whoami` | Where this key is scoped: organization, environment, role, scopes, this server's version, and which tools were withheld and why. Needs no scope, so a key that can do almost nothing can still ask why |
77
+ | `content_describe` | What can exist here: every field type with its **own settings schema**, plus this environment's Contracts and Templates |
78
+ | `content_find` | Locate entities by kind, search or external id, with one paging contract across both listings |
79
+ | `content_get` | Read one entity in full |
80
+ | `content_write` | Create or update one entity |
81
+ | `content_delete` | Delete one, behind an explicit confirmation |
82
+ | `content_publish` | Plan, read the blockers, then publish |
83
+ | `content_operation_status` | Poll a job |
84
+ | `content_transfer` | Move a whole model between environments, atomically. `identityMode` picks how items are matched: `externalId` (the default, by natural key), `preserve` (by id), or `fresh` (everything new) |
85
+ | `content_topology` | Where this environment sits: the delivery environments a publish lands in, and its promotion neighbours. One hop only |
86
+
87
+ Which of them appear depends on your key's scopes: a read-scoped key gets a server with no write
88
+ tools at all, rather than tools that always fail. `content_whoami` is the exception and always
89
+ appears — it reports which tools were withheld and what each would need, so an absent tool is
90
+ explained rather than merely missing.
91
+
92
+ Every result also names the organization and environment it was answered in, and an empty one says so
93
+ explicitly. A key reads and writes exactly one authoring environment, so "no Contracts" always means
94
+ "none here" — an agent that reads it as "none anywhere" creates duplicates.
95
+
96
+ ## Content: authoring is half the job
97
+
98
+ This server builds and publishes a content model. The site that **renders** it reads the Content
99
+ Delivery API, and that has its own client, [`@ebitex/content-sdk`](https://www.npmjs.com/package/@ebitex/content-sdk)
100
+ (or `Ebitex.Content.Delivery` for .NET). The server's instructions and the
101
+ `ebitex-content://help/rendering-your-site` resource tell an agent so before it writes a renderer; if
102
+ you are briefing an agent yourself, say the same.
103
+
104
+ ## Content: why it cannot drift
105
+
106
+ The Content app encodes **no knowledge of the content model**. It does not know what field types exist,
107
+ what a Contract may contain, or what makes a document valid. All three are answered at runtime:
108
+ `content_describe` returns each field type's own declared schema, and every write is validated by the
109
+ server that stores it. There is nothing here to fall out of step, because nothing is duplicated.
110
+
111
+ That also shapes how errors work. A refusal is relayed **whole**, with its field paths intact and no
112
+ summarizing, because for an agent the error is the control loop: try, read the error, fix the one
113
+ field it names, call again.
114
+
115
+ ## Content resources
116
+
117
+ Alongside the tools, the server offers the Content documentation as MCP resources — start with
118
+ `ebitex-content://help/agent-authoring`, which explains what Contracts, Templates, Presentations,
119
+ Adapters and the Experience tree are for, and the order to create them in. Then read
120
+ `ebitex-content://help/content-modelling` before you decide what the model looks like: it says what belongs in a Contract and what in a Template,
121
+ which field to use, how to name things, how to build containers such as tabs and accordions, and how to ship a model to others.
122
+
123
+ ## Embedding it
124
+
125
+ ```ts
126
+ import { buildServer, readConfig } from '@ebitex/mcp'
127
+
128
+ const { server, banner } = await buildServer({ config: readConfig() })
129
+ console.error(banner) // never stdout — on stdio, that stream is the protocol
130
+ ```
131
+
132
+ ## A note on `zod`
133
+
134
+ This package pins `zod` to `^3.25.76` rather than `^4`, even though `@modelcontextprotocol/sdk`
135
+ accepts either. The reason is type identity, not capability: the SDK's schema types are written
136
+ against whichever `zod` resolves for *it*, and a second copy at a different major produces a type
137
+ mismatch on every tool registration. Pinning to the version the SDK resolves keeps one `zod` in the
138
+ tree. This matters at build time only; at runtime the SDK handles both.
139
+
140
+ ## Licence
141
+
142
+ Apache-2.0 — © ebitex software LLC.
143
+
144
+ Full guide: [developers.ebitex.io](https://developers.ebitex.io/getting-started/content-as-code/).
package/dist/app.d.ts ADDED
@@ -0,0 +1,57 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ /**
3
+ * What one ebitex app contributes to the server.
4
+ *
5
+ * The server is one process serving every app whose key the operator configured. An app is a module
6
+ * behind this contract, and nothing in `server.ts` knows what any of them does: it asks each app
7
+ * whether it is configured, starts the ones that are, and lets each register its own tools and
8
+ * resources. Adding an app is a new module and one line in `apps/index.ts`.
9
+ *
10
+ * Each app brings its own key because the suite's management keys are different kinds, each minted
11
+ * in its own app and bound to that app's organization and scope. One key cannot stand in for
12
+ * another, so a session that should reach two apps carries two keys.
13
+ */
14
+ /** What every app is handed. */
15
+ export type AppContext = {
16
+ /** Origin only. Each app appends its own route prefix. */
17
+ baseUrl: string;
18
+ /** An operator's declaration that this session must not write, whatever its keys could do. */
19
+ readOnly: boolean;
20
+ /** The environment the server was launched with, so an app reads its own variables. */
21
+ env: Record<string, string | undefined>;
22
+ /** Substituted by tests. Defaults to the global `fetch`. */
23
+ fetchImpl?: typeof fetch;
24
+ /** Reported by an app that tells an agent which build it is talking to. */
25
+ serverVersion: string;
26
+ };
27
+ /** A started app: what it says about itself, and how it attaches to the server. */
28
+ export type StartedApp = {
29
+ /** Sentences for the server's instructions, read by an agent before its first call. */
30
+ instructions: string;
31
+ /** Lines for the operator's startup banner, naming where this app's writes will land. */
32
+ banner: string[];
33
+ /** Registers this app's tools and resources. */
34
+ register(server: McpServer): void;
35
+ };
36
+ export type McpApp = {
37
+ /** Stable lowercase id, also the prefix of every tool name the app registers. */
38
+ id: string;
39
+ /** What the app is called in prose. */
40
+ label: string;
41
+ /** The variable that holds the app's management key. */
42
+ keyVar: string;
43
+ /** Where a person mints that key, written for someone editing an MCP client's JSON. */
44
+ keyHelp: string;
45
+ /** True when this app's key is present, which is the only thing that turns an app on. */
46
+ isConfigured(env: Record<string, string | undefined>): boolean;
47
+ /** Resolves the key against the API and builds the app. Throws `StartupError` or `ConfigError`. */
48
+ start(context: AppContext): Promise<StartedApp>;
49
+ };
50
+ /**
51
+ * A failure at startup that a person can fix in a config file (a key that was refused, an API that
52
+ * could not be reached). Printed as its message alone: a stack trace would bury the one line that
53
+ * matters.
54
+ */
55
+ export declare class StartupError extends Error {
56
+ }
57
+ //# sourceMappingURL=app.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAExE;;;;;;;;;;;GAWG;AAEH,gCAAgC;AAChC,MAAM,MAAM,UAAU,GAAG;IACvB,0DAA0D;IAC1D,OAAO,EAAE,MAAM,CAAA;IACf,8FAA8F;IAC9F,QAAQ,EAAE,OAAO,CAAA;IACjB,uFAAuF;IACvF,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;IACvC,4DAA4D;IAC5D,SAAS,CAAC,EAAE,OAAO,KAAK,CAAA;IACxB,2EAA2E;IAC3E,aAAa,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,mFAAmF;AACnF,MAAM,MAAM,UAAU,GAAG;IACvB,uFAAuF;IACvF,YAAY,EAAE,MAAM,CAAA;IACpB,yFAAyF;IACzF,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,gDAAgD;IAChD,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAAA;CAClC,CAAA;AAED,MAAM,MAAM,MAAM,GAAG;IACnB,iFAAiF;IACjF,EAAE,EAAE,MAAM,CAAA;IACV,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAA;IACb,wDAAwD;IACxD,MAAM,EAAE,MAAM,CAAA;IACd,uFAAuF;IACvF,OAAO,EAAE,MAAM,CAAA;IACf,yFAAyF;IACzF,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,OAAO,CAAA;IAC9D,mGAAmG;IACnG,KAAK,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;CAChD,CAAA;AAED;;;;GAIG;AACH,qBAAa,YAAa,SAAQ,KAAK;CAAG"}
package/dist/app.js ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * A failure at startup that a person can fix in a config file (a key that was refused, an API that
3
+ * could not be reached). Printed as its message alone: a stack trace would bury the one line that
4
+ * matters.
5
+ */
6
+ export class StartupError extends Error {
7
+ }
8
+ //# sourceMappingURL=app.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAsDA;;;;GAIG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK;CAAG"}
@@ -0,0 +1,23 @@
1
+ import type { AppContext, McpApp } from '../../app.js';
2
+ import { type Session } from './session.js';
3
+ /**
4
+ * The Content app (the CMS). Everything Content-specific lives under this directory; the server
5
+ * knows it only through this one export.
6
+ *
7
+ * Nothing here decides anything — which tools exist is decided by the key's own scopes
8
+ * (`session.has`), and which routes exist is decided by `routes.ts`. This file only wires them.
9
+ */
10
+ export declare const INSTRUCTIONS: string;
11
+ export declare const contentApp: McpApp;
12
+ /**
13
+ * What the operator sees on stderr for this app.
14
+ *
15
+ * It exists for one failure, and it is not a bug in this server: a key bound to a production
16
+ * authoring environment sitting in an MCP client's config file, with an agent doing exactly what it
17
+ * was asked to. This server cannot detect that — whether an environment is "production" is the
18
+ * customer's own topology, and a management key deliberately cannot see it — so saying plainly
19
+ * where writes will land is the whole mitigation, and it is why it names the environment rather
20
+ * than only reporting that the key worked.
21
+ */
22
+ export declare function contentBanner(context: Pick<AppContext, 'readOnly'>, session: Session): string[];
23
+ //# sourceMappingURL=app.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../src/apps/content/app.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAc,MAAM,cAAc,CAAA;AAIlE,OAAO,EAAmC,KAAK,OAAO,EAAE,MAAM,cAAc,CAAA;AAG5E;;;;;;GAMG;AAEH,eAAO,MAAM,YAAY,QAuBmB,CAAA;AAE5C,eAAO,MAAM,UAAU,EAAE,MASxB,CAAA;AAyBD;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,EAAE,CAmB/F"}
@@ -0,0 +1,95 @@
1
+ import { createClient } from './client.js';
2
+ import { isContentConfigured, KEY_VAR, readContentConfig } from './config.js';
3
+ import { registerResources } from './resources/register.js';
4
+ import { resolveSession, SCOPE_AUTHORING } from './session.js';
5
+ import { registerTools } from './tools/register.js';
6
+ /**
7
+ * The Content app (the CMS). Everything Content-specific lives under this directory; the server
8
+ * knows it only through this one export.
9
+ *
10
+ * Nothing here decides anything — which tools exist is decided by the key's own scopes
11
+ * (`session.has`), and which routes exist is decided by `routes.ts`. This file only wires them.
12
+ */
13
+ export const INSTRUCTIONS = "Content is ebitex's CMS. Start with content_describe — it returns every field type with " +
14
+ 'its own settings schema and the Contracts and Templates this environment already has, ' +
15
+ 'which is where the shape of anything you write comes from. Read the ' +
16
+ 'ebitex-content://help/agent-authoring resource before building a model; it explains what ' +
17
+ 'Contracts, Templates, Presentations, Adapters and the Experience tree are for, and the ' +
18
+ 'order to create them in. Then read ebitex-content://help/content-modelling before you decide ' +
19
+ 'what the model looks like: Contracts hold editorial content only, a Template and its settings ' +
20
+ 'hold every placement and appearance choice, and a presentation field (not a component field) ' +
21
+ 'is how a page draws a section. When a write is refused, the refusal names the failing field: ' +
22
+ 'correct that one thing and call again. ' +
23
+ // It belongs here rather than only in a tool description because an agent reads instructions
24
+ // before its first call — which is before the first empty result it would otherwise misread as
25
+ // "nothing exists".
26
+ 'This key is bound to exactly one organization and one authoring environment, so every ' +
27
+ 'result is scoped to that environment: an empty list means nothing matched there, not that ' +
28
+ 'nothing exists. content_whoami reports the binding, and needs no scope. ' +
29
+ // The authoring half of this app builds the model; the half that renders it is a separate job
30
+ // with its own client. An agent that was pointed here for authoring and at the REST reference
31
+ // for rendering is never told the SDK exists, and writes a Delivery client by hand.
32
+ 'Building the site that renders this content is a separate job, and it has a client: ' +
33
+ 'install @ebitex/content-sdk (npm) or Ebitex.Content.Delivery (.NET) instead of writing a ' +
34
+ 'Delivery API client by hand. Read ebitex-content://help/rendering-your-site before you write ' +
35
+ 'any code that fetches published content.';
36
+ export const contentApp = {
37
+ id: 'content',
38
+ label: 'Content',
39
+ keyVar: KEY_VAR,
40
+ // Names the screen as the product and help/content/management-keys.md do. Plain ">" rather than an
41
+ // arrow glyph because this is written to a terminal of unknown encoding.
42
+ keyHelp: 'mint a management key under Settings > API Keys > Management keys',
43
+ isConfigured: isContentConfigured,
44
+ start: startContent,
45
+ };
46
+ async function startContent(context) {
47
+ const config = readContentConfig(context.env);
48
+ const client = createClient({ baseUrl: context.baseUrl, key: config.key, fetchImpl: context.fetchImpl });
49
+ const target = config.targetKey
50
+ ? createClient({ baseUrl: context.baseUrl, key: config.targetKey, fetchImpl: context.fetchImpl })
51
+ : null;
52
+ const session = await resolveSession(client, {
53
+ readOnlyRequested: context.readOnly,
54
+ expectedRealm: config.expectedRealm,
55
+ });
56
+ return {
57
+ instructions: INSTRUCTIONS,
58
+ banner: contentBanner(context, session),
59
+ register(server) {
60
+ registerTools(server, { client, session, target, serverVersion: context.serverVersion });
61
+ registerResources(server, { client, session });
62
+ },
63
+ };
64
+ }
65
+ /**
66
+ * What the operator sees on stderr for this app.
67
+ *
68
+ * It exists for one failure, and it is not a bug in this server: a key bound to a production
69
+ * authoring environment sitting in an MCP client's config file, with an agent doing exactly what it
70
+ * was asked to. This server cannot detect that — whether an environment is "production" is the
71
+ * customer's own topology, and a management key deliberately cannot see it — so saying plainly
72
+ * where writes will land is the whole mitigation, and it is why it names the environment rather
73
+ * than only reporting that the key worked.
74
+ */
75
+ export function contentBanner(context, session) {
76
+ const { who } = session;
77
+ const lines = [
78
+ 'Content',
79
+ ` organization ${who.organizationName ?? who.organizationId}`,
80
+ ` environment ${who.environmentName ?? who.environmentId}`,
81
+ ` acting as ${who.roleName ?? 'unknown role'} (key: ${who.keyName ?? 'unnamed'})`,
82
+ ` scopes ${who.scopes.length ? who.scopes.join(', ') : 'none'}`,
83
+ ];
84
+ if (context.readOnly) {
85
+ lines.push(' mode read-only (forced by EBITEX_MCP_READ_ONLY)');
86
+ }
87
+ else if (session.has(SCOPE_AUTHORING)) {
88
+ lines.push(` mode READ-WRITE — writes land in "${who.environmentName ?? who.environmentId}"`);
89
+ }
90
+ else {
91
+ lines.push(' mode read-only (this key carries no authoring scope)');
92
+ }
93
+ return lines;
94
+ }
95
+ //# sourceMappingURL=app.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.js","sourceRoot":"","sources":["../../../src/apps/content/app.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAsB,MAAM,aAAa,CAAA;AAC9D,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,EAAE,cAAc,EAAE,eAAe,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,CAAC,CAAA;IACzG,CAAC;SAAM,CAAC;QACN,KAAK,CAAC,IAAI,CAAC,iEAAiE,CAAC,CAAA;IAC/E,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * The HTTP client for `/content/management/v1`.
3
+ *
4
+ * Deliberately **one method per verb**, not one per endpoint. The endpoints come from
5
+ * the route table, which is the only place in this package that knows a route exists — so a newly
6
+ * reachable family is a row there rather than a method here, and there is no second list to keep in
7
+ * step with the first.
8
+ *
9
+ * It is also the only module that holds the key, and the only one that calls `fetch`. Both are
10
+ * worth keeping true: a test drives the whole server by substituting one function.
11
+ */
12
+ export declare const ROUTE_PREFIX = "/content/management/v1";
13
+ export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
14
+ export type ContentClient = {
15
+ /** Origin only, for messages that need to say where writes are landing. */
16
+ readonly baseUrl: string;
17
+ request(method: HttpMethod, path: string, body?: unknown): Promise<unknown>;
18
+ };
19
+ export type ClientOptions = {
20
+ baseUrl: string;
21
+ key: string;
22
+ /** Substituted by tests. Defaults to the global `fetch`. */
23
+ fetchImpl?: typeof fetch;
24
+ };
25
+ export declare function createClient(options: ClientOptions): ContentClient;
26
+ /**
27
+ * Builds a query string from values that may be absent, skipping the absent ones.
28
+ *
29
+ * Kept here rather than inlined because the API rejects unknown *properties* on a body but is
30
+ * ordinary about query parameters — the asymmetry is easy to forget, and sending `limit=undefined`
31
+ * as a literal string is the kind of thing that reads as an API bug for an afternoon.
32
+ */
33
+ export declare function query(params: Record<string, string | number | boolean | undefined | null>): string;
34
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/apps/content/client.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,YAAY,2BAA2B,CAAA;AAEpD,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAA;AAEpE,MAAM,MAAM,aAAa,GAAG;IAC1B,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CAC5E,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;IACX,4DAA4D;IAC5D,SAAS,CAAC,EAAE,OAAO,KAAK,CAAA;CACzB,CAAA;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,aAAa,GAAG,aAAa,CAqClE;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC,GAAG,MAAM,CASlG"}