mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-04-19 00:33:22 +02:00
Minor updates to filesystem
This commit is contained in:
@@ -44,13 +44,6 @@ Node.js server implementing Model Context Protocol (MCP) for filesystem operatio
|
||||
- List directory contents with [FILE] or [DIR] prefixes
|
||||
- Input: `path` (string)
|
||||
|
||||
- **delete_file**
|
||||
- Remove files or directories
|
||||
- Inputs:
|
||||
- `path` (string)
|
||||
- `recursive` (boolean, optional): For directory deletion
|
||||
- Use with caution - deletions are permanent
|
||||
|
||||
- **move_file**
|
||||
- Move or rename files and directories
|
||||
- Inputs:
|
||||
@@ -79,5 +72,5 @@ Node.js server implementing Model Context Protocol (MCP) for filesystem operatio
|
||||
|
||||
## Notes
|
||||
|
||||
- Exercise caution with `delete_file` (deletes files permanently) and `write_file` (overwrites existing files)
|
||||
- Exercise caution with `write_file`, since it can overwrite an existing file
|
||||
- File paths can be absolute or relative
|
||||
|
||||
@@ -35,11 +35,6 @@ interface ListDirectoryArgs {
|
||||
path: string;
|
||||
}
|
||||
|
||||
interface DeleteFileArgs {
|
||||
path: string;
|
||||
recursive?: boolean;
|
||||
}
|
||||
|
||||
interface MoveFileArgs {
|
||||
source: string;
|
||||
destination: string;
|
||||
@@ -210,30 +205,6 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
||||
required: ["path"],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "delete_file",
|
||||
description:
|
||||
"Remove files or directories from the file system. Can handle both individual " +
|
||||
"files and directories. For directories, you can specify recursive deletion to " +
|
||||
"remove all contents. Use with extreme caution as deletions are permanent and " +
|
||||
"cannot be undone.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
path: {
|
||||
type: "string",
|
||||
description: "Path of the file or directory to delete",
|
||||
},
|
||||
recursive: {
|
||||
type: "boolean",
|
||||
description:
|
||||
"If true, recursively delete directories and their contents. Required for non-empty directories.",
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
required: ["path"],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "move_file",
|
||||
description:
|
||||
@@ -393,18 +364,6 @@ function isListDirectoryArgs(args: unknown): args is ListDirectoryArgs {
|
||||
);
|
||||
}
|
||||
|
||||
function isDeleteFileArgs(args: unknown): args is DeleteFileArgs {
|
||||
const deleteArgs = args as DeleteFileArgs;
|
||||
return (
|
||||
typeof args === "object" &&
|
||||
args !== null &&
|
||||
"path" in args &&
|
||||
typeof deleteArgs.path === "string" &&
|
||||
(deleteArgs.recursive === undefined ||
|
||||
typeof deleteArgs.recursive === "boolean")
|
||||
);
|
||||
}
|
||||
|
||||
function isMoveFileArgs(args: unknown): args is MoveFileArgs {
|
||||
return (
|
||||
typeof args === "object" &&
|
||||
@@ -506,27 +465,6 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
||||
};
|
||||
}
|
||||
|
||||
case "delete_file": {
|
||||
if (!isDeleteFileArgs(args)) {
|
||||
throw new Error("Invalid arguments for delete_file");
|
||||
}
|
||||
const stats = await fs.stat(args.path);
|
||||
if (stats.isDirectory()) {
|
||||
if (args.recursive) {
|
||||
await fs.rm(args.path, { recursive: true });
|
||||
} else {
|
||||
await fs.rmdir(args.path);
|
||||
}
|
||||
} else {
|
||||
await fs.unlink(args.path);
|
||||
}
|
||||
return {
|
||||
content: [
|
||||
{ type: "text", text: `Successfully deleted ${args.path}` },
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
case "move_file": {
|
||||
if (!isMoveFileArgs(args)) {
|
||||
throw new Error("Invalid arguments for move_file");
|
||||
|
||||
Reference in New Issue
Block a user