@twojestarerpg/campaignmap-mcp 0.0.0-stage → 0.1.0

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 twojestarerpg
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,35 @@
1
- # Temporary Holding Version
1
+ # @twojestarerpg/campaignmap-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
+ MCP server that lets your AI assistant (OpenCode, Claude Desktop, Claude Code, Cursor, ...) read and edit **your** maps and campaigns on <https://maps.twojestarerpg.pl>. You sign in with your normal site account; the assistant can only touch what your account can.
4
+
5
+ Requires Node.js 22 or newer.
6
+
7
+ ## 1. Sign in (once)
8
+
9
+ ```
10
+ npx -y @twojestarerpg/campaignmap-mcp login
11
+ ```
12
+
13
+ Enter your site e-mail and password. The password is never stored; only a renewable session token is kept in `~/.campaignmap/session.json`. `npx -y @twojestarerpg/campaignmap-mcp logout` revokes it.
14
+
15
+ ## 2. Add it to your AI client
16
+
17
+ Command: `npx -y @twojestarerpg/campaignmap-mcp`
18
+
19
+ - **OpenCode** (`opencode.json`):
20
+ ```json
21
+ { "mcp": { "campaignmap": { "type": "local", "command": ["npx", "-y", "@twojestarerpg/campaignmap-mcp"], "enabled": true } } }
22
+ ```
23
+ - **Claude Desktop / Cursor** (`mcpServers`):
24
+ ```json
25
+ { "mcpServers": { "campaignmap": { "command": "npx", "args": ["-y", "@twojestarerpg/campaignmap-mcp"] } } }
26
+ ```
27
+ - **Claude Code:** `claude mcp add campaignmap -- npx -y @twojestarerpg/campaignmap-mcp`
28
+
29
+ No npm? Download `campaignmap-mcp.mjs` from the GitHub release and use `node /path/to/campaignmap-mcp.mjs` as the command (and for `login`).
30
+
31
+ Deleting needs a human confirmation on a terminal, so clients without one cannot delete (use the website). Full guide and troubleshooting: `docs/MCP.md` in the repository.
32
+
33
+ ## License
34
+
35
+ MIT - see `LICENSE`. Bundled third-party code: `THIRD-PARTY-NOTICES.txt`.
@@ -0,0 +1,477 @@
1
+ THIRD-PARTY NOTICES
2
+
3
+ campaignmap-mcp (MIT) bundles the following third-party packages. Their licences follow.
4
+
5
+ ==============================================================================
6
+ @modelcontextprotocol/core@2.4.0
7
+ License: Apache-2.0
8
+ Source: https://modelcontextprotocol.io
9
+
10
+ --- LICENSE ---
11
+ The MCP project is undergoing a licensing transition from the MIT License to the Apache License, Version 2.0 ("Apache-2.0"). All new code and specification contributions to the project are licensed under Apache-2.0. Documentation contributions (excluding specifications) are licensed under CC-BY-4.0.
12
+
13
+ Contributions for which relicensing consent has been obtained are licensed under Apache-2.0. Contributions made by authors who originally licensed their work under the MIT License and who have not yet granted explicit permission to relicense remain licensed under the MIT License.
14
+
15
+ No rights beyond those granted by the applicable original license are conveyed for such contributions.
16
+
17
+ ---
18
+
19
+ Apache License
20
+ Version 2.0, January 2004
21
+ http://www.apache.org/licenses/
22
+
23
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
24
+
25
+ 1. Definitions.
26
+
27
+ "License" shall mean the terms and conditions for use, reproduction,
28
+ and distribution as defined by Sections 1 through 9 of this document.
29
+
30
+ "Licensor" shall mean the copyright owner or entity authorized by
31
+ the copyright owner that is granting the License.
32
+
33
+ "Legal Entity" shall mean the union of the acting entity and all
34
+ other entities that control, are controlled by, or are under common
35
+ control with that entity. For the purposes of this definition,
36
+ "control" means (i) the power, direct or indirect, to cause the
37
+ direction or management of such entity, whether by contract or
38
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
39
+ outstanding shares, or (iii) beneficial ownership of such entity.
40
+
41
+ "You" (or "Your") shall mean an individual or Legal Entity
42
+ exercising permissions granted by this License.
43
+
44
+ "Source" form shall mean the preferred form for making modifications,
45
+ including but not limited to software source code, documentation
46
+ source, and configuration files.
47
+
48
+ "Object" form shall mean any form resulting from mechanical
49
+ transformation or translation of a Source form, including but
50
+ not limited to compiled object code, generated documentation,
51
+ and conversions to other media types.
52
+
53
+ "Work" shall mean the work of authorship, whether in Source or
54
+ Object form, made available under the License, as indicated by a
55
+ copyright notice that is included in or attached to the work
56
+ (an example is provided in the Appendix below).
57
+
58
+ "Derivative Works" shall mean any work, whether in Source or Object
59
+ form, that is based on (or derived from) the Work and for which the
60
+ editorial revisions, annotations, elaborations, or other modifications
61
+ represent, as a whole, an original work of authorship. For the purposes
62
+ of this License, Derivative Works shall not include works that remain
63
+ separable from, or merely link (or bind by name) to the interfaces of,
64
+ the Work and Derivative Works thereof.
65
+
66
+ "Contribution" shall mean any work of authorship, including
67
+ the original version of the Work and any modifications or additions
68
+ to that Work or Derivative Works thereof, that is intentionally
69
+ submitted to the Licensor for inclusion in the Work by the copyright
70
+ owner or by an individual or Legal Entity authorized to submit on behalf
71
+ of the copyright owner. For the purposes of this definition, "submitted"
72
+ means any form of electronic, verbal, or written communication sent
73
+ to the Licensor or its representatives, including but not limited to
74
+ communication on electronic mailing lists, source code control systems,
75
+ and issue tracking systems that are managed by, or on behalf of, the
76
+ Licensor for the purpose of discussing and improving the Work, but
77
+ excluding communication that is conspicuously marked or otherwise
78
+ designated in writing by the copyright owner as "Not a Contribution."
79
+
80
+ "Contributor" shall mean Licensor and any individual or Legal Entity
81
+ on behalf of whom a Contribution has been received by Licensor and
82
+ subsequently incorporated within the Work.
83
+
84
+ 2. Grant of Copyright License. Subject to the terms and conditions of
85
+ this License, each Contributor hereby grants to You a perpetual,
86
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
87
+ copyright license to reproduce, prepare Derivative Works of,
88
+ publicly display, publicly perform, sublicense, and distribute the
89
+ Work and such Derivative Works in Source or Object form.
90
+
91
+ 3. Grant of Patent License. Subject to the terms and conditions of
92
+ this License, each Contributor hereby grants to You a perpetual,
93
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
94
+ (except as stated in this section) patent license to make, have made,
95
+ use, offer to sell, sell, import, and otherwise transfer the Work,
96
+ where such license applies only to those patent claims licensable
97
+ by such Contributor that are necessarily infringed by their
98
+ Contribution(s) alone or by combination of their Contribution(s)
99
+ with the Work to which such Contribution(s) was submitted. If You
100
+ institute patent litigation against any entity (including a
101
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
102
+ or a Contribution incorporated within the Work constitutes direct
103
+ or contributory patent infringement, then any patent licenses
104
+ granted to You under this License for that Work shall terminate
105
+ as of the date such litigation is filed.
106
+
107
+ 4. Redistribution. You may reproduce and distribute copies of the
108
+ Work or Derivative Works thereof in any medium, with or without
109
+ modifications, and in Source or Object form, provided that You
110
+ meet the following conditions:
111
+
112
+ (a) You must give any other recipients of the Work or
113
+ Derivative Works a copy of this License; and
114
+
115
+ (b) You must cause any modified files to carry prominent notices
116
+ stating that You changed the files; and
117
+
118
+ (c) You must retain, in the Source form of any Derivative Works
119
+ that You distribute, all copyright, patent, trademark, and
120
+ attribution notices from the Source form of the Work,
121
+ excluding those notices that do not pertain to any part of
122
+ the Derivative Works; and
123
+
124
+ (d) If the Work includes a "NOTICE" text file as part of its
125
+ distribution, then any Derivative Works that You distribute must
126
+ include a readable copy of the attribution notices contained
127
+ within such NOTICE file, excluding those notices that do not
128
+ pertain to any part of the Derivative Works, in at least one
129
+ of the following places: within a NOTICE text file distributed
130
+ as part of the Derivative Works; within the Source form or
131
+ documentation, if provided along with the Derivative Works; or,
132
+ within a display generated by the Derivative Works, if and
133
+ wherever such third-party notices normally appear. The contents
134
+ of the NOTICE file are for informational purposes only and
135
+ do not modify the License. You may add Your own attribution
136
+ notices within Derivative Works that You distribute, alongside
137
+ or as an addendum to the NOTICE text from the Work, provided
138
+ that such additional attribution notices cannot be construed
139
+ as modifying the License.
140
+
141
+ You may add Your own copyright statement to Your modifications and
142
+ may provide additional or different license terms and conditions
143
+ for use, reproduction, or distribution of Your modifications, or
144
+ for any such Derivative Works as a whole, provided Your use,
145
+ reproduction, and distribution of the Work otherwise complies with
146
+ the conditions stated in this License.
147
+
148
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
149
+ any Contribution intentionally submitted for inclusion in the Work
150
+ by You to the Licensor shall be under the terms and conditions of
151
+ this License, without any additional terms or conditions.
152
+ Notwithstanding the above, nothing herein shall supersede or modify
153
+ the terms of any separate license agreement you may have executed
154
+ with Licensor regarding such Contributions.
155
+
156
+ 6. Trademarks. This License does not grant permission to use the trade
157
+ names, trademarks, service marks, or product names of the Licensor,
158
+ except as required for reasonable and customary use in describing the
159
+ origin of the Work and reproducing the content of the NOTICE file.
160
+
161
+ 7. Disclaimer of Warranty. Unless required by applicable law or
162
+ agreed to in writing, Licensor provides the Work (and each
163
+ Contributor provides its Contributions) on an "AS IS" BASIS,
164
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
165
+ implied, including, without limitation, any warranties or conditions
166
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
167
+ PARTICULAR PURPOSE. You are solely responsible for determining the
168
+ appropriateness of using or redistributing the Work and assume any
169
+ risks associated with Your exercise of permissions under this License.
170
+
171
+ 8. Limitation of Liability. In no event and under no legal theory,
172
+ whether in tort (including negligence), contract, or otherwise,
173
+ unless required by applicable law (such as deliberate and grossly
174
+ negligent acts) or agreed to in writing, shall any Contributor be
175
+ liable to You for damages, including any direct, indirect, special,
176
+ incidental, or consequential damages of any character arising as a
177
+ result of this License or out of the use or inability to use the
178
+ Work (including but not limited to damages for loss of goodwill,
179
+ work stoppage, computer failure or malfunction, or any and all
180
+ other commercial damages or losses), even if such Contributor
181
+ has been advised of the possibility of such damages.
182
+
183
+ 9. Accepting Warranty or Additional Liability. While redistributing
184
+ the Work or Derivative Works thereof, You may choose to offer,
185
+ and charge a fee for, acceptance of support, warranty, indemnity,
186
+ or other liability obligations and/or rights consistent with this
187
+ License. However, in accepting such obligations, You may act only
188
+ on Your own behalf and on Your sole responsibility, not on behalf
189
+ of any other Contributor, and only if You agree to indemnify,
190
+ defend, and hold each Contributor harmless for any liability
191
+ incurred by, or claims asserted against, such Contributor by reason
192
+ of your accepting any such warranty or additional liability.
193
+
194
+ END OF TERMS AND CONDITIONS
195
+
196
+ ---
197
+
198
+ MIT License
199
+
200
+ Copyright (c) 2024-2025 Model Context Protocol a Series of LF Projects, LLC.
201
+
202
+ Permission is hereby granted, free of charge, to any person obtaining a copy
203
+ of this software and associated documentation files (the "Software"), to deal
204
+ in the Software without restriction, including without limitation the rights
205
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
206
+ copies of the Software, and to permit persons to whom the Software is
207
+ furnished to do so, subject to the following conditions:
208
+
209
+ The above copyright notice and this permission notice shall be included in all
210
+ copies or substantial portions of the Software.
211
+
212
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
213
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
214
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
215
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
216
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
217
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
218
+ SOFTWARE.
219
+
220
+ ---
221
+
222
+ Creative Commons Attribution 4.0 International (CC-BY-4.0)
223
+
224
+ Documentation in this project (excluding specifications) is licensed under
225
+ CC-BY-4.0. See https://creativecommons.org/licenses/by/4.0/legalcode for
226
+ the full license text.
227
+
228
+ ==============================================================================
229
+ @modelcontextprotocol/server@2.4.0
230
+ License: Apache-2.0
231
+ Source: https://modelcontextprotocol.io
232
+
233
+ --- LICENSE ---
234
+ The MCP project is undergoing a licensing transition from the MIT License to the Apache License, Version 2.0 ("Apache-2.0"). All new code and specification contributions to the project are licensed under Apache-2.0. Documentation contributions (excluding specifications) are licensed under CC-BY-4.0.
235
+
236
+ Contributions for which relicensing consent has been obtained are licensed under Apache-2.0. Contributions made by authors who originally licensed their work under the MIT License and who have not yet granted explicit permission to relicense remain licensed under the MIT License.
237
+
238
+ No rights beyond those granted by the applicable original license are conveyed for such contributions.
239
+
240
+ ---
241
+
242
+ Apache License
243
+ Version 2.0, January 2004
244
+ http://www.apache.org/licenses/
245
+
246
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
247
+
248
+ 1. Definitions.
249
+
250
+ "License" shall mean the terms and conditions for use, reproduction,
251
+ and distribution as defined by Sections 1 through 9 of this document.
252
+
253
+ "Licensor" shall mean the copyright owner or entity authorized by
254
+ the copyright owner that is granting the License.
255
+
256
+ "Legal Entity" shall mean the union of the acting entity and all
257
+ other entities that control, are controlled by, or are under common
258
+ control with that entity. For the purposes of this definition,
259
+ "control" means (i) the power, direct or indirect, to cause the
260
+ direction or management of such entity, whether by contract or
261
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
262
+ outstanding shares, or (iii) beneficial ownership of such entity.
263
+
264
+ "You" (or "Your") shall mean an individual or Legal Entity
265
+ exercising permissions granted by this License.
266
+
267
+ "Source" form shall mean the preferred form for making modifications,
268
+ including but not limited to software source code, documentation
269
+ source, and configuration files.
270
+
271
+ "Object" form shall mean any form resulting from mechanical
272
+ transformation or translation of a Source form, including but
273
+ not limited to compiled object code, generated documentation,
274
+ and conversions to other media types.
275
+
276
+ "Work" shall mean the work of authorship, whether in Source or
277
+ Object form, made available under the License, as indicated by a
278
+ copyright notice that is included in or attached to the work
279
+ (an example is provided in the Appendix below).
280
+
281
+ "Derivative Works" shall mean any work, whether in Source or Object
282
+ form, that is based on (or derived from) the Work and for which the
283
+ editorial revisions, annotations, elaborations, or other modifications
284
+ represent, as a whole, an original work of authorship. For the purposes
285
+ of this License, Derivative Works shall not include works that remain
286
+ separable from, or merely link (or bind by name) to the interfaces of,
287
+ the Work and Derivative Works thereof.
288
+
289
+ "Contribution" shall mean any work of authorship, including
290
+ the original version of the Work and any modifications or additions
291
+ to that Work or Derivative Works thereof, that is intentionally
292
+ submitted to the Licensor for inclusion in the Work by the copyright
293
+ owner or by an individual or Legal Entity authorized to submit on behalf
294
+ of the copyright owner. For the purposes of this definition, "submitted"
295
+ means any form of electronic, verbal, or written communication sent
296
+ to the Licensor or its representatives, including but not limited to
297
+ communication on electronic mailing lists, source code control systems,
298
+ and issue tracking systems that are managed by, or on behalf of, the
299
+ Licensor for the purpose of discussing and improving the Work, but
300
+ excluding communication that is conspicuously marked or otherwise
301
+ designated in writing by the copyright owner as "Not a Contribution."
302
+
303
+ "Contributor" shall mean Licensor and any individual or Legal Entity
304
+ on behalf of whom a Contribution has been received by Licensor and
305
+ subsequently incorporated within the Work.
306
+
307
+ 2. Grant of Copyright License. Subject to the terms and conditions of
308
+ this License, each Contributor hereby grants to You a perpetual,
309
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
310
+ copyright license to reproduce, prepare Derivative Works of,
311
+ publicly display, publicly perform, sublicense, and distribute the
312
+ Work and such Derivative Works in Source or Object form.
313
+
314
+ 3. Grant of Patent License. Subject to the terms and conditions of
315
+ this License, each Contributor hereby grants to You a perpetual,
316
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
317
+ (except as stated in this section) patent license to make, have made,
318
+ use, offer to sell, sell, import, and otherwise transfer the Work,
319
+ where such license applies only to those patent claims licensable
320
+ by such Contributor that are necessarily infringed by their
321
+ Contribution(s) alone or by combination of their Contribution(s)
322
+ with the Work to which such Contribution(s) was submitted. If You
323
+ institute patent litigation against any entity (including a
324
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
325
+ or a Contribution incorporated within the Work constitutes direct
326
+ or contributory patent infringement, then any patent licenses
327
+ granted to You under this License for that Work shall terminate
328
+ as of the date such litigation is filed.
329
+
330
+ 4. Redistribution. You may reproduce and distribute copies of the
331
+ Work or Derivative Works thereof in any medium, with or without
332
+ modifications, and in Source or Object form, provided that You
333
+ meet the following conditions:
334
+
335
+ (a) You must give any other recipients of the Work or
336
+ Derivative Works a copy of this License; and
337
+
338
+ (b) You must cause any modified files to carry prominent notices
339
+ stating that You changed the files; and
340
+
341
+ (c) You must retain, in the Source form of any Derivative Works
342
+ that You distribute, all copyright, patent, trademark, and
343
+ attribution notices from the Source form of the Work,
344
+ excluding those notices that do not pertain to any part of
345
+ the Derivative Works; and
346
+
347
+ (d) If the Work includes a "NOTICE" text file as part of its
348
+ distribution, then any Derivative Works that You distribute must
349
+ include a readable copy of the attribution notices contained
350
+ within such NOTICE file, excluding those notices that do not
351
+ pertain to any part of the Derivative Works, in at least one
352
+ of the following places: within a NOTICE text file distributed
353
+ as part of the Derivative Works; within the Source form or
354
+ documentation, if provided along with the Derivative Works; or,
355
+ within a display generated by the Derivative Works, if and
356
+ wherever such third-party notices normally appear. The contents
357
+ of the NOTICE file are for informational purposes only and
358
+ do not modify the License. You may add Your own attribution
359
+ notices within Derivative Works that You distribute, alongside
360
+ or as an addendum to the NOTICE text from the Work, provided
361
+ that such additional attribution notices cannot be construed
362
+ as modifying the License.
363
+
364
+ You may add Your own copyright statement to Your modifications and
365
+ may provide additional or different license terms and conditions
366
+ for use, reproduction, or distribution of Your modifications, or
367
+ for any such Derivative Works as a whole, provided Your use,
368
+ reproduction, and distribution of the Work otherwise complies with
369
+ the conditions stated in this License.
370
+
371
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
372
+ any Contribution intentionally submitted for inclusion in the Work
373
+ by You to the Licensor shall be under the terms and conditions of
374
+ this License, without any additional terms or conditions.
375
+ Notwithstanding the above, nothing herein shall supersede or modify
376
+ the terms of any separate license agreement you may have executed
377
+ with Licensor regarding such Contributions.
378
+
379
+ 6. Trademarks. This License does not grant permission to use the trade
380
+ names, trademarks, service marks, or product names of the Licensor,
381
+ except as required for reasonable and customary use in describing the
382
+ origin of the Work and reproducing the content of the NOTICE file.
383
+
384
+ 7. Disclaimer of Warranty. Unless required by applicable law or
385
+ agreed to in writing, Licensor provides the Work (and each
386
+ Contributor provides its Contributions) on an "AS IS" BASIS,
387
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
388
+ implied, including, without limitation, any warranties or conditions
389
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
390
+ PARTICULAR PURPOSE. You are solely responsible for determining the
391
+ appropriateness of using or redistributing the Work and assume any
392
+ risks associated with Your exercise of permissions under this License.
393
+
394
+ 8. Limitation of Liability. In no event and under no legal theory,
395
+ whether in tort (including negligence), contract, or otherwise,
396
+ unless required by applicable law (such as deliberate and grossly
397
+ negligent acts) or agreed to in writing, shall any Contributor be
398
+ liable to You for damages, including any direct, indirect, special,
399
+ incidental, or consequential damages of any character arising as a
400
+ result of this License or out of the use or inability to use the
401
+ Work (including but not limited to damages for loss of goodwill,
402
+ work stoppage, computer failure or malfunction, or any and all
403
+ other commercial damages or losses), even if such Contributor
404
+ has been advised of the possibility of such damages.
405
+
406
+ 9. Accepting Warranty or Additional Liability. While redistributing
407
+ the Work or Derivative Works thereof, You may choose to offer,
408
+ and charge a fee for, acceptance of support, warranty, indemnity,
409
+ or other liability obligations and/or rights consistent with this
410
+ License. However, in accepting such obligations, You may act only
411
+ on Your own behalf and on Your sole responsibility, not on behalf
412
+ of any other Contributor, and only if You agree to indemnify,
413
+ defend, and hold each Contributor harmless for any liability
414
+ incurred by, or claims asserted against, such Contributor by reason
415
+ of your accepting any such warranty or additional liability.
416
+
417
+ END OF TERMS AND CONDITIONS
418
+
419
+ ---
420
+
421
+ MIT License
422
+
423
+ Copyright (c) 2024-2025 Model Context Protocol a Series of LF Projects, LLC.
424
+
425
+ Permission is hereby granted, free of charge, to any person obtaining a copy
426
+ of this software and associated documentation files (the "Software"), to deal
427
+ in the Software without restriction, including without limitation the rights
428
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
429
+ copies of the Software, and to permit persons to whom the Software is
430
+ furnished to do so, subject to the following conditions:
431
+
432
+ The above copyright notice and this permission notice shall be included in all
433
+ copies or substantial portions of the Software.
434
+
435
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
436
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
437
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
438
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
439
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
440
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
441
+ SOFTWARE.
442
+
443
+ ---
444
+
445
+ Creative Commons Attribution 4.0 International (CC-BY-4.0)
446
+
447
+ Documentation in this project (excluding specifications) is licensed under
448
+ CC-BY-4.0. See https://creativecommons.org/licenses/by/4.0/legalcode for
449
+ the full license text.
450
+
451
+ ==============================================================================
452
+ zod@4.6.7
453
+ License: MIT
454
+ Source: https://zod.dev
455
+
456
+ --- LICENSE ---
457
+ MIT License
458
+
459
+ Copyright (c) 2025 Colin McDonnell
460
+
461
+ Permission is hereby granted, free of charge, to any person obtaining a copy
462
+ of this software and associated documentation files (the "Software"), to deal
463
+ in the Software without restriction, including without limitation the rights
464
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
465
+ copies of the Software, and to permit persons to whom the Software is
466
+ furnished to do so, subject to the following conditions:
467
+
468
+ The above copyright notice and this permission notice shall be included in all
469
+ copies or substantial portions of the Software.
470
+
471
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
472
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
473
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
474
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
475
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
476
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
477
+ SOFTWARE.
@@ -0,0 +1,45 @@
1
+ import { NotLoggedInError } from './session.js';
2
+ export function envelope(statusCode, error, message) {
3
+ return { status: statusCode, ok: false, text: JSON.stringify({ statusCode, error, message }) };
4
+ }
5
+ export class ApiClient {
6
+ config;
7
+ session;
8
+ doFetch;
9
+ constructor(config, session, doFetch) {
10
+ this.config = config;
11
+ this.session = session;
12
+ this.doFetch = doFetch ?? fetch;
13
+ }
14
+ async request(req) {
15
+ try {
16
+ let token = await this.session.getAccessToken();
17
+ let res = await this.send(req, token);
18
+ if (res.status === 401) {
19
+ token = await this.session.renew(); // once; a second 401 is the answer
20
+ res = await this.send(req, token);
21
+ }
22
+ const text = await res.text();
23
+ return { status: res.status, ok: res.ok, text: text === '' && res.ok ? '{"ok":true}' : text };
24
+ }
25
+ catch (err) {
26
+ if (err instanceof NotLoggedInError)
27
+ return envelope(401, 'Unauthorized', err.message);
28
+ return envelope(0, 'NetworkError', `Request to ${this.config.apiUrl} failed: ${err.message}`);
29
+ }
30
+ }
31
+ send(req, token) {
32
+ const url = new URL(`${this.config.apiUrl}/api/v1${req.path}`);
33
+ for (const [k, v] of Object.entries(req.query ?? {})) {
34
+ if (v !== undefined)
35
+ url.searchParams.set(k, String(v));
36
+ }
37
+ const headers = { authorization: `Bearer ${token}`, accept: 'application/json' };
38
+ let body;
39
+ if (req.body !== undefined) {
40
+ headers['content-type'] = 'application/json';
41
+ body = JSON.stringify(req.body);
42
+ }
43
+ return this.doFetch(url, { method: req.method, headers, body });
44
+ }
45
+ }
package/dist/config.js ADDED
@@ -0,0 +1,13 @@
1
+ // MCP-001 / LLD-58 §3: environment configuration.
2
+ import { homedir } from 'node:os';
3
+ import { join } from 'node:path';
4
+ /** The one production deployment; override with CAMPAIGNMAP_API_URL (e.g. a local dev stack). */
5
+ export const DEFAULT_API_URL = 'https://maps.twojestarerpg.pl';
6
+ export function loadConfig(env = process.env) {
7
+ const apiUrl = (env.CAMPAIGNMAP_API_URL?.trim() || DEFAULT_API_URL).replace(/\/+$/, '');
8
+ return {
9
+ apiUrl,
10
+ sessionFile: env.CAMPAIGNMAP_SESSION_FILE?.trim() || join(homedir(), '.campaignmap', 'session.json'),
11
+ tty: env.CAMPAIGNMAP_TTY?.trim() || undefined,
12
+ };
13
+ }
@@ -0,0 +1,21 @@
1
+ import { envelope } from './apiClient.js';
2
+ export function terminalConfirmer(openPrompter) {
3
+ return async (question) => {
4
+ const prompter = openPrompter();
5
+ if (!prompter)
6
+ return false;
7
+ try {
8
+ const answer = (await prompter.ask(`${question} [y/N] `)).trim().toLowerCase();
9
+ return answer === 'y' || answer === 'yes';
10
+ }
11
+ catch {
12
+ return false;
13
+ }
14
+ finally {
15
+ prompter.close();
16
+ }
17
+ };
18
+ }
19
+ export const refusal = (what) => envelope(409, 'Confirmation required', `${what} was NOT performed: it needs a human to confirm on the terminal where campaignmap-mcp runs, ` +
20
+ 'and none confirmed (no terminal available, or the answer was not "y"). ' +
21
+ 'Ask the user to do it in the CampaignMap app, or to run the MCP client from a terminal.');
package/dist/index.js ADDED
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env node
2
+ // MCP-001: entry point.
3
+ // campaignmap-mcp stdio MCP server (spawned by the LLM client)
4
+ // campaignmap-mcp login interactive login on a normal terminal
5
+ // campaignmap-mcp logout revoke the refresh token and delete the session file
6
+ //
7
+ // stdout belongs to the JSON-RPC protocol: only log() (stderr) may print.
8
+ import { serveStdio } from '@modelcontextprotocol/server/stdio';
9
+ import { ApiClient } from './apiClient.js';
10
+ import { loadConfig } from './config.js';
11
+ import { terminalConfirmer } from './confirm.js';
12
+ import { log } from './log.js';
13
+ import { createMcpServer } from './server.js';
14
+ import { Session } from './session.js';
15
+ import { openControllingTerminal, stdioPrompter } from './tty.js';
16
+ async function main() {
17
+ const config = loadConfig();
18
+ const command = process.argv[2];
19
+ if (command === 'login' || command === 'logout') {
20
+ const session = new Session({ config });
21
+ if (command === 'logout') {
22
+ await session.logout();
23
+ log('Logged out.');
24
+ return;
25
+ }
26
+ const prompter = stdioPrompter();
27
+ if (!prompter)
28
+ throw new Error('"login" needs an interactive terminal.');
29
+ await session.login(prompter);
30
+ log(`Logged in to ${config.apiUrl}. The session is stored in ${config.sessionFile}.`);
31
+ return;
32
+ }
33
+ if (command !== undefined)
34
+ throw new Error(`Unknown command "${command}". Use: campaignmap-mcp [login|logout]`);
35
+ const openPrompter = () => openControllingTerminal(config.tty);
36
+ const session = new Session({ config, openPrompter });
37
+ const api = new ApiClient(config, session);
38
+ const confirm = terminalConfirmer(openPrompter);
39
+ log(`serving ${config.apiUrl} (${session.isLoggedIn() ? 'session found' : 'not logged in yet'})`);
40
+ serveStdio(() => createMcpServer({ api, confirm }), { onerror: (e) => log(`protocol error: ${e.message}`) });
41
+ }
42
+ main().then(() => {
43
+ // `login` / `logout` finished; the server variant keeps the process alive via stdin.
44
+ if (process.argv[2] === 'login' || process.argv[2] === 'logout')
45
+ process.exit(0);
46
+ }, (err) => {
47
+ log(`fatal: ${err.message}`);
48
+ process.exit(1);
49
+ });