@alonchat/mcp-server 0.1.0 → 0.3.2

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/LICENSE CHANGED
@@ -1,201 +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.
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
@@ -13,9 +13,21 @@ this package or copying an API key. See the connection guide below.
13
13
 
14
14
  ## Local STDIO server
15
15
 
16
- Set `ALONCHAT_API_KEY`, then run:
16
+ STDIO means standard input/output: the AI client starts this package as a local child process and
17
+ communicates through process pipes. It is useful for development and unattended API-key setups;
18
+ hosted OAuth remains the normal interactive connection.
19
+
20
+ First save a verified CLI profile, then run:
21
+
22
+ ```bash
23
+ npx -y @alonchat/cli auth login --profile work
24
+ npx -y @alonchat/mcp-server --profile work
25
+ ```
26
+
27
+ An environment-only CI setup also works:
17
28
 
18
29
  ```bash
30
+ export ALONCHAT_API_KEY=sk-your-key
19
31
  npx -y @alonchat/mcp-server
20
32
  ```
21
33
 
@@ -25,12 +37,21 @@ Example Codex configuration:
25
37
  [mcp_servers.alonchat]
26
38
  command = "npx"
27
39
  args = ["-y", "@alonchat/mcp-server"]
28
- env_vars = ["ALONCHAT_API_KEY"]
29
40
  ```
30
41
 
42
+ Add `env_vars = ["ALONCHAT_API_KEY"]` when the MCP client should use an environment key instead of
43
+ the saved default profile. Explicit `--profile NAME` selects that saved profile.
44
+
31
45
  The server exposes `chat_with_agent` plus any additional tools allowed by the connected project key.
32
46
  Reuse the returned conversation ID to continue a thread.
33
47
 
48
+ Tool failures set `isError: true`. Operation failures retain their structured receipt when one is
49
+ available. API failures without a receipt, including chat failures, expose a structured `error` with
50
+ `code`, `message`, HTTP `status`, and `retryable`; request IDs, retry delays, and resolution
51
+ instructions are included when supplied by the API. Arbitrary error details are not forwarded. An
52
+ `OUTCOME_UNCERTAIN` result is not permission to repeat the action with a new idempotency key:
53
+ reconcile the earlier outcome before retrying the same consequential turn.
54
+
34
55
  Read-only billing tools include `get_subscription`, `get_usage`, `list_plans`, and `list_invoices`.
35
56
  Usage and invoices require `billing_read`. These tools cannot charge a card, change a plan, or
36
57
  cancel a subscription.
@@ -39,10 +60,26 @@ With explicit `read_conversations`, `agent_design_read`, and `agent_design_write
39
60
  server also exposes setup inspection, bounded production transcript reads, deterministic design
40
61
  validation, and review-gated agent-design drafts. Drafting does not publish live changes.
41
62
 
42
- API keys are server-side credentials. Keep them in the MCP client's environment or secret store.
63
+ API keys are server-side credentials. Keep them in the CLI profile, MCP client's secret store, or
64
+ environment. Never place them in client-visible configuration or source control.
43
65
 
44
66
  [MCP connection guide](https://alonchat.com/docs/developer/mcp)
45
67
  [Agent workbench guide](https://alonchat.com/docs/developer/agent-workbench)
46
68
 
47
69
  Licensed under Apache-2.0. The MCP server is a thin protocol adapter; the AlonChat application and
48
70
  hosted agent runtime remain proprietary.
71
+
72
+ ## Discovery and authority
73
+
74
+ | Connection | Runs where | Authentication |
75
+ | ------------------ | -------------------------------- | --------------------------------------- |
76
+ | Hosted `/api/mcp` | AlonChat service | Account-linked OAuth grant |
77
+ | This STDIO package | MCP client's local child process | Verified CLI profile or project API key |
78
+
79
+ Both project the governed operation catalog. Tools are filtered by principal, project/agent scope
80
+ and declared MCP exposure. Tool availability, MCP annotations and client confirmation do not
81
+ override server permissions, approval or verified readback.
82
+
83
+ A tool may return accepted background work or a pending approval. Show that receipt as pending until
84
+ its durable outcome is read back. A completed upload transfer is separate from source training or
85
+ structured import completion.
package/dist/index.js CHANGED
@@ -1,17 +1,38 @@
1
1
  #!/usr/bin/env node
2
2
  import { AlonChatClient } from '@alonchat/sdk';
3
+ import { resolveAlonChatCredential } from '@alonchat/sdk/node-credentials';
3
4
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
- import { createAlonChatMcpServer } from './server.js';
5
- const apiKey = process.env.ALONCHAT_API_KEY;
6
- if (!apiKey) {
7
- process.stderr.write('ALONCHAT_API_KEY is required\n');
8
- process.exit(1);
5
+ import { createAlonChatMcpServer, formatMcpStartupError } from './server.js';
6
+ function option(args, name) {
7
+ const index = args.indexOf(name);
8
+ if (index === -1)
9
+ return undefined;
10
+ const value = args[index + 1];
11
+ if (!value || value.startsWith('--'))
12
+ throw new Error(`${name} requires a value`);
13
+ return value;
14
+ }
15
+ async function main() {
16
+ const credential = await resolveAlonChatCredential({
17
+ profile: option(process.argv.slice(2), '--profile'),
18
+ baseUrl: option(process.argv.slice(2), '--base-url'),
19
+ });
20
+ const client = new AlonChatClient({
21
+ apiKey: credential.apiKey,
22
+ baseUrl: credential.baseUrl,
23
+ surface: 'mcp',
24
+ });
25
+ const discovery = await client.discoverOperationsResult();
26
+ await createAlonChatMcpServer(client, discovery.operations, {
27
+ includeChat: discovery.capabilities.chat,
28
+ }).connect(new StdioServerTransport());
29
+ }
30
+ try {
31
+ await main();
32
+ }
33
+ catch (error) {
34
+ const failure = formatMcpStartupError(error);
35
+ process.stderr.write(`${failure.message}\n`);
36
+ process.exit(failure.exitCode);
9
37
  }
10
- const client = new AlonChatClient({
11
- apiKey,
12
- baseUrl: process.env.ALONCHAT_BASE_URL,
13
- surface: 'mcp',
14
- });
15
- const availableOperations = await client.discoverOperations();
16
- await createAlonChatMcpServer(client, availableOperations).connect(new StdioServerTransport());
17
38
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAErD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAA;AAC3C,IAAI,CAAC,MAAM,EAAE,CAAC;IACZ,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAA;IACtD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC;AAED,MAAM,MAAM,GAAG,IAAI,cAAc,CAAC;IAChC,MAAM;IACN,OAAO,EAA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IAAI,cAAc,CAAC;QAChC,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,OAAO,EAAE,KAAK;KACf,CAAC,CAAA;IACF,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,wBAAwB,EAAE,CAAA;IACzD,MAAM,uBAAuB,CAAC,MAAM,EAAE,SAAS,CAAC,UAAU,EAAE;QAC1D,WAAW,EAAE,SAAS,CAAC,YAAY,CAAC,IAAI;KACzC,CAAC,CAAC,OAAO,CAAC,IAAI,oBAAoB,EAAE,CAAC,CAAA;AACxC,CAAC;AAED,IAAI,CAAC;IACH,MAAM,IAAI,EAAE,CAAA;AACd,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IACf,MAAM,OAAO,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAA;IAC5C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,OAAO,IAAI,CAAC,CAAA;IAC5C,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;AAChC,CAAC"}
package/dist/server.d.ts CHANGED
@@ -12,6 +12,11 @@ export interface AlonChatMcpServerOptions {
12
12
  includeChat?: boolean;
13
13
  instructions?: string;
14
14
  }
15
+ export declare function formatMcpStartupError(error: unknown): {
16
+ message: string;
17
+ exitCode: number;
18
+ };
19
+ export declare function buildMcpInstructions(discoveredOperations: readonly DiscoverableOperation[], options?: Pick<AlonChatMcpServerOptions, 'includeChat'>): string;
15
20
  export declare function createAlonChatMcpServer(client: McpOperationClient, discoveredOperations: readonly DiscoverableOperation[], options?: AlonChatMcpServerOptions): McpServer;
16
21
  export {};
17
22
  //# sourceMappingURL=server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,EAEL,KAAK,YA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AAS,CAAA;KAAE,GAChD,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAA;IACpC,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;CAC5D;AAED,MAAM,WAAW,wBAAwB;IACvC,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAa3F;AAED,wBAAgB,oBAAoB,CAClC,oBAAoB,EAAE,SAAS,qBAAqB,EAAE,EACtD,OAAO,GAAE,IAAI,CAAC,wBAAwB,EAAE,aAAa,CAAM,GAC1D,MAAM,CAkER;AAwFD,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,kBAAkB,EAC1B,oBAAoB,EAAE,SAAS,qBAAqB,EAAE,EACtD,OAAO,GAAE,wBAA6B,GACrC,SAAS,CA4JX"}
package/dist/server.js CHANGED
@@ -1,23 +1,130 @@
1
- import { PLATFORM_OPERATION_BY_ID } from '@alonchat/contracts';
1
+ import { PLATFORM_OPERATION_BY_ID, PLATFORM_PACKAGE_VERSION } from '@alonchat/contracts';
2
+ import { parsePublicChatInteraction, publicChatInteractionJsonSchema, } from '@alonchat/contracts/chat-presentation';
2
3
  import { AlonChatApiError, } from '@alonchat/sdk';
3
4
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
4
5
  import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
6
+ export function formatMcpStartupError(error) {
7
+ if (!(error instanceof AlonChatApiError)) {
8
+ const message = error instanceof Error ? error.message : String(error);
9
+ return { message: `AlonChat MCP startup failed: ${message}`, exitCode: 1 };
10
+ }
11
+ const request = error.requestId ? ` (request ${error.requestId})` : '';
12
+ const retry = error.retryAfterSeconds === undefined ? '' : ` Retry after ${error.retryAfterSeconds} seconds.`;
13
+ return {
14
+ message: `AlonChat MCP startup failed [${error.code}]: ${error.message}${request}${retry}`,
15
+ exitCode: error.retryable ? 75 : 1,
16
+ };
17
+ }
18
+ export function buildMcpInstructions(discoveredOperations, options = {}) {
19
+ const includeChat = options.includeChat ?? false;
20
+ const toolNames = discoveredOperations.flatMap(operation => operation.bindings.mcp?.toolName ? [operation.bindings.mcp.toolName] : []);
21
+ const tools = [...(includeChat ? ['chat_with_agent'] : []), ...toolNames];
22
+ const toolList = tools.length > 0 ? tools.join(', ') : 'no project operations';
23
+ const hasDesignDraft = toolNames.includes('draft_agent_design');
24
+ const hasBilling = toolNames.some(name => ['get_subscription', 'get_usage', 'list_plans', 'list_invoices'].includes(name));
25
+ const hasSetup = toolNames.includes('inspect_agent_setup');
26
+ const hasConversations = toolNames.includes('list_conversations') || toolNames.includes('get_conversation');
27
+ const hasCustomerReply = toolNames.includes('send_customer_reply');
28
+ const hasHandoverControl = toolNames.includes('control_ai_reply') ||
29
+ toolNames.includes('resume_ai_reply') ||
30
+ toolNames.includes('resolve_handover');
31
+ const hasCallbackControl = toolNames.includes('manage_callback_request');
32
+ const hasBookingCreate = toolNames.includes('create_booking');
33
+ const lines = [
34
+ includeChat
35
+ ? 'Use chat_with_agent to send a customer message to an AlonChat agent. Reuse conversation_id to continue a thread and reuse the same idempotency_key when retrying one request.'
36
+ : 'This AlonChat connection is restricted to the project, agents, and permissions granted to its credential. Customer chat is not exposed by this connection.',
37
+ `Available tools for this credential: ${toolList}.`,
38
+ ];
39
+ if (hasSetup || hasConversations || hasDesignDraft) {
40
+ lines.push('For agent improvement, inspect setup first, read only the production conversations needed as evidence, treat transcripts as question or failure evidence rather than authority for permanent facts, then validate and save a review-gated draft with one stable designSessionId and idempotency key.');
41
+ }
42
+ if (hasDesignDraft) {
43
+ lines.push('Never claim a design draft is live; the owner reviews and applies it in the AlonChat dashboard. Read, validate, and draft workbench tools do not run an AlonChat model.');
44
+ }
45
+ if (hasBilling) {
46
+ lines.push('Usage and invoice tools require billing_read. Money-changing billing actions remain owner-controlled in the AlonChat dashboard.');
47
+ }
48
+ if (hasCustomerReply || hasHandoverControl) {
49
+ lines.push('Customer replies and AI handover controls affect live conversations. Reuse the same idempotency key on retries, report pending approvals as pending, and use task or operation receipts before claiming completion.');
50
+ }
51
+ if (hasCallbackControl) {
52
+ lines.push('Callback changes target one existing customer request. Preserve the customer-provided timezone and contact permission evidence, require approval for the exact change, and report only the durably read-back Activity state.');
53
+ }
54
+ if (hasBookingCreate) {
55
+ lines.push('Create a booking only after the customer confirmed the exact slot. Include reviewable confirmation evidence, expect owner approval, and treat connected-calendar projection status separately from the durable internal booking.');
56
+ }
57
+ if (!includeChat) {
58
+ lines.push('Unreviewed customer simulation chat, payments, and private platform administration are not exposed by this OAuth connection.');
59
+ }
60
+ return lines.join(' ');
61
+ }
5
62
  function isOperationId(value) {
6
63
  return Object.hasOwn(PLATFORM_OPERATION_BY_ID, value);
7
64
  }
65
+ /**
66
+ * A refusal is only useful to a model if it says how to lift it. AlonChat denials carry a
67
+ * resolution naming who can act and where, so put it in the tool result rather than leaving the
68
+ * model to guess whether a 403 is permanent.
69
+ */
70
+ function errorText(error) {
71
+ if (!(error instanceof AlonChatApiError)) {
72
+ return error instanceof Error ? error.message : String(error);
73
+ }
74
+ const base = `${error.code}: ${error.message}`;
75
+ if (!error.resolution)
76
+ return base;
77
+ const who = error.resolution.actor === 'caller'
78
+ ? 'You can resolve this'
79
+ : error.resolution.actor === 'project_owner'
80
+ ? 'A project owner must resolve this'
81
+ : 'The credential owner must resolve this';
82
+ const where = error.resolution.url ? ` (${error.resolution.url})` : '';
83
+ return `${base}\n\n${who}: ${error.resolution.summary}${where}`;
84
+ }
85
+ function toolErrorResult(error) {
86
+ return {
87
+ isError: true,
88
+ content: [{ type: 'text', text: errorText(error) }],
89
+ ...(error instanceof AlonChatApiError
90
+ ? {
91
+ structuredContent: error.receipt
92
+ ? { receipt: error.receipt }
93
+ : {
94
+ error: {
95
+ code: error.code,
96
+ message: error.message,
97
+ status: error.status,
98
+ retryable: error.retryable,
99
+ ...(error.requestId ? { requestId: error.requestId } : {}),
100
+ ...(error.retryAfterSeconds !== undefined
101
+ ? { retryAfterSeconds: error.retryAfterSeconds }
102
+ : {}),
103
+ ...(error.resolution ? { resolution: error.resolution } : {}),
104
+ },
105
+ },
106
+ }
107
+ : {}),
108
+ };
109
+ }
8
110
  function mcpInputSchema(operation) {
111
+ // MCP tools always take one JSON object. JSON Schema permits a root `anyOf` whose
112
+ // branches are objects, but the MCP protocol schema (and standards-strict clients)
113
+ // still requires the advertised root type to be `object`.
114
+ const objectInputSchema = {
115
+ ...operation.inputSchema,
116
+ type: 'object',
117
+ };
9
118
  if (operation.kind !== 'command')
10
- return operation.inputSchema;
11
- const properties = typeof operation.inputSchema.properties === 'object' &&
12
- operation.inputSchema.properties !== null
13
- ? operation.inputSchema.properties
119
+ return objectInputSchema;
120
+ const properties = typeof objectInputSchema.properties === 'object' && objectInputSchema.properties !== null
121
+ ? objectInputSchema.properties
14
122
  : {};
15
- const required = Array.isArray(operation.inputSchema.required)
16
- ? operation.inputSchema.required.filter((value) => typeof value === 'string')
123
+ const required = Array.isArray(objectInputSchema.required)
124
+ ? objectInputSchema.required.filter((value) => typeof value === 'string')
17
125
  : [];
18
126
  return {
19
- ...operation.inputSchema,
20
- type: 'object',
127
+ ...objectInputSchema,
21
128
  properties: {
22
129
  ...properties,
23
130
  _alonchatIdempotencyKey: {
@@ -31,17 +138,12 @@ function mcpInputSchema(operation) {
31
138
  };
32
139
  }
33
140
  export function createAlonChatMcpServer(client, discoveredOperations, options = {}) {
34
- const includeChat = options.includeChat ?? true;
35
- const server = new McpServer({ name: 'alonchat', version: '0.1.0' }, {
36
- instructions: options.instructions ??
37
- (includeChat
38
- ? 'Use chat_with_agent to send a customer message to an AlonChat agent. Reuse conversation_id to continue a thread and reuse the same idempotency_key when retrying one request. For agent improvement, inspect setup first, read only needed production conversations, treat transcripts as question/failure evidence rather than authority for permanent facts, validate the complete design, then save a review-gated draft with one stable designSessionId and idempotency key. Never claim a design draft is live; the owner reviews and applies it in AlonChat. Read, validate, and draft workbench tools do not run an AlonChat model. Usage and invoice tools require billing_read. Money-changing billing actions remain owner-controlled in the AlonChat dashboard.'
39
- : 'This account-linked AlonChat connection is restricted to the project, agents, and permissions approved by the signed-in user. Inspect setup first, read only the production conversations needed as evidence, treat transcripts as question or failure evidence rather than authority for permanent facts, validate the complete design, then save a review-gated draft with one stable designSessionId and idempotency key. Never claim a design draft is live; the owner reviews and applies it in AlonChat. Billing tools are read-only. Publishing, payments, private platform administration, and customer chat are not exposed by this OAuth connection.'),
141
+ const includeChat = options.includeChat ?? false;
142
+ const server = new McpServer({ name: 'alonchat', version: PLATFORM_PACKAGE_VERSION }, {
143
+ instructions: options.instructions ?? buildMcpInstructions(discoveredOperations, { includeChat }),
40
144
  });
41
145
  const operationTools = discoveredOperations
42
- .filter(operation => operation.bindings.mcp !== undefined &&
43
- operation.bindings.api !== undefined &&
44
- isOperationId(operation.id))
146
+ .filter(operation => operation.bindings.mcp !== undefined && isOperationId(operation.id))
45
147
  .map(operation => ({
46
148
  operation,
47
149
  tool: {
@@ -61,10 +163,11 @@ export function createAlonChatMcpServer(client, discoveredOperations, options =
61
163
  const chatTool = {
62
164
  name: 'chat_with_agent',
63
165
  title: 'Chat with an AlonChat agent',
64
- description: 'Send one customer message to an AlonChat agent and receive its reply. The agent may use the tools and procedures configured by its owner.',
166
+ description: 'Send a customer message using API chat. Published Workflows may return ordered presentation and buttons. Select only a returned control, copying its payload and the latest presentation.workflow runId/nodeId into interaction; reuse conversation_id. Forms collect answers conversationally. Custom widgets use conversational fallback on API chat; interactive custom-widget rendering requires the web widget and is not verified by this tool. API scheduled followups, wait nodes, and inline form submission are not supported yet. Reuse the same idempotency key only for the exact same turn.',
65
167
  inputSchema: {
66
168
  type: 'object',
67
169
  properties: {
170
+ interaction: publicChatInteractionJsonSchema,
68
171
  agent_id: {
69
172
  type: 'string',
70
173
  minLength: 1,
@@ -88,7 +191,7 @@ export function createAlonChatMcpServer(client, discoveredOperations, options =
88
191
  description: 'Stable key to reuse when retrying the same message.',
89
192
  },
90
193
  },
91
- required: ['agent_id', 'message'],
194
+ required: ['agent_id', 'message', 'idempotency_key'],
92
195
  additionalProperties: false,
93
196
  },
94
197
  annotations: {
@@ -105,13 +208,17 @@ export function createAlonChatMcpServer(client, discoveredOperations, options =
105
208
  server.server.setRequestHandler(CallToolRequestSchema, async (request) => {
106
209
  if (includeChat && request.params.name === chatTool.name) {
107
210
  const args = request.params.arguments ?? {};
108
- if (typeof args.agent_id !== 'string' || typeof args.message !== 'string') {
211
+ if (typeof args.agent_id !== 'string' ||
212
+ typeof args.message !== 'string' ||
213
+ typeof args.idempotency_key !== 'string' ||
214
+ args.idempotency_key.length < 1 ||
215
+ args.idempotency_key.length > 255) {
109
216
  return {
110
217
  isError: true,
111
218
  content: [
112
219
  {
113
220
  type: 'text',
114
- text: 'chat_with_agent requires agent_id and message.',
221
+ text: 'chat_with_agent requires agent_id, message, and a 1-255 character idempotency_key.',
115
222
  },
116
223
  ],
117
224
  };
@@ -120,33 +227,35 @@ export function createAlonChatMcpServer(client, discoveredOperations, options =
120
227
  const result = await client.sendMessage({
121
228
  agentId: args.agent_id,
122
229
  message: args.message,
230
+ ...(args.interaction !== undefined
231
+ ? { interaction: parsePublicChatInteraction(args.interaction) }
232
+ : {}),
123
233
  ...(typeof args.conversation_id === 'string'
124
234
  ? { conversationId: args.conversation_id }
125
235
  : {}),
126
- ...(typeof args.idempotency_key === 'string'
127
- ? { idempotencyKey: args.idempotency_key }
128
- : {}),
236
+ idempotencyKey: args.idempotency_key,
129
237
  });
130
238
  return {
131
- content: [{ type: 'text', text: result.response }],
239
+ content: [
240
+ {
241
+ type: 'text',
242
+ text: result.customerMessage
243
+ ? 'Customer message accepted for staff; no AI response was generated for this message.'
244
+ : result.response,
245
+ },
246
+ ],
132
247
  structuredContent: {
133
248
  response: result.response,
134
249
  conversation_id: result.conversationId,
135
250
  credits_used: result.creditsUsed,
136
251
  credits_remaining: result.creditsRemaining,
252
+ ...(result.customerMessage ? { customer_message: result.customerMessage } : {}),
253
+ ...(result.presentation ? { presentation: result.presentation } : {}),
137
254
  },
138
255
  };
139
256
  }
140
257
  catch (error) {
141
- const message = error instanceof AlonChatApiError
142
- ? `${error.code}: ${error.message}`
143
- : error instanceof Error
144
- ? error.message
145
- : String(error);
146
- return {
147
- isError: true,
148
- content: [{ type: 'text', text: message }],
149
- };
258
+ return toolErrorResult(error);
150
259
  }
151
260
  }
152
261
  const operation = operationByTool.get(request.params.name);
@@ -169,15 +278,7 @@ export function createAlonChatMcpServer(client, discoveredOperations, options =
169
278
  };
170
279
  }
171
280
  catch (error) {
172
- const message = error instanceof AlonChatApiError
173
- ? `${error.code}: ${error.message}`
174
- : error instanceof Error
175
- ? error.message
176
- : String(error);
177
- return {
178
- isError: true,
179
- content: [{ type: 'text', text: message }],
180
- };
281
+ return toolErrorResult(error);
181
282
  }
182
283
  });
183
284
  return server;
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,EACL,gBAAgB,GAKjB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACnE,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAA;AAkBlG,SAAS,aAAa,CAAC,KAAa;IAClC,OAAO,MAAM,CAAC,MAAM,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAA;AACvD,CAAC;AAED,SAAS,cAAc,CAAC,SAAgC;IACtD,IAAI,SAAS,CAAC,IAAI,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC,WAAW,CAAA;IAE9D,MAAM,UAAU,GACd,OAAO,SAAS,CAAC,WAAW,CA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AAO,eAAe,CAAC,KAAK,CAAC,CAAA;QAC/B,CAAC;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alonchat/mcp-server",
3
- "version": "0.1.0",
3
+ "version": "0.3.2",
4
4
  "description": "Model Context Protocol server for connecting AI clients to AlonChat agents.",
5
5
  "keywords": [
6
6
  "alonchat",
@@ -41,9 +41,9 @@
41
41
  "dev": "node ../../node_modules/tsx/dist/cli.mjs src/index.ts"
42
42
  },
43
43
  "dependencies": {
44
- "@alonchat/contracts": "0.1.0",
45
- "@alonchat/sdk": "0.1.0",
46
- "@modelcontextprotocol/sdk": "1.30.0",
44
+ "@alonchat/contracts": "0.3.2",
45
+ "@alonchat/sdk": "0.3.2",
46
+ "@modelcontextprotocol/sdk": "1.32.1",
47
47
  "zod": "^3.25.76"
48
48
  },
49
49
  "engines": {