file-share-mcp 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,7 +9,7 @@ import { fileURLToPath } from 'url';
9
9
  import fs from 'fs';
10
10
  import { setupLogging } from './utils/logger.js';
11
11
  import { getConfig } from './utils/config-manager.js';
12
- import { getSharedFiles, validateSafePath } from './utils/file-manager.js';
12
+ import { getSharedFiles, validateSafePath, writeSharedFile, copyToSharedFolder } from './utils/file-manager.js';
13
13
  import { VERSION } from './version.js';
14
14
  const __filename = fileURLToPath(import.meta.url);
15
15
  const __dirname = path.dirname(__filename);
@@ -133,6 +133,42 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
133
133
  required: ['filename'],
134
134
  },
135
135
  },
136
+ {
137
+ name: 'write_file',
138
+ description: 'Write text content to a new file in the shared folder, making it immediately available to the user.',
139
+ inputSchema: {
140
+ type: 'object',
141
+ properties: {
142
+ filename: {
143
+ type: 'string',
144
+ description: 'Name of the file to create (e.g. "report.md"). Must not contain path separators.',
145
+ },
146
+ content: {
147
+ type: 'string',
148
+ description: 'Text content to write into the file.',
149
+ },
150
+ },
151
+ required: ['filename', 'content'],
152
+ },
153
+ },
154
+ {
155
+ name: 'copy_file',
156
+ description: 'Copy an existing file from the agent workspace to the shared folder, making it available to the user.',
157
+ inputSchema: {
158
+ type: 'object',
159
+ properties: {
160
+ source_path: {
161
+ type: 'string',
162
+ description: 'Absolute path to the source file in the agent workspace.',
163
+ },
164
+ filename: {
165
+ type: 'string',
166
+ description: 'Optional target filename in the shared folder. Defaults to the source file basename.',
167
+ },
168
+ },
169
+ required: ['source_path'],
170
+ },
171
+ },
136
172
  ],
137
173
  };
138
174
  });
@@ -192,6 +228,26 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
192
228
  content: [{ type: 'text', text: content }],
193
229
  };
194
230
  }
231
+ case 'write_file': {
232
+ const { filename, content } = z.object({
233
+ filename: z.string(),
234
+ content: z.string(),
235
+ }).parse(args);
236
+ const dest = writeSharedFile(filename, content);
237
+ return {
238
+ content: [{ type: 'text', text: `File "${path.basename(dest)}" written to shared folder.` }],
239
+ };
240
+ }
241
+ case 'copy_file': {
242
+ const { source_path, filename } = z.object({
243
+ source_path: z.string(),
244
+ filename: z.string().optional(),
245
+ }).parse(args);
246
+ const copiedName = copyToSharedFolder(source_path, filename);
247
+ return {
248
+ content: [{ type: 'text', text: `File "${copiedName}" copied to shared folder.` }],
249
+ };
250
+ }
195
251
  default:
196
252
  throw new Error(`Tool not found: ${name}`);
197
253
  }
@@ -37,3 +37,18 @@ export function deleteFile(filename) {
37
37
  fs.unlinkSync(fullPath);
38
38
  }
39
39
  }
40
+ export function writeSharedFile(filename, content) {
41
+ const dest = validateSafePath(filename);
42
+ fs.writeFileSync(dest, content, 'utf-8');
43
+ return dest;
44
+ }
45
+ export function copyToSharedFolder(sourcePath, filename) {
46
+ const targetFilename = filename ?? path.basename(sourcePath);
47
+ const stats = fs.statSync(sourcePath);
48
+ if (!stats.isFile()) {
49
+ throw new Error(`Source path is not a file: ${sourcePath}`);
50
+ }
51
+ const dest = validateSafePath(targetFilename);
52
+ fs.copyFileSync(sourcePath, dest);
53
+ return targetFilename;
54
+ }
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = '1.0.1';
1
+ export const VERSION = '1.0.2';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "file-share-mcp",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "MCP server for bidirectional file sharing between AI agents and users, with a built-in web GUI",
5
5
  "author": "",
6
6
  "license": "ISC",