@g33ks/foundryvtt-mcp 0.0.0-stage → 2.0.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.
Files changed (96) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +468 -2
  3. package/dist/character/manager.js +208 -0
  4. package/dist/cli/checks.js +307 -0
  5. package/dist/cli/config-file.js +120 -0
  6. package/dist/cli/init.js +410 -0
  7. package/dist/cli/prompt.js +117 -0
  8. package/dist/cli/snippets.js +49 -0
  9. package/dist/combat/manager.js +371 -0
  10. package/dist/config/env-layers.js +49 -0
  11. package/dist/config/index.js +298 -0
  12. package/dist/config/sources.js +201 -0
  13. package/dist/core.js +415 -0
  14. package/dist/diagnostics/client.js +353 -0
  15. package/dist/diagnostics/types.js +94 -0
  16. package/dist/foundry/auth.js +220 -0
  17. package/dist/foundry/browser-detect.js +170 -0
  18. package/dist/foundry/client.js +5555 -0
  19. package/dist/foundry/dice-formula.js +154 -0
  20. package/dist/foundry/event-log.js +299 -0
  21. package/dist/foundry/headless-gm-session.js +740 -0
  22. package/dist/foundry/journal-history.js +90 -0
  23. package/dist/foundry/journal-integrity.js +306 -0
  24. package/dist/foundry/module-bridge.js +413 -0
  25. package/dist/foundry/types.js +52 -0
  26. package/dist/foundry/world-cache.js +386 -0
  27. package/dist/index.js +107 -0
  28. package/dist/mcp-server.js +63 -0
  29. package/dist/server.js +159 -0
  30. package/dist/shared/build-order.js +134 -0
  31. package/dist/shared/config-hash.js +62 -0
  32. package/dist/shared/config-notice.js +55 -0
  33. package/dist/shared/control.js +255 -0
  34. package/dist/shared/daemon-link.js +135 -0
  35. package/dist/shared/daemon.js +313 -0
  36. package/dist/shared/ipc-client.js +200 -0
  37. package/dist/shared/ipc-server.js +316 -0
  38. package/dist/shared/paths.js +79 -0
  39. package/dist/shared/protocol.js +230 -0
  40. package/dist/shared/relay-config.js +65 -0
  41. package/dist/shared/relay.js +120 -0
  42. package/dist/shared/rotating-log.js +57 -0
  43. package/dist/shared/spawn.js +39 -0
  44. package/dist/shared/state-file.js +33 -0
  45. package/dist/shared/token.js +62 -0
  46. package/dist/shared/version.js +57 -0
  47. package/dist/tools/base.js +74 -0
  48. package/dist/tools/definitions.js +3109 -0
  49. package/dist/tools/handlers/actor-mutations.js +128 -0
  50. package/dist/tools/handlers/actors.js +114 -0
  51. package/dist/tools/handlers/chat-mutations.js +49 -0
  52. package/dist/tools/handlers/chat.js +36 -0
  53. package/dist/tools/handlers/combat-mutations.js +215 -0
  54. package/dist/tools/handlers/combat-order.js +94 -0
  55. package/dist/tools/handlers/combat.js +51 -0
  56. package/dist/tools/handlers/compendium.js +83 -0
  57. package/dist/tools/handlers/diagnostics.js +438 -0
  58. package/dist/tools/handlers/dice.js +54 -0
  59. package/dist/tools/handlers/effects.js +103 -0
  60. package/dist/tools/handlers/events.js +50 -0
  61. package/dist/tools/handlers/generation.js +258 -0
  62. package/dist/tools/handlers/item-mutations.js +132 -0
  63. package/dist/tools/handlers/items.js +53 -0
  64. package/dist/tools/handlers/journal-mutations.js +230 -0
  65. package/dist/tools/handlers/journals.js +80 -0
  66. package/dist/tools/handlers/module-bridge.js +421 -0
  67. package/dist/tools/handlers/placeable-mutations.js +272 -0
  68. package/dist/tools/handlers/resources.js +203 -0
  69. package/dist/tools/handlers/roll-tables.js +97 -0
  70. package/dist/tools/handlers/scene-mutations.js +159 -0
  71. package/dist/tools/handlers/scenes.js +355 -0
  72. package/dist/tools/handlers/settings.js +53 -0
  73. package/dist/tools/handlers/tile-mutations.js +56 -0
  74. package/dist/tools/handlers/token-mutations.js +356 -0
  75. package/dist/tools/handlers/users.js +59 -0
  76. package/dist/tools/handlers/utils.js +47 -0
  77. package/dist/tools/handlers/wall-mutations.js +98 -0
  78. package/dist/tools/handlers/world-documents.js +222 -0
  79. package/dist/tools/handlers/world.js +92 -0
  80. package/dist/tools/index.js +25 -0
  81. package/dist/tools/new-router.js +97 -0
  82. package/dist/tools/registry.js +79 -0
  83. package/dist/tools/resources.js +63 -0
  84. package/dist/tools/router.js +688 -0
  85. package/dist/tools/write-tools.js +97 -0
  86. package/dist/utils/cache-instance.js +30 -0
  87. package/dist/utils/cache.js +205 -0
  88. package/dist/utils/diagnostics.js +332 -0
  89. package/dist/utils/guards.js +17 -0
  90. package/dist/utils/image-size.js +160 -0
  91. package/dist/utils/log-args.js +47 -0
  92. package/dist/utils/logger.js +203 -0
  93. package/dist/utils/refusal.js +30 -0
  94. package/dist/utils/sanitize.js +22 -0
  95. package/dist/utils/serial-queue.js +22 -0
  96. package/package.json +124 -4
@@ -0,0 +1,160 @@
1
+ /**
2
+ * @fileoverview Minimal, dependency-free image dimension reader.
3
+ *
4
+ * Scene backgrounds and tile textures are plain files on FoundryVTT's local
5
+ * `Data` directory (PNG/JPEG/WebP in practice for the asset packs this
6
+ * server's scene/tile tools work with). Reading true pixel dimensions from
7
+ * disk means `create_scene`/`create_tile` never have to ask the caller to
8
+ * guess a width/height — the number one source of misaligned grids and
9
+ * off-canvas tiles when doing this by hand.
10
+ *
11
+ * Each format is detected by magic bytes and parsed from its own minimal
12
+ * header structure — no image decoding, just the size fields every format
13
+ * stores near the front of the file.
14
+ */
15
+ import { closeSync, openSync, readSync } from 'node:fs';
16
+ /** True if `buf` starts with the 8-byte PNG signature. */
17
+ function isPng(buf) {
18
+ return (buf.length >= 24 &&
19
+ buf[0] === 0x89 &&
20
+ buf[1] === 0x50 &&
21
+ buf[2] === 0x4e &&
22
+ buf[3] === 0x47 &&
23
+ buf[4] === 0x0d &&
24
+ buf[5] === 0x0a &&
25
+ buf[6] === 0x1a &&
26
+ buf[7] === 0x0a);
27
+ }
28
+ /** PNG: width/height are a fixed 8 bytes into the mandatory IHDR chunk (offset 16). */
29
+ function pngSize(buf) {
30
+ return { width: buf.readUInt32BE(16), height: buf.readUInt32BE(20) };
31
+ }
32
+ /** True if `buf` starts with the JPEG SOI marker (0xFFD8). */
33
+ function isJpeg(buf) {
34
+ return buf.length >= 4 && buf[0] === 0xff && buf[1] === 0xd8;
35
+ }
36
+ /**
37
+ * JPEG: no fixed offset — width/height live in whichever Start-Of-Frame
38
+ * marker (0xC0-0xCF, excluding the DHT/JPG/DAC markers 0xC4/0xC8/0xCC) the
39
+ * file actually uses, reached by walking the marker segment chain from the
40
+ * SOI. Each segment after the marker byte pair carries a 2-byte big-endian
41
+ * length (including itself); SOF segments store height then width 3 bytes
42
+ * into their payload.
43
+ */
44
+ function jpegSize(buf) {
45
+ let offset = 2; // past the 0xFFD8 SOI marker
46
+ while (offset + 4 <= buf.length) {
47
+ if (buf[offset] !== 0xff) {
48
+ // Not aligned on a marker — bail rather than mis-scan garbage.
49
+ return null;
50
+ }
51
+ const marker = buf[offset + 1];
52
+ // Standalone markers with no length/payload.
53
+ if (marker === 0xd8 || marker === 0xd9 || (marker >= 0xd0 && marker <= 0xd7)) {
54
+ offset += 2;
55
+ continue;
56
+ }
57
+ const segmentLength = buf.readUInt16BE(offset + 2);
58
+ const isSof = marker >= 0xc0 && marker <= 0xcf && marker !== 0xc4 && marker !== 0xc8 && marker !== 0xcc;
59
+ if (isSof) {
60
+ if (offset + 9 > buf.length) {
61
+ return null;
62
+ }
63
+ const height = buf.readUInt16BE(offset + 5);
64
+ const width = buf.readUInt16BE(offset + 7);
65
+ return { width, height };
66
+ }
67
+ offset += 2 + segmentLength;
68
+ }
69
+ return null;
70
+ }
71
+ /** True if `buf` starts with a RIFF....WEBP container header. */
72
+ function isWebp(buf) {
73
+ return (buf.length >= 30 &&
74
+ buf.toString('ascii', 0, 4) === 'RIFF' &&
75
+ buf.toString('ascii', 8, 12) === 'WEBP');
76
+ }
77
+ /**
78
+ * WebP: dimensions are encoded differently per sub-format (VP8, VP8L, VP8X)
79
+ * following the 12-byte RIFF/WEBP header. Only the three sub-formats
80
+ * FoundryVTT/browsers actually produce are handled.
81
+ */
82
+ function webpSize(buf) {
83
+ const fourCc = buf.toString('ascii', 12, 16);
84
+ if (fourCc === 'VP8X') {
85
+ // Extended format: 24-bit little-endian canvas width/height minus one, at offset 24/27.
86
+ const width = buf[24] | (buf[25] << 8) | (buf[26] << 16);
87
+ const height = buf[27] | (buf[28] << 8) | (buf[29] << 16);
88
+ return { width: width + 1, height: height + 1 };
89
+ }
90
+ if (fourCc === 'VP8 ' && buf.length >= 30) {
91
+ // Lossy: 14-bit width/height (top 2 bits are an unrelated scale flag) at offset 26/28.
92
+ const width = buf.readUInt16LE(26) & 0x3fff;
93
+ const height = buf.readUInt16LE(28) & 0x3fff;
94
+ return { width, height };
95
+ }
96
+ if (fourCc === 'VP8L' && buf.length >= 25) {
97
+ // Lossless: a packed 32-bit little-endian field at offset 21 holds
98
+ // 14-bit (width-1) then 14-bit (height-1).
99
+ const bits = buf[21] |
100
+ (buf[22] << 8) |
101
+ (buf[23] << 16) |
102
+ (buf[24] << 24);
103
+ const width = (bits & 0x3fff) + 1;
104
+ const height = ((bits >> 14) & 0x3fff) + 1;
105
+ return { width, height };
106
+ }
107
+ return null;
108
+ }
109
+ /**
110
+ * Bytes read from the front of each file. All three formats' dimension
111
+ * fields live well inside this window for any file this server actually
112
+ * handles (PNG: fixed 24-byte offset; WebP: fixed ~30-byte offset; JPEG:
113
+ * markers before the first Start-Of-Frame — typically one EXIF/JFIF
114
+ * segment, each capped at 65533 bytes by the format itself). Reading a
115
+ * bounded prefix instead of the whole file keeps `list_scene_assets`
116
+ * cheap even over a folder of multi-megabyte battlemap JPEGs.
117
+ */
118
+ const HEADER_READ_BYTES = 262144;
119
+ /**
120
+ * Reads an image's true pixel dimensions from its header, without decoding
121
+ * pixel data. Supports PNG, JPEG, and WebP — the formats FoundryVTT's own
122
+ * asset pipeline and typical battlemap packs use. Reads only a bounded
123
+ * prefix of the file ({@link HEADER_READ_BYTES}), not the full contents.
124
+ *
125
+ * @param absolutePath - filesystem path to the image file
126
+ * @returns dimensions, or null if the file is missing, unreadable, not one
127
+ * of the supported formats, or the dimension fields fall outside the
128
+ * read window (pathological — not expected for real map/prop art)
129
+ */
130
+ export function getImageSize(absolutePath) {
131
+ let fd;
132
+ try {
133
+ fd = openSync(absolutePath, 'r');
134
+ }
135
+ catch {
136
+ return null;
137
+ }
138
+ try {
139
+ const buf = Buffer.alloc(HEADER_READ_BYTES);
140
+ const bytesRead = readSync(fd, buf, 0, HEADER_READ_BYTES, 0);
141
+ const header = buf.subarray(0, bytesRead);
142
+ if (isPng(header)) {
143
+ return pngSize(header);
144
+ }
145
+ if (isJpeg(header)) {
146
+ return jpegSize(header);
147
+ }
148
+ if (isWebp(header)) {
149
+ return webpSize(header);
150
+ }
151
+ return null;
152
+ }
153
+ catch {
154
+ return null;
155
+ }
156
+ finally {
157
+ closeSync(fd);
158
+ }
159
+ }
160
+ //# sourceMappingURL=image-size.js.map
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @fileoverview Tool arguments as they may appear in a log line.
3
+ *
4
+ * `daemon.log` records every tool call. Journal pages, chat messages, macro
5
+ * code and the like are the user's campaign text and have no business in a
6
+ * log, so content-bearing arguments are replaced by their length. Ids, names
7
+ * and other short parameters stay as they are, since they are what makes a
8
+ * log line useful.
9
+ */
10
+ /** Argument names whose string values are always content. */
11
+ const CONTENT_KEYS = new Set([
12
+ 'content',
13
+ 'text',
14
+ 'html',
15
+ 'description',
16
+ 'flavor',
17
+ 'command',
18
+ ]);
19
+ /** Any other string longer than this is treated as content too (pasted text, base64, …). */
20
+ const MAX_PLAIN_STRING = 200;
21
+ function placeholder(value) {
22
+ return `<${value.length} chars>`;
23
+ }
24
+ function redact(value, key) {
25
+ if (typeof value === 'string') {
26
+ if ((key !== null && CONTENT_KEYS.has(key)) || value.length > MAX_PLAIN_STRING) {
27
+ return placeholder(value);
28
+ }
29
+ return value;
30
+ }
31
+ if (Array.isArray(value)) {
32
+ // Array items inherit the array's key: `content: ["…"]` is still content.
33
+ return value.map((item) => redact(item, key));
34
+ }
35
+ if (value !== null && typeof value === 'object') {
36
+ return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, redact(v, k)]));
37
+ }
38
+ return value;
39
+ }
40
+ /**
41
+ * A copy of `args` safe to log: content-bearing strings (at any depth, e.g.
42
+ * `pages[].content`) become `"<312 chars>"`. Never mutates `args`.
43
+ */
44
+ export function redactToolArgs(args) {
45
+ return redact(args, null);
46
+ }
47
+ //# sourceMappingURL=log-args.js.map
@@ -0,0 +1,203 @@
1
+ /**
2
+ * @fileoverview Centralized logging utility for FoundryVTT MCP Server
3
+ *
4
+ * This module provides a structured logging system with configurable log levels
5
+ * and consistent formatting across the application. It respects the LOG_LEVEL
6
+ * environment variable for controlling verbosity.
7
+ *
8
+ * @version 0.1.0
9
+ * @author FoundryVTT MCP Team
10
+ */
11
+ import { config } from '../config/index.js';
12
+ /**
13
+ * Centralized logger class for structured application logging
14
+ *
15
+ * Provides methods for different log levels and automatically filters
16
+ * messages based on the configured minimum log level.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * import { logger } from './utils/logger.js';
21
+ *
22
+ * logger.info('Server starting...');
23
+ * logger.error('Connection failed:', error);
24
+ * logger.debug('Detailed debug info', { data: someObject });
25
+ * ```
26
+ */
27
+ export class Logger {
28
+ logLevel;
29
+ sinks = [];
30
+ levels = {
31
+ debug: 0,
32
+ info: 1,
33
+ warn: 2,
34
+ error: 3,
35
+ };
36
+ /**
37
+ * Creates a new Logger instance
38
+ *
39
+ * @param logLevel - Minimum log level to display (default: 'info'), or a
40
+ * function resolving it on first use; while it returns `null` (no usable
41
+ * configuration yet) messages are filtered at `info` and it is asked again
42
+ */
43
+ constructor(logLevel = 'info') {
44
+ this.logLevel = logLevel;
45
+ }
46
+ /** Overrides the configured level (`init` keeps its terminal output to its own messages). */
47
+ setLevel(level) {
48
+ this.logLevel = level;
49
+ }
50
+ /**
51
+ * Also writes every emitted line to `sink` (e.g. a log file). The shared
52
+ * process runs detached with no stderr, so its sink is the only output.
53
+ */
54
+ addSink(sink) {
55
+ this.sinks.push(sink);
56
+ }
57
+ emit(write, line) {
58
+ write(line);
59
+ for (const sink of this.sinks) {
60
+ sink(line);
61
+ }
62
+ }
63
+ level() {
64
+ if (typeof this.logLevel === 'function') {
65
+ const resolved = this.logLevel();
66
+ if (resolved === null) {
67
+ return 'info';
68
+ }
69
+ this.logLevel = resolved;
70
+ }
71
+ return this.logLevel;
72
+ }
73
+ /**
74
+ * Determines if a message should be logged based on current log level
75
+ *
76
+ * @private
77
+ * @param level - The log level to check
78
+ * @returns True if the message should be logged, false otherwise
79
+ */
80
+ shouldLog(level) {
81
+ return this.levels[level] >= this.levels[this.level()];
82
+ }
83
+ /**
84
+ * Formats a log message with timestamp, level, and optional metadata
85
+ *
86
+ * @private
87
+ * @param level - The log level
88
+ * @param message - The main log message
89
+ * @param meta - Optional metadata object
90
+ * @returns Formatted log message string
91
+ */
92
+ formatMessage(level, message, meta) {
93
+ const timestamp = new Date().toISOString();
94
+ const metaStr = meta ? ` ${JSON.stringify(meta)}` : '';
95
+ return `[${timestamp}] ${level.toUpperCase()}: ${message}${metaStr}`;
96
+ }
97
+ /**
98
+ * Logs a debug message (lowest priority)
99
+ *
100
+ * Used for detailed information that's only needed when debugging issues.
101
+ * Only shown when LOG_LEVEL is set to 'debug'.
102
+ *
103
+ * Note: In an MCP stdio server, all log output MUST be written to stderr
104
+ * (via console.error) so that stdout remains clean for JSON-RPC messages.
105
+ *
106
+ * @param message - The debug message
107
+ * @param meta - Optional metadata object
108
+ * @example
109
+ * ```typescript
110
+ * logger.debug('Processing user request', { userId: '123', action: 'search' });
111
+ * ```
112
+ */
113
+ debug(message, meta) {
114
+ if (this.shouldLog('debug')) {
115
+ this.emit(console.error, this.formatMessage('debug', message, meta));
116
+ }
117
+ }
118
+ /**
119
+ * Logs an informational message
120
+ *
121
+ * Used for general information about application flow and important events.
122
+ * Shown when LOG_LEVEL is 'debug' or 'info'.
123
+ *
124
+ * Note: In an MCP stdio server, all log output MUST be written to stderr
125
+ * (via console.error) so that stdout remains clean for JSON-RPC messages.
126
+ *
127
+ * @param message - The info message
128
+ * @param meta - Optional metadata object
129
+ * @example
130
+ * ```typescript
131
+ * logger.info('Server started successfully', { port: 3000 });
132
+ * ```
133
+ */
134
+ info(message, meta) {
135
+ if (this.shouldLog('info')) {
136
+ this.emit(console.error, this.formatMessage('info', message, meta));
137
+ }
138
+ }
139
+ /**
140
+ * Logs a warning message
141
+ *
142
+ * Used for potentially problematic situations that don't prevent operation
143
+ * but should be noted. Shown when LOG_LEVEL is 'debug', 'info', or 'warn'.
144
+ *
145
+ * @param message - The warning message
146
+ * @param meta - Optional metadata object
147
+ * @example
148
+ * ```typescript
149
+ * logger.warn('Deprecated API endpoint used', { endpoint: '/old-api' });
150
+ * ```
151
+ */
152
+ warn(message, meta) {
153
+ if (this.shouldLog('warn')) {
154
+ this.emit(console.warn, this.formatMessage('warn', message, meta));
155
+ }
156
+ }
157
+ /**
158
+ * Logs an error message (highest priority)
159
+ *
160
+ * Used for error conditions and exceptions that affect application operation.
161
+ * Always shown regardless of LOG_LEVEL setting.
162
+ *
163
+ * @param message - The error message
164
+ * @param error - Optional error object or metadata
165
+ * @example
166
+ * ```typescript
167
+ * logger.error('Database connection failed', error);
168
+ * logger.error('Invalid user input', { input: userData, validation: errors });
169
+ * ```
170
+ */
171
+ error(message, error) {
172
+ if (this.shouldLog('error')) {
173
+ const errorDetails = error instanceof Error ? { message: error.message, stack: error.stack } : error;
174
+ this.emit(console.error, this.formatMessage('error', message, errorDetails));
175
+ }
176
+ }
177
+ }
178
+ /**
179
+ * Global logger instance
180
+ *
181
+ * Pre-configured logger instance ready for use throughout the application.
182
+ * Respects the LOG_LEVEL environment variable for filtering messages.
183
+ *
184
+ * @example
185
+ * ```typescript
186
+ * import { logger } from './utils/logger.js';
187
+ *
188
+ * logger.info('Application starting');
189
+ * logger.error('Something went wrong', error);
190
+ * ```
191
+ */
192
+ // The level is resolved on first use, not at import: importing the logger must
193
+ // not validate the whole configuration (`status`/`stop` run without one), and
194
+ // logging must never fail or exit while there is none (`info` meanwhile).
195
+ export const logger = new Logger(() => {
196
+ try {
197
+ return config.logLevel;
198
+ }
199
+ catch {
200
+ return null;
201
+ }
202
+ });
203
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @fileoverview Expected refusals: a tool call turned down by design (a
3
+ * missing or outdated journal page version, …), as opposed to a failure.
4
+ *
5
+ * The caller still gets an error, but the log gets one warn line without a
6
+ * stack instead of the error lines a failure produces.
7
+ */
8
+ import { McpError } from '@modelcontextprotocol/sdk/types.js';
9
+ /** Thrown below the handlers (e.g. by `FoundryClient`) for an expected refusal. */
10
+ export class RefusedError extends Error {
11
+ name = 'RefusedError';
12
+ }
13
+ /** `McpError.data` marking an expected refusal. */
14
+ const REFUSAL_DATA = { refusal: true };
15
+ /** An `McpError` for an expected refusal. */
16
+ export function refusalError(code, message) {
17
+ return new McpError(code, message, REFUSAL_DATA);
18
+ }
19
+ /** True for a {@link RefusedError} or an `McpError` built by {@link refusalError}. */
20
+ export function isRefusal(error) {
21
+ if (error instanceof RefusedError) {
22
+ return true;
23
+ }
24
+ if (!(error instanceof McpError)) {
25
+ return false;
26
+ }
27
+ const data = error.data;
28
+ return typeof data === 'object' && data !== null && 'refusal' in data && data.refusal === true;
29
+ }
30
+ //# sourceMappingURL=refusal.js.map
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @fileoverview Sanitization utilities for safe string processing.
3
+ */
4
+ /**
5
+ * Strips HTML tags from a string iteratively to prevent incomplete multi-character sanitization bypasses.
6
+ *
7
+ * @param input - The raw input string containing potential HTML tags
8
+ * @returns Clean plain text with all HTML tags stripped
9
+ */
10
+ export function stripHtml(input) {
11
+ if (!input) {
12
+ return '';
13
+ }
14
+ let prev = '';
15
+ let curr = input;
16
+ while (curr !== prev) {
17
+ prev = curr;
18
+ curr = curr.replace(/<[^<>]*>/g, '');
19
+ }
20
+ return curr;
21
+ }
22
+ //# sourceMappingURL=sanitize.js.map
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @fileoverview Runs async tasks one at a time, in submission order.
3
+ */
4
+ export class SerialQueue {
5
+ tail = Promise.resolve();
6
+ pendingCount = 0;
7
+ /** Tasks submitted and not yet settled, the running one included. */
8
+ get pending() {
9
+ return this.pendingCount;
10
+ }
11
+ /** Runs `task` after every previously submitted task has settled. */
12
+ run(task) {
13
+ this.pendingCount++;
14
+ const result = this.tail.then(task).finally(() => {
15
+ this.pendingCount--;
16
+ });
17
+ // A failed task must not block the ones queued behind it.
18
+ this.tail = result.catch(() => undefined);
19
+ return result;
20
+ }
21
+ }
22
+ //# sourceMappingURL=serial-queue.js.map
package/package.json CHANGED
@@ -1,6 +1,126 @@
1
1
  {
2
2
  "name": "@g33ks/foundryvtt-mcp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "2.0.0",
4
+ "description": "Model Context Protocol server for FoundryVTT integration",
5
+ "bin": {
6
+ "foundryvtt-mcp": "dist/index.js"
7
+ },
8
+ "type": "module",
9
+ "scripts": {
10
+ "build": "tsc && node -e \"require('node:fs').chmodSync('dist/index.js', 0o755)\"",
11
+ "dev": "tsx watch src/index.ts",
12
+ "start": "node dist/index.js",
13
+ "smoke": "node scripts/smoke-test.js",
14
+ "smoke:dotenv": "node scripts/smoke-dotenv.js",
15
+ "smoke:pack": "node scripts/smoke-pack.js",
16
+ "stress:shared": "node scripts/stress-shared.js",
17
+ "check:bridge-security": "node scripts/check-bridge-security.js",
18
+ "bridge:package": "node scripts/package-bridge.js",
19
+ "test": "vitest run",
20
+ "test:watch": "vitest --watch",
21
+ "test:coverage": "vitest run --coverage",
22
+ "test:ui": "vitest --ui",
23
+ "test:e2e": "playwright test",
24
+ "test:e2e:ui": "playwright test --ui",
25
+ "test:e2e:headed": "playwright test --headed",
26
+ "test:e2e:debug": "playwright test --debug",
27
+ "test:e2e:report": "playwright show-report",
28
+ "test:integration": "vitest run --config vitest.integration.config.ts",
29
+ "test:integration:watch": "vitest --watch --config vitest.integration.config.ts",
30
+ "test:integration:ui": "vitest --ui --config vitest.integration.config.ts",
31
+ "test:integration:docker": "docker compose -f docker-compose.test.yml up -d --wait && npm run test:integration; docker compose -f docker-compose.test.yml down -v",
32
+ "lint": "biome check src",
33
+ "lint:fix": "biome check --write src",
34
+ "format": "biome format --write src",
35
+ "clean": "rimraf dist",
36
+ "setup": "npm run clean && npm run build && node dist/index.js init --check",
37
+ "prepare": "husky",
38
+ "prepublishOnly": "npm run clean && npm run build"
39
+ },
40
+ "keywords": [
41
+ "foundry",
42
+ "vtt",
43
+ "mcp",
44
+ "ai",
45
+ "tabletop",
46
+ "rpg",
47
+ "foundryvtt",
48
+ "foundry-vtt",
49
+ "model-context-protocol",
50
+ "mcp-server",
51
+ "claude"
52
+ ],
53
+ "author": "G33ks",
54
+ "contributors": [
55
+ "Lauri Gates",
56
+ "Rafael Niehaus"
57
+ ],
58
+ "license": "MIT",
59
+ "repository": {
60
+ "type": "git",
61
+ "url": "https://github.com/G33ks/foundryvtt-mcp.git"
62
+ },
63
+ "homepage": "https://github.com/G33ks/foundryvtt-mcp#readme",
64
+ "bugs": {
65
+ "url": "https://github.com/G33ks/foundryvtt-mcp/issues"
66
+ },
67
+ "publishConfig": {
68
+ "access": "public"
69
+ },
70
+ "files": [
71
+ "dist/**/*.js",
72
+ "README.md",
73
+ "LICENSE"
74
+ ],
75
+ "dependencies": {
76
+ "@modelcontextprotocol/sdk": "^1.32.2",
77
+ "ajv": "^8.20.0",
78
+ "axios": "^1.21.0",
79
+ "dotenv": "^17.4.2",
80
+ "playwright-core": "^1.63.0",
81
+ "socket.io-client": "^4.8.3",
82
+ "ws": "^8.21.0",
83
+ "zod": "^4.6.7"
84
+ },
85
+ "devDependencies": {
86
+ "@biomejs/biome": "^2.5.0",
87
+ "@playwright/test": "^1.61.0",
88
+ "@types/node": "^25.9.4",
89
+ "@types/ws": "^8.18.1",
90
+ "husky": "^9.1.7",
91
+ "lint-staged": "^17.0.7",
92
+ "rimraf": "^6.1.4",
93
+ "tsx": "^4.22.4",
94
+ "typescript": "^6.0.3",
95
+ "vitest": "^4.1.12"
96
+ },
97
+ "engines": {
98
+ "node": ">=22"
99
+ },
100
+ "overrides": {
101
+ "@hono/node-server": "^2.1.6",
102
+ "hono": "^4.13.16",
103
+ "express-rate-limit": "^8.5.1",
104
+ "ip-address": "^10.7.6",
105
+ "path-to-regexp": "^8.4.2",
106
+ "fast-uri": "^3.1.9",
107
+ "socket.io-parser": "^4.2.7",
108
+ "vite": "^7.3.7",
109
+ "rollup": "^4.60.3",
110
+ "postcss": "^8.5.23",
111
+ "nanoid": "^3.3.16",
112
+ "picomatch": "^4.0.4",
113
+ "brace-expansion": "^5.0.12",
114
+ "form-data": "^4.0.6",
115
+ "ws": "^8.21.0",
116
+ "qs": "^6.17.1"
117
+ },
118
+ "lint-staged": {
119
+ "src/**/*.{ts,tsx,js,jsx}": [
120
+ "biome check --write"
121
+ ],
122
+ "src/**/*.{json,css,md}": [
123
+ "biome format --write"
124
+ ]
125
+ }
126
+ }