@mcptoolshop/file-forge 0.2.1 → 1.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 (66) hide show
  1. package/README.md +33 -5
  2. package/build/config/index.d.ts +29 -0
  3. package/build/config/index.d.ts.map +1 -0
  4. package/build/config/index.js +229 -0
  5. package/build/config/index.js.map +1 -0
  6. package/build/index.d.ts +9 -0
  7. package/build/index.d.ts.map +1 -0
  8. package/build/index.js +25 -0
  9. package/build/index.js.map +1 -0
  10. package/build/security/index.d.ts +8 -0
  11. package/build/security/index.d.ts.map +1 -0
  12. package/build/security/index.js +8 -0
  13. package/build/security/index.js.map +1 -0
  14. package/build/security/read-only.d.ts +32 -0
  15. package/build/security/read-only.d.ts.map +1 -0
  16. package/build/security/read-only.js +62 -0
  17. package/build/security/read-only.js.map +1 -0
  18. package/build/security/sandbox.d.ts +60 -0
  19. package/build/security/sandbox.d.ts.map +1 -0
  20. package/build/security/sandbox.js +231 -0
  21. package/build/security/sandbox.js.map +1 -0
  22. package/build/server.d.ts +32 -0
  23. package/build/server.d.ts.map +1 -0
  24. package/build/server.js +171 -0
  25. package/build/server.js.map +1 -0
  26. package/build/tools/metadata.d.ts +11 -0
  27. package/build/tools/metadata.d.ts.map +1 -0
  28. package/build/tools/metadata.js +423 -0
  29. package/build/tools/metadata.js.map +1 -0
  30. package/build/tools/read.d.ts +11 -0
  31. package/build/tools/read.d.ts.map +1 -0
  32. package/build/tools/read.js +335 -0
  33. package/build/tools/read.js.map +1 -0
  34. package/build/tools/scaffold.d.ts +11 -0
  35. package/build/tools/scaffold.d.ts.map +1 -0
  36. package/build/tools/scaffold.js +345 -0
  37. package/build/tools/scaffold.js.map +1 -0
  38. package/build/tools/search.d.ts +11 -0
  39. package/build/tools/search.d.ts.map +1 -0
  40. package/build/tools/search.js +250 -0
  41. package/build/tools/search.js.map +1 -0
  42. package/build/tools/write.d.ts +11 -0
  43. package/build/tools/write.d.ts.map +1 -0
  44. package/build/tools/write.js +538 -0
  45. package/build/tools/write.js.map +1 -0
  46. package/build/types.d.ts +402 -0
  47. package/build/types.d.ts.map +1 -0
  48. package/build/types.js +146 -0
  49. package/build/types.js.map +1 -0
  50. package/build/utils/errors.d.ts +43 -0
  51. package/build/utils/errors.d.ts.map +1 -0
  52. package/build/utils/errors.js +125 -0
  53. package/build/utils/errors.js.map +1 -0
  54. package/build/utils/index.d.ts +10 -0
  55. package/build/utils/index.d.ts.map +1 -0
  56. package/build/utils/index.js +9 -0
  57. package/build/utils/index.js.map +1 -0
  58. package/build/utils/logger.d.ts +88 -0
  59. package/build/utils/logger.d.ts.map +1 -0
  60. package/build/utils/logger.js +166 -0
  61. package/build/utils/logger.js.map +1 -0
  62. package/build/utils/validation.d.ts +43 -0
  63. package/build/utils/validation.d.ts.map +1 -0
  64. package/build/utils/validation.js +196 -0
  65. package/build/utils/validation.js.map +1 -0
  66. package/package.json +1 -1
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
- <p align="center">
2
- <a href="README.ja.md">日本語</a> | <a href="README.zh.md">中文</a> | <a href="README.es.md">Español</a> | <a href="README.fr.md">Français</a> | <a href="README.hi.md">हिन्दी</a> | <a href="README.it.md">Italiano</a> | <a href="README.pt-BR.md">Português (BR)</a>
3
- </p>
4
-
1
+ <p align="center">
2
+ <a href="README.ja.md">日本語</a> | <a href="README.zh.md">中文</a> | <a href="README.es.md">Español</a> | <a href="README.fr.md">Français</a> | <a href="README.hi.md">हिन्दी</a> | <a href="README.it.md">Italiano</a> | <a href="README.pt-BR.md">Português (BR)</a>
3
+ </p>
4
+
5
5
  <p align="center"><img src="https://raw.githubusercontent.com/mcp-tool-shop-org/brand/main/logos/mcp-file-forge/readme.png" alt="MCP File Forge" width="400"></p>
6
6
 
7
7
  <p align="center">
@@ -232,10 +232,38 @@ npm run lint
232
232
 
233
233
  ---
234
234
 
235
+ ## Security & Data Scope
236
+
237
+ MCP File Forge is an **MCP server** providing sandboxed file operations for AI agents.
238
+
239
+ - **Data accessed:** Files within explicitly allowed directories only. Config files, template directories
240
+ - **Data NOT accessed:** No cloud sync. No telemetry. No analytics. No data outside sandbox
241
+ - **Network:** stdio transport only — no network listeners. No egress
242
+ - **No telemetry** is collected or sent
243
+
244
+ Full policy: [SECURITY.md](SECURITY.md)
245
+
246
+ ---
247
+
248
+ ## Scorecard
249
+
250
+ | Category | Score |
251
+ |----------|-------|
252
+ | A. Security | 10/10 |
253
+ | B. Error Handling | 10/10 |
254
+ | C. Operator Docs | 10/10 |
255
+ | D. Shipping Hygiene | 10/10 |
256
+ | E. Identity (soft) | 10/10 |
257
+ | **Overall** | **50/50** |
258
+
259
+ ---
260
+
235
261
  ## License
236
262
 
237
263
  [MIT](LICENSE)
238
264
 
239
265
  ---
240
266
 
241
- Built by <a href="https://mcp-tool-shop.github.io/">MCP Tool Shop</a>
267
+ <p align="center">
268
+ Built by <a href="https://mcp-tool-shop.github.io/">MCP Tool Shop</a>
269
+ </p>
@@ -0,0 +1,29 @@
1
+ /**
2
+ * MCP File Forge - Configuration Module
3
+ *
4
+ * Handles loading and merging configuration from multiple sources.
5
+ */
6
+ import type { ServerConfig } from '../types.js';
7
+ /**
8
+ * Load and merge configuration from all sources.
9
+ *
10
+ * Priority (highest to lowest):
11
+ * 1. CLI arguments (not implemented yet)
12
+ * 2. Environment variables
13
+ * 3. Config file
14
+ * 4. Built-in defaults
15
+ */
16
+ export declare function loadConfig(): Promise<ServerConfig>;
17
+ /**
18
+ * Get the current configuration.
19
+ */
20
+ export declare function getConfig(): ServerConfig;
21
+ /**
22
+ * Reset configuration (useful for testing).
23
+ */
24
+ export declare function resetConfig(): void;
25
+ /**
26
+ * Get default configuration.
27
+ */
28
+ export declare function getDefaultConfig(): ServerConfig;
29
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,YAAY,EAA4C,MAAM,aAAa,CAAC;AA4L1F;;;;;;;;GAQG;AACH,wBAAsB,UAAU,IAAI,OAAO,CAAC,YAAY,CAAC,CA+BxD;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,YAAY,CAKxC;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAElC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,YAAY,CAE/C"}
@@ -0,0 +1,229 @@
1
+ /**
2
+ * MCP File Forge - Configuration Module
3
+ *
4
+ * Handles loading and merging configuration from multiple sources.
5
+ */
6
+ import * as fs from 'node:fs/promises';
7
+ import * as path from 'node:path';
8
+ import { ServerConfigSchema } from '../types.js';
9
+ /**
10
+ * Default configuration values.
11
+ */
12
+ const DEFAULT_CONFIG = {
13
+ sandbox: {
14
+ allowed_paths: ['.'],
15
+ denied_paths: ['**/node_modules/**', '**/.git/**'],
16
+ follow_symlinks: false,
17
+ max_file_size: 104857600, // 100MB
18
+ max_depth: 20,
19
+ },
20
+ templates: {
21
+ paths: ['./templates'],
22
+ },
23
+ logging: {
24
+ level: 'info',
25
+ },
26
+ read_only: false,
27
+ };
28
+ /**
29
+ * Environment variable prefix.
30
+ */
31
+ const ENV_PREFIX = 'MCP_FILE_FORGE_';
32
+ /**
33
+ * Parse a comma-separated string into an array.
34
+ */
35
+ function parseCSV(value) {
36
+ return value
37
+ .split(',')
38
+ .map((s) => s.trim())
39
+ .filter((s) => s.length > 0);
40
+ }
41
+ /**
42
+ * Parse environment variables into partial config.
43
+ */
44
+ function parseEnvironment() {
45
+ const config = {};
46
+ const sandbox = {};
47
+ const templates = {};
48
+ const logging = {};
49
+ // Read-only mode
50
+ const readOnly = process.env[`${ENV_PREFIX}READ_ONLY`];
51
+ if (readOnly !== undefined) {
52
+ config.read_only = readOnly.toLowerCase() === 'true';
53
+ }
54
+ // Sandbox settings
55
+ const allowedPaths = process.env[`${ENV_PREFIX}ALLOWED_PATHS`];
56
+ if (allowedPaths) {
57
+ sandbox.allowed_paths = parseCSV(allowedPaths);
58
+ }
59
+ const deniedPaths = process.env[`${ENV_PREFIX}DENIED_PATHS`];
60
+ if (deniedPaths) {
61
+ sandbox.denied_paths = parseCSV(deniedPaths);
62
+ }
63
+ const followSymlinks = process.env[`${ENV_PREFIX}FOLLOW_SYMLINKS`];
64
+ if (followSymlinks !== undefined) {
65
+ sandbox.follow_symlinks = followSymlinks.toLowerCase() === 'true';
66
+ }
67
+ const maxFileSize = process.env[`${ENV_PREFIX}MAX_FILE_SIZE`];
68
+ if (maxFileSize) {
69
+ const parsed = parseInt(maxFileSize, 10);
70
+ if (!isNaN(parsed)) {
71
+ sandbox.max_file_size = parsed;
72
+ }
73
+ }
74
+ const maxDepth = process.env[`${ENV_PREFIX}MAX_DEPTH`];
75
+ if (maxDepth) {
76
+ const parsed = parseInt(maxDepth, 10);
77
+ if (!isNaN(parsed)) {
78
+ sandbox.max_depth = parsed;
79
+ }
80
+ }
81
+ // Template settings
82
+ const templatePaths = process.env[`${ENV_PREFIX}TEMPLATE_PATHS`];
83
+ if (templatePaths) {
84
+ templates.paths = parseCSV(templatePaths);
85
+ }
86
+ // Logging settings
87
+ const logLevel = process.env[`${ENV_PREFIX}LOG_LEVEL`];
88
+ if (logLevel) {
89
+ const level = logLevel.toLowerCase();
90
+ if (['error', 'warn', 'info', 'debug'].includes(level)) {
91
+ logging.level = level;
92
+ }
93
+ }
94
+ const logFile = process.env[`${ENV_PREFIX}LOG_FILE`];
95
+ if (logFile) {
96
+ logging.file = logFile;
97
+ }
98
+ // Merge partial configs
99
+ if (Object.keys(sandbox).length > 0) {
100
+ config.sandbox = sandbox;
101
+ }
102
+ if (Object.keys(templates).length > 0) {
103
+ config.templates = templates;
104
+ }
105
+ if (Object.keys(logging).length > 0) {
106
+ config.logging = logging;
107
+ }
108
+ return config;
109
+ }
110
+ /**
111
+ * Load configuration from a JSON file.
112
+ */
113
+ async function loadConfigFile(configPath) {
114
+ try {
115
+ const content = await fs.readFile(configPath, 'utf-8');
116
+ return JSON.parse(content);
117
+ }
118
+ catch {
119
+ // Config file doesn't exist or is invalid
120
+ return {};
121
+ }
122
+ }
123
+ /**
124
+ * Deep merge two configuration objects.
125
+ */
126
+ function mergeConfig(base, override) {
127
+ return {
128
+ sandbox: {
129
+ ...base.sandbox,
130
+ ...override.sandbox,
131
+ },
132
+ templates: {
133
+ ...base.templates,
134
+ ...override.templates,
135
+ },
136
+ logging: {
137
+ ...base.logging,
138
+ ...override.logging,
139
+ },
140
+ read_only: override.read_only ?? base.read_only,
141
+ };
142
+ }
143
+ /**
144
+ * Find config file in current directory or parent directories.
145
+ */
146
+ async function findConfigFile() {
147
+ const configNames = ['mcp-file-forge.json', '.mcp-file-forge.json'];
148
+ let currentDir = process.cwd();
149
+ // Search up to 5 levels
150
+ for (let i = 0; i < 5; i++) {
151
+ for (const name of configNames) {
152
+ const configPath = path.join(currentDir, name);
153
+ try {
154
+ await fs.access(configPath);
155
+ return configPath;
156
+ }
157
+ catch {
158
+ // File doesn't exist, continue
159
+ }
160
+ }
161
+ const parentDir = path.dirname(currentDir);
162
+ if (parentDir === currentDir)
163
+ break;
164
+ currentDir = parentDir;
165
+ }
166
+ return null;
167
+ }
168
+ /**
169
+ * Global configuration instance.
170
+ */
171
+ let globalConfig = null;
172
+ /**
173
+ * Load and merge configuration from all sources.
174
+ *
175
+ * Priority (highest to lowest):
176
+ * 1. CLI arguments (not implemented yet)
177
+ * 2. Environment variables
178
+ * 3. Config file
179
+ * 4. Built-in defaults
180
+ */
181
+ export async function loadConfig() {
182
+ if (globalConfig) {
183
+ return globalConfig;
184
+ }
185
+ // Start with defaults
186
+ let config = { ...DEFAULT_CONFIG };
187
+ // Load config file if found
188
+ const configPath = await findConfigFile();
189
+ if (configPath) {
190
+ const fileConfig = await loadConfigFile(configPath);
191
+ config = mergeConfig(config, fileConfig);
192
+ console.error(`[config] Loaded config from ${configPath}`);
193
+ }
194
+ // Apply environment variables (higher priority)
195
+ const envConfig = parseEnvironment();
196
+ config = mergeConfig(config, envConfig);
197
+ // Validate the final config
198
+ const result = ServerConfigSchema.safeParse(config);
199
+ if (!result.success) {
200
+ console.error('[config] Warning: Invalid configuration, using defaults');
201
+ console.error(result.error.issues);
202
+ globalConfig = DEFAULT_CONFIG;
203
+ return DEFAULT_CONFIG;
204
+ }
205
+ globalConfig = result.data;
206
+ return result.data;
207
+ }
208
+ /**
209
+ * Get the current configuration.
210
+ */
211
+ export function getConfig() {
212
+ if (!globalConfig) {
213
+ throw new Error('Configuration not loaded. Call loadConfig() first.');
214
+ }
215
+ return globalConfig;
216
+ }
217
+ /**
218
+ * Reset configuration (useful for testing).
219
+ */
220
+ export function resetConfig() {
221
+ globalConfig = null;
222
+ }
223
+ /**
224
+ * Get default configuration.
225
+ */
226
+ export function getDefaultConfig() {
227
+ return { ...DEFAULT_CONFIG };
228
+ }
229
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD;;GAEG;AACH,MAAM,cAAc,GAAiB;IACnC,OAAO,EAAE;QACP,aAAa,EAAE,CAAC,GAAG,CAAC;QACpB,YAAY,EAAE,CAAC,oBAAoB,EAAE,YAAY,CAAC;QAClD,eAAe,EAAE,KAAK;QACtB,aAAa,EAAE,SAAS,EAAE,QAAQ;QAClC,SAAS,EAAE,EAAE;KACd;IACD,SAAS,EAAE;QACT,KAAK,EAAE,CAAC,aAAa,CAAC;KACvB;IACD,OAAO,EAAE;QACP,KAAK,EAAE,MAAM;KACd;IACD,SAAS,EAAE,KAAK;CACjB,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,GAAG,iBAAiB,CAAC;AAErC;;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OAAO,CAAC,KAAK,CAAC,+BAA+B,UAAU,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED,gDAAgD;IAChD,MAAM,SAAS,GAAG,gBAAgB,EAAE,CAAC;IACrC,MAAM,GAAG,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAExC,4BAA4B;IAC5B,MAAM,MAAM,GAAG,kBAAkB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACpD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,CAAC,KAAK,CAAC,yDAAyD,CAAC,CAAC;QACzE,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACnC,YAAY,GAAG,cAAc,CAAC;QAC9B,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC;IAC3B,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS;IACvB,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IACxE,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW;IACzB,YAAY,GAAG,IAAI,CAAC;AACtB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,EAAE,GAAG,cAAc,EAAE,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * MCP File Forge - Entry Point
4
+ *
5
+ * A Model Context Protocol server for secure file operations
6
+ * and project scaffolding.
7
+ */
8
+ export { createSandboxServer } from './server.js';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;GAKG;AAKH,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC"}
package/build/index.js ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * MCP File Forge - Entry Point
4
+ *
5
+ * A Model Context Protocol server for secure file operations
6
+ * and project scaffolding.
7
+ */
8
+ import { startServer } from './server.js';
9
+ // Re-export for Smithery scanning
10
+ export { createSandboxServer } from './server.js';
11
+ // Handle uncaught errors
12
+ process.on('uncaughtException', (error) => {
13
+ console.error('[mcp-file-forge] Uncaught exception:', error);
14
+ process.exit(1);
15
+ });
16
+ process.on('unhandledRejection', (reason) => {
17
+ console.error('[mcp-file-forge] Unhandled rejection:', reason);
18
+ process.exit(1);
19
+ });
20
+ // Start the server
21
+ startServer().catch((error) => {
22
+ console.error('[mcp-file-forge] Fatal error:', error);
23
+ process.exit(1);
24
+ });
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,kCAAkC;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD,yBAAyB;AACzB,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,KAAK,EAAE,EAAE;IACxC,OAAO,CAAC,KAAK,CAAC,sCAAsC,EAAE,KAAK,CAAC,CAAC;IAC7D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,MAAM,EAAE,EAAE;IAC1C,OAAO,CAAC,KAAK,CAAC,uCAAuC,EAAE,MAAM,CAAC,CAAC;IAC/D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,mBAAmB;AACnB,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IAC5B,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,KAAK,CAAC,CAAC;IACtD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * MCP File Forge - Security Module
3
+ *
4
+ * Exports all security-related functionality.
5
+ */
6
+ export { Sandbox, getSandbox, resetSandbox } from './sandbox.js';
7
+ export { enableReadOnlyMode, disableReadOnlyMode, isReadOnlyMode, validateWriteAllowed, WRITE_TOOLS, isWriteTool, } from './read-only.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/security/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,oBAAoB,EACpB,WAAW,EACX,WAAW,GACZ,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * MCP File Forge - Security Module
3
+ *
4
+ * Exports all security-related functionality.
5
+ */
6
+ export { Sandbox, getSandbox, resetSandbox } from './sandbox.js';
7
+ export { enableReadOnlyMode, disableReadOnlyMode, isReadOnlyMode, validateWriteAllowed, WRITE_TOOLS, isWriteTool, } from './read-only.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/security/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,oBAAoB,EACpB,WAAW,EACX,WAAW,GACZ,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * MCP File Forge - Read-Only Mode
3
+ *
4
+ * Controls whether write operations are allowed.
5
+ */
6
+ import type { FileForgeError } from '../types.js';
7
+ /**
8
+ * Enable read-only mode (disables all write operations).
9
+ */
10
+ export declare function enableReadOnlyMode(): void;
11
+ /**
12
+ * Disable read-only mode (allows write operations).
13
+ */
14
+ export declare function disableReadOnlyMode(): void;
15
+ /**
16
+ * Check if read-only mode is enabled.
17
+ */
18
+ export declare function isReadOnlyMode(): boolean;
19
+ /**
20
+ * Validate that a write operation is allowed.
21
+ * Returns an error if in read-only mode.
22
+ */
23
+ export declare function validateWriteAllowed(): FileForgeError | null;
24
+ /**
25
+ * List of tool names that require write access.
26
+ */
27
+ export declare const WRITE_TOOLS: readonly ["write_file", "create_directory", "copy_file", "move_file", "delete_file", "scaffold_project"];
28
+ /**
29
+ * Check if a tool requires write access.
30
+ */
31
+ export declare function isWriteTool(toolName: string): boolean;
32
+ //# sourceMappingURL=read-only.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-only.d.ts","sourceRoot":"","sources":["../../src/security/read-only.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAOlD;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAExC;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,cAAc,GAAG,IAAI,CAY5D;AAED;;GAEG;AACH,eAAO,MAAM,WAAW,0GAOd,CAAC;AAEX;;GAEG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAErD"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * MCP File Forge - Read-Only Mode
3
+ *
4
+ * Controls whether write operations are allowed.
5
+ */
6
+ /**
7
+ * Global read-only state.
8
+ */
9
+ let readOnlyMode = false;
10
+ /**
11
+ * Enable read-only mode (disables all write operations).
12
+ */
13
+ export function enableReadOnlyMode() {
14
+ readOnlyMode = true;
15
+ }
16
+ /**
17
+ * Disable read-only mode (allows write operations).
18
+ */
19
+ export function disableReadOnlyMode() {
20
+ readOnlyMode = false;
21
+ }
22
+ /**
23
+ * Check if read-only mode is enabled.
24
+ */
25
+ export function isReadOnlyMode() {
26
+ return readOnlyMode;
27
+ }
28
+ /**
29
+ * Validate that a write operation is allowed.
30
+ * Returns an error if in read-only mode.
31
+ */
32
+ export function validateWriteAllowed() {
33
+ if (readOnlyMode) {
34
+ return {
35
+ code: 'WRITE_DISABLED',
36
+ message: 'Write operations are disabled in read-only mode',
37
+ details: {
38
+ mode: 'read-only',
39
+ hint: 'Set MCP_FILE_FORGE_READ_ONLY=false to enable write operations',
40
+ },
41
+ };
42
+ }
43
+ return null;
44
+ }
45
+ /**
46
+ * List of tool names that require write access.
47
+ */
48
+ export const WRITE_TOOLS = [
49
+ 'write_file',
50
+ 'create_directory',
51
+ 'copy_file',
52
+ 'move_file',
53
+ 'delete_file',
54
+ 'scaffold_project',
55
+ ];
56
+ /**
57
+ * Check if a tool requires write access.
58
+ */
59
+ export function isWriteTool(toolName) {
60
+ return WRITE_TOOLS.includes(toolName);
61
+ }
62
+ //# sourceMappingURL=read-only.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-only.js","sourceRoot":"","sources":["../../src/security/read-only.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;GAEG;AACH,IAAI,YAAY,GAAG,KAAK,CAAC;AAEzB;;GAEG;AACH,MAAM,UAAU,kBAAkB;IAChC,YAAY,GAAG,IAAI,CAAC;AACtB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB;IACjC,YAAY,GAAG,KAAK,CAAC;AACvB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB;IAClC,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO;YACL,IAAI,EAAE,gBAAgB;YACtB,OAAO,EAAE,iDAAiD;YAC1D,OAAO,EAAE;gBACP,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,+DAA+D;aACtE;SACF,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,YAAY;IACZ,kBAAkB;IAClB,WAAW;IACX,WAAW;IACX,aAAa;IACb,kBAAkB;CACV,CAAC;AAEX;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,QAAgB;IAC1C,OAAO,WAAW,CAAC,QAAQ,CAAC,QAAwC,CAAC,CAAC;AACxE,CAAC"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * MCP File Forge - Sandbox Security Layer
3
+ *
4
+ * Path validation and access control for file operations.
5
+ */
6
+ import type { SandboxConfig, FileForgeError } from '../types.js';
7
+ /**
8
+ * Sandbox manager for validating and controlling file access.
9
+ */
10
+ export declare class Sandbox {
11
+ private config;
12
+ private resolvedAllowedPaths;
13
+ private initialized;
14
+ constructor(config?: Partial<SandboxConfig>);
15
+ /**
16
+ * Initialize the sandbox by resolving all allowed paths to absolute paths.
17
+ */
18
+ initialize(): Promise<void>;
19
+ /**
20
+ * Check if a path is within the allowed sandbox paths.
21
+ */
22
+ isPathAllowed(targetPath: string): boolean;
23
+ /**
24
+ * Validate a path and return error if not allowed.
25
+ */
26
+ validatePath(targetPath: string): Promise<FileForgeError | null>;
27
+ /**
28
+ * Check if a path contains traversal attempts.
29
+ */
30
+ private hasPathTraversal;
31
+ /**
32
+ * Validate file size against limits.
33
+ */
34
+ validateFileSize(size: number): FileForgeError | null;
35
+ /**
36
+ * Validate recursion depth.
37
+ */
38
+ validateDepth(depth: number): FileForgeError | null;
39
+ /**
40
+ * Get the current configuration.
41
+ */
42
+ getConfig(): SandboxConfig;
43
+ /**
44
+ * Get resolved allowed paths.
45
+ */
46
+ getAllowedPaths(): string[];
47
+ /**
48
+ * Update configuration at runtime.
49
+ */
50
+ updateConfig(config: Partial<SandboxConfig>): void;
51
+ }
52
+ /**
53
+ * Get or create the global sandbox instance.
54
+ */
55
+ export declare function getSandbox(config?: Partial<SandboxConfig>): Sandbox;
56
+ /**
57
+ * Reset the global sandbox (useful for testing).
58
+ */
59
+ export declare function resetSandbox(): void;
60
+ //# sourceMappingURL=sandbox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../src/security/sandbox.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEjE;;GAEG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,oBAAoB,CAAgB;IAC5C,OAAO,CAAC,WAAW,CAAS;gBAEhB,MAAM,GAAE,OAAO,CAAC,aAAa,CAAM;IAU/C;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAoBjC;;OAEG;IACH,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAkC1C;;OAEG;IACG,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAqDtE;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAkBxB;;OAEG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI;IAcrD;;OAEG;IACH,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI;IAcnD;;OAEG;IACH,SAAS,IAAI,aAAa;IAI1B;;OAEG;IACH,eAAe,IAAI,MAAM,EAAE;IAI3B;;OAEG;IACH,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI;CAkBnD;AAOD;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,OAAO,CAKnE;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,IAAI,CAEnC"}