@mcptoolshop/file-forge 0.1.0 → 0.2.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 +168 -54
  2. package/package.json +1 -1
  3. package/build/config/index.d.ts +0 -29
  4. package/build/config/index.d.ts.map +0 -1
  5. package/build/config/index.js +0 -229
  6. package/build/config/index.js.map +0 -1
  7. package/build/index.d.ts +0 -9
  8. package/build/index.d.ts.map +0 -1
  9. package/build/index.js +0 -23
  10. package/build/index.js.map +0 -1
  11. package/build/security/index.d.ts +0 -8
  12. package/build/security/index.d.ts.map +0 -1
  13. package/build/security/index.js +0 -8
  14. package/build/security/index.js.map +0 -1
  15. package/build/security/read-only.d.ts +0 -32
  16. package/build/security/read-only.d.ts.map +0 -1
  17. package/build/security/read-only.js +0 -62
  18. package/build/security/read-only.js.map +0 -1
  19. package/build/security/sandbox.d.ts +0 -60
  20. package/build/security/sandbox.d.ts.map +0 -1
  21. package/build/security/sandbox.js +0 -231
  22. package/build/security/sandbox.js.map +0 -1
  23. package/build/server.d.ts +0 -20
  24. package/build/server.d.ts.map +0 -1
  25. package/build/server.js +0 -63
  26. package/build/server.js.map +0 -1
  27. package/build/tools/metadata.d.ts +0 -11
  28. package/build/tools/metadata.d.ts.map +0 -1
  29. package/build/tools/metadata.js +0 -423
  30. package/build/tools/metadata.js.map +0 -1
  31. package/build/tools/read.d.ts +0 -11
  32. package/build/tools/read.d.ts.map +0 -1
  33. package/build/tools/read.js +0 -335
  34. package/build/tools/read.js.map +0 -1
  35. package/build/tools/scaffold.d.ts +0 -11
  36. package/build/tools/scaffold.d.ts.map +0 -1
  37. package/build/tools/scaffold.js +0 -345
  38. package/build/tools/scaffold.js.map +0 -1
  39. package/build/tools/search.d.ts +0 -11
  40. package/build/tools/search.d.ts.map +0 -1
  41. package/build/tools/search.js +0 -250
  42. package/build/tools/search.js.map +0 -1
  43. package/build/tools/write.d.ts +0 -11
  44. package/build/tools/write.d.ts.map +0 -1
  45. package/build/tools/write.js +0 -538
  46. package/build/tools/write.js.map +0 -1
  47. package/build/types.d.ts +0 -402
  48. package/build/types.d.ts.map +0 -1
  49. package/build/types.js +0 -146
  50. package/build/types.js.map +0 -1
  51. package/build/utils/errors.d.ts +0 -43
  52. package/build/utils/errors.d.ts.map +0 -1
  53. package/build/utils/errors.js +0 -125
  54. package/build/utils/errors.js.map +0 -1
  55. package/build/utils/index.d.ts +0 -10
  56. package/build/utils/index.d.ts.map +0 -1
  57. package/build/utils/index.js +0 -9
  58. package/build/utils/index.js.map +0 -1
  59. package/build/utils/logger.d.ts +0 -88
  60. package/build/utils/logger.d.ts.map +0 -1
  61. package/build/utils/logger.js +0 -166
  62. package/build/utils/logger.js.map +0 -1
  63. package/build/utils/validation.d.ts +0 -43
  64. package/build/utils/validation.d.ts.map +0 -1
  65. package/build/utils/validation.js +0 -196
  66. package/build/utils/validation.js.map +0 -1
package/README.md CHANGED
@@ -1,33 +1,67 @@
1
- # MCP File Forge
1
+ <p align="center"><img src="logo.png" alt="MCP File Forge" width="200"></p>
2
2
 
3
- A Model Context Protocol (MCP) server for secure file operations and project scaffolding.
3
+ <h1 align="center">MCP File Forge</h1>
4
4
 
5
- ## Features
5
+ <p align="center">
6
+ Secure file operations and project scaffolding for AI agents.
7
+ <br />
8
+ Part of <a href="https://mcptoolshop.com">MCP Tool Shop</a>
9
+ </p>
6
10
 
7
- - **Secure File Operations**: Read, write, copy, move, and delete files with sandboxed access controls
8
- - **Project Scaffolding**: Create projects from templates with variable substitution
9
- - **Windows-First**: Optimized for Windows paths, permissions, and conventions
10
- - **Search Capabilities**: Glob patterns and regex content search
11
- - **Configurable Security**: Define allowed paths, size limits, and read-only modes
11
+ <p align="center">
12
+ <a href="https://www.npmjs.com/package/@mcptoolshop/file-forge"><img alt="npm version" src="https://img.shields.io/npm/v/@mcptoolshop/file-forge"></a>
13
+ <a href="https://github.com/mcp-tool-shop-org/mcp-file-forge/blob/main/LICENSE"><img alt="license" src="https://img.shields.io/npm/l/@mcptoolshop/file-forge"></a>
14
+ <img alt="node" src="https://img.shields.io/badge/node-%3E%3D18-brightgreen">
15
+ </p>
16
+
17
+ ---
18
+
19
+ ## At a Glance
20
+
21
+ MCP File Forge is a [Model Context Protocol](https://modelcontextprotocol.io) (MCP) server that gives AI agents sandboxed, policy-controlled access to the local file system. It ships **17 tools** across five categories:
22
+
23
+ | Category | Tools | Description |
24
+ |----------|-------|-------------|
25
+ | **Reading** | `read_file`, `read_directory`, `read_multiple` | Read files and directory listings |
26
+ | **Writing** | `write_file`, `create_directory`, `copy_file`, `move_file`, `delete_file` | Create, modify, copy, move, and delete |
27
+ | **Search** | `glob_search`, `grep_search`, `find_by_content` | Find files by name pattern or content |
28
+ | **Metadata** | `file_stat`, `file_exists`, `get_disk_usage`, `compare_files` | Inspect size, timestamps, existence |
29
+ | **Scaffolding** | `scaffold_project`, `list_templates` | Create projects from templates with variable substitution |
30
+
31
+ Key properties:
32
+
33
+ - **Sandboxed** -- operations are restricted to explicitly allowed directories.
34
+ - **Read-only mode** -- flip one env var to disable all write tools.
35
+ - **Symlink-safe** -- symlink following is off by default to prevent sandbox escapes.
36
+ - **Windows-first** -- designed for Windows paths and conventions, works everywhere.
37
+ - **Template engine** -- `{{var}}` / `${var}` substitution plus path-level `__var__` renaming.
38
+
39
+ ---
12
40
 
13
41
  ## Installation
14
42
 
15
43
  ```bash
16
- npm install @mcp-tool-shop/file-forge
44
+ npm install -g @mcptoolshop/file-forge
45
+ ```
46
+
47
+ Or run directly with npx:
48
+
49
+ ```bash
50
+ npx @mcptoolshop/file-forge
17
51
  ```
18
52
 
19
- ## Quick Start
53
+ ---
20
54
 
21
- ### With Claude Desktop
55
+ ## Claude Desktop Configuration
22
56
 
23
- Add to your `claude_desktop_config.json`:
57
+ Add the following to your `claude_desktop_config.json`:
24
58
 
25
59
  ```json
26
60
  {
27
61
  "mcpServers": {
28
62
  "file-forge": {
29
- "command": "node",
30
- "args": ["path/to/mcp-file-forge/build/index.js"],
63
+ "command": "npx",
64
+ "args": ["-y", "@mcptoolshop/file-forge"],
31
65
  "env": {
32
66
  "MCP_FILE_FORGE_ALLOWED_PATHS": "C:/Projects,C:/Users/you/Documents"
33
67
  }
@@ -36,69 +70,144 @@ Add to your `claude_desktop_config.json`:
36
70
  }
37
71
  ```
38
72
 
39
- ### Standalone
73
+ If you installed globally you can point directly at the binary:
40
74
 
41
- ```bash
42
- npx @mcp-tool-shop/file-forge
75
+ ```json
76
+ {
77
+ "mcpServers": {
78
+ "file-forge": {
79
+ "command": "mcp-file-forge",
80
+ "env": {
81
+ "MCP_FILE_FORGE_ALLOWED_PATHS": "C:/Projects"
82
+ }
83
+ }
84
+ }
85
+ }
43
86
  ```
44
87
 
45
- ## Available Tools
88
+ ---
89
+
90
+ ## Tool Reference
91
+
92
+ ### Reading
46
93
 
47
- ### File Reading
48
- - `read_file` - Read file contents with encoding and line range options
49
- - `read_directory` - List directory contents with metadata
50
- - `read_multiple` - Batch read multiple files
94
+ | Tool | Description | Key Parameters |
95
+ |------|-------------|----------------|
96
+ | `read_file` | Read file contents | `path`, `encoding?`, `start_line?`, `end_line?`, `max_size_kb?` |
97
+ | `read_directory` | List directory entries | `path`, `recursive?`, `max_depth?`, `include_hidden?`, `pattern?` |
98
+ | `read_multiple` | Batch-read multiple files | `paths`, `encoding?`, `fail_on_error?` |
51
99
 
52
- ### File Writing
53
- - `write_file` - Write or overwrite file contents
54
- - `create_directory` - Create directories
55
- - `copy_file` - Copy files or directories
56
- - `move_file` - Move or rename files
57
- - `delete_file` - Delete files or directories
100
+ ### Writing
101
+
102
+ | Tool | Description | Key Parameters |
103
+ |------|-------------|----------------|
104
+ | `write_file` | Write or overwrite a file | `path`, `content`, `encoding?`, `create_dirs?`, `overwrite?`, `backup?` |
105
+ | `create_directory` | Create a directory | `path`, `recursive?` |
106
+ | `copy_file` | Copy a file or directory | `source`, `destination`, `overwrite?`, `recursive?` |
107
+ | `move_file` | Move or rename | `source`, `destination`, `overwrite?` |
108
+ | `delete_file` | Delete a file or directory | `path`, `recursive?`, `force?` |
58
109
 
59
110
  ### Search
60
- - `glob_search` - Find files matching glob patterns
61
- - `grep_search` - Search file contents with regex
111
+
112
+ | Tool | Description | Key Parameters |
113
+ |------|-------------|----------------|
114
+ | `glob_search` | Find files by glob pattern | `pattern`, `base_path?`, `max_results?`, `include_dirs?` |
115
+ | `grep_search` | Search file contents with regex | `pattern`, `path?`, `glob?`, `case_sensitive?`, `max_results?`, `context_lines?` |
116
+ | `find_by_content` | Literal text search (no regex) | `text`, `path?`, `file_pattern?`, `max_results?` |
62
117
 
63
118
  ### Metadata
64
- - `file_stat` - Get file statistics
65
- - `file_exists` - Check if path exists
119
+
120
+ | Tool | Description | Key Parameters |
121
+ |------|-------------|----------------|
122
+ | `file_stat` | File/directory statistics | `path` |
123
+ | `file_exists` | Check existence and type | `path`, `type?` (`file` / `directory` / `any`) |
124
+ | `get_disk_usage` | Directory size breakdown | `path`, `max_depth?` |
125
+ | `compare_files` | Compare two paths | `path1`, `path2` |
66
126
 
67
127
  ### Scaffolding
68
- - `scaffold_project` - Create project from template
69
- - `list_templates` - List available templates
70
128
 
71
- ## Configuration
129
+ | Tool | Description | Key Parameters |
130
+ |------|-------------|----------------|
131
+ | `scaffold_project` | Create project from template | `template`, `destination`, `variables?`, `overwrite?` |
132
+ | `list_templates` | List available templates | `category?` |
133
+
134
+ Full parameter documentation, examples, and error codes are in the [HANDBOOK.md](HANDBOOK.md).
135
+
136
+ ---
72
137
 
73
- ### Environment Variables
138
+ ## Environment Variables
74
139
 
75
140
  | Variable | Description | Default |
76
141
  |----------|-------------|---------|
77
- | `MCP_FILE_FORGE_ALLOWED_PATHS` | Comma-separated allowed paths | `.` |
78
- | `MCP_FILE_FORGE_READ_ONLY` | Disable write operations | `false` |
79
- | `MCP_FILE_FORGE_MAX_FILE_SIZE` | Max file size in bytes | `104857600` |
80
- | `MCP_FILE_FORGE_LOG_LEVEL` | Logging level | `info` |
142
+ | `MCP_FILE_FORGE_ALLOWED_PATHS` | Comma-separated list of allowed root directories | `.` (cwd) |
143
+ | `MCP_FILE_FORGE_DENIED_PATHS` | Comma-separated denied path glob patterns | `**/node_modules/**`, `**/.git/**` |
144
+ | `MCP_FILE_FORGE_READ_ONLY` | Disable all write operations | `false` |
145
+ | `MCP_FILE_FORGE_MAX_FILE_SIZE` | Maximum file size in bytes | `104857600` (100 MB) |
146
+ | `MCP_FILE_FORGE_MAX_DEPTH` | Maximum recursion depth | `20` |
147
+ | `MCP_FILE_FORGE_FOLLOW_SYMLINKS` | Allow following symlinks outside sandbox | `false` |
148
+ | `MCP_FILE_FORGE_TEMPLATE_PATHS` | Comma-separated template directories | `./templates` |
149
+ | `MCP_FILE_FORGE_LOG_LEVEL` | Log verbosity (`error`, `warn`, `info`, `debug`) | `info` |
150
+ | `MCP_FILE_FORGE_LOG_FILE` | Path to a log file (in addition to stderr) | _none_ |
81
151
 
82
- ### Config File
152
+ ---
83
153
 
84
- Create `mcp-file-forge.json` in the working directory:
154
+ ## Config File
155
+
156
+ Create `mcp-file-forge.json` (or `.mcp-file-forge.json`) in or above your working directory:
85
157
 
86
158
  ```json
87
159
  {
88
160
  "sandbox": {
89
- "allowed_paths": ["./projects"],
90
- "denied_paths": ["**/secrets/**"],
91
- "max_file_size": 52428800
92
- }
161
+ "allowed_paths": ["C:/Projects", "C:/Users/you/Documents"],
162
+ "denied_paths": ["**/secrets/**", "**/.env"],
163
+ "follow_symlinks": false,
164
+ "max_file_size": 52428800,
165
+ "max_depth": 20
166
+ },
167
+ "templates": {
168
+ "paths": ["./templates", "~/.mcp-file-forge/templates"]
169
+ },
170
+ "logging": {
171
+ "level": "info",
172
+ "file": "./logs/mcp-file-forge.log"
173
+ },
174
+ "read_only": false
93
175
  }
94
176
  ```
95
177
 
178
+ Configuration priority (highest wins):
179
+
180
+ 1. Environment variables
181
+ 2. Config file
182
+ 3. Built-in defaults
183
+
184
+ ---
185
+
96
186
  ## Security
97
187
 
98
- - Path sandboxing restricts operations to allowed directories
99
- - Symlink following is disabled by default
100
- - Read-only mode available for safe browsing
101
- - Size limits prevent memory exhaustion
188
+ MCP File Forge enforces several layers of protection to keep AI agents from reaching outside their designated workspace:
189
+
190
+ - **Path sandboxing** -- every path is resolved to an absolute path and checked against the `allowed_paths` list before any I/O occurs.
191
+ - **Denied paths** -- glob patterns that are blocked even within allowed directories (e.g. `**/secrets/**`).
192
+ - **Symlink protection** -- symlinks are not followed by default; if a symlink target resolves outside the sandbox, the operation is denied.
193
+ - **Path traversal detection** -- `..` sequences that would escape the sandbox are rejected.
194
+ - **Size limits** -- files larger than `max_file_size` are refused to prevent memory exhaustion.
195
+ - **Depth limits** -- recursive operations are capped at `max_depth` levels.
196
+ - **Read-only mode** -- set `MCP_FILE_FORGE_READ_ONLY=true` to disable `write_file`, `create_directory`, `copy_file`, `move_file`, `delete_file`, and `scaffold_project`.
197
+ - **Null-byte rejection** -- paths containing `\0` are refused.
198
+ - **Windows long-path guard** -- paths exceeding 32,767 characters are refused.
199
+
200
+ ---
201
+
202
+ ## Documentation
203
+
204
+ | Document | Description |
205
+ |----------|-------------|
206
+ | [HANDBOOK.md](HANDBOOK.md) | Deep-dive: security model, tool reference, templates, architecture, FAQ |
207
+ | [CHANGELOG.md](CHANGELOG.md) | Release history (Keep a Changelog format) |
208
+ | [docs/PLANNING.md](docs/PLANNING.md) | Internal planning and research notes |
209
+
210
+ ---
102
211
 
103
212
  ## Development
104
213
 
@@ -109,17 +218,22 @@ npm install
109
218
  # Build
110
219
  npm run build
111
220
 
112
- # Development mode (watch)
221
+ # Watch mode
113
222
  npm run dev
114
223
 
115
224
  # Run tests
116
225
  npm test
226
+
227
+ # Lint
228
+ npm run lint
117
229
  ```
118
230
 
231
+ ---
232
+
119
233
  ## License
120
234
 
121
- MIT
235
+ [MIT](LICENSE)
122
236
 
123
- ## Author
237
+ ---
124
238
 
125
- mcp-tool-shop
239
+ **Author:** [mcp-tool-shop](https://github.com/mcp-tool-shop)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcptoolshop/file-forge",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "MCP server for file operations and project scaffolding - Windows-first, secure, sandboxed",
5
5
  "type": "module",
6
6
  "main": "./build/index.js",
@@ -1,29 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,229 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACv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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"}
package/build/index.d.ts DELETED
@@ -1,9 +0,0 @@
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 {};
9
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;GAKG"}
package/build/index.js DELETED
@@ -1,23 +0,0 @@
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
- // Handle uncaught errors
10
- process.on('uncaughtException', (error) => {
11
- console.error('[mcp-file-forge] Uncaught exception:', error);
12
- process.exit(1);
13
- });
14
- process.on('unhandledRejection', (reason) => {
15
- console.error('[mcp-file-forge] Unhandled rejection:', reason);
16
- process.exit(1);
17
- });
18
- // Start the server
19
- startServer().catch((error) => {
20
- console.error('[mcp-file-forge] Fatal error:', error);
21
- process.exit(1);
22
- });
23
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,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"}
@@ -1,8 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,8 +0,0 @@
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
@@ -1 +0,0 @@
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"}