Skip to content

Commit 0e69a58

Browse files
Minor Filesystem MCP Updates (#428)
1 parent a99eb52 commit 0e69a58

2 files changed

Lines changed: 29 additions & 13 deletions

File tree

mcp-servers/mcp-server-filesystem-edit/README.md

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Filesystem Edit MCP Server
22

3-
Allows for robust editing Markdown and LaTeX files.
3+
Allows for robust editing of Markdown, Office, and LaTeX files.
4+
Your system and configuration will determine which are supported. By default working with Markdown (`.md`) files is always enabled
45

56
This is a [Model Context Protocol](https://github.com/modelcontextprotocol) (MCP) server project.
67

@@ -37,6 +38,12 @@ http://127.0.0.1:25567/sse
3738
```
3839

3940

41+
### Optional Features
42+
- If you have pdflatex installed on your system and you would like `edit_file` to automatically compile LaTeX files for you,
43+
can provide the argument `--enable-pdflatex` when starting the server.
44+
- If the system is Windows, it will automatically you have Office apps installed and will use them to edit `.docx` files and also view `.xlsx` files.
45+
46+
4047
### Setting Working Directory
4148
The server uses a single working directory for security purposes. There are two ways to configure them:
4249

@@ -51,22 +58,24 @@ The server uses a single working directory for security purposes. There are two
5158

5259
### `view_file(path)`
5360
- Reads the content of the file at the given path.
54-
55-
### `edit_file(path, task)`
61+
- NOTE: Currently only certain common file types are supported.
62+
- For viewing:
63+
- Directly can view: `.md`, `.csv`, `.tex`
64+
- Can be viewed through an office app, only on Windows: `.docx`, `.xlsx` (first worksheet)
65+
- These file extensions can be edited:
66+
- Directly on the filesystem: `.md`, `.tex`
67+
- Through an office app, only on Windows: `.docx`
68+
- If you have `pdflatex` installed and provide the `--enable-pdflatex` argument, you can also automatically compile LaTeX files.
69+
70+
### `edit_file(path, task: str)`
5671
- Edits the file at the given path with the provided content according to the task.
5772
- Uses sampling to understand things like conversation history and attachments from the client.
58-
- If the file extension is `.md` or `.tex`, special handling is applied.
5973
- All other file types will return an error.
6074
- If `enable-pdflatex` is set, it will compile the LaTeX file using pdflatex and return the output.
6175

62-
### `add_comments(path, comments)`
76+
### `add_comments(path, only_analyze: bool)`
6377
- Reads the file at the given path, adds comments to the content, and returns suggestions on what to do next.
64-
- Special handling is applied for `.md` and `.tex` files. All other file types will return an error.
65-
66-
67-
### Optional Features
68-
- If you have pdflatex installed on your system and you would like `edit_file` to automatically compile LaTeX files for you,
69-
can provide the argument `--enable-pdflatex` when starting the server.
78+
- If only_analyze is set to true, it will only analyze the comments in the current file and return hints on what to do next without modifying the file.
7079

7180

7281
## Client Configuration

mcp-servers/mcp-server-filesystem-edit/mcp_server_filesystem_edit/server.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Copyright (c) Microsoft. All rights reserved.
22

3+
import logging
34
import sys
45
from pathlib import Path
56

@@ -20,6 +21,8 @@
2021
# Set the name of the MCP server
2122
server_name = "Filesystem Edit MCP Server"
2223

24+
logger = logging.getLogger("mcp_server_filesystem")
25+
2326

2427
VIEW_BY_FILE_EXTENSIONS = [".md", ".tex", ".csv"]
2528
VIEW_CUSTOM_EXTENSIONS = [".docx", ".xlsx", ".csv"]
@@ -44,9 +47,13 @@ async def get_allowed_directory(ctx: Context) -> Path:
4447
else:
4548
roots = [Path(root.uri.path).resolve() for root in list_roots_result.roots if root.uri.path]
4649

47-
roots = [root for root in roots if root.is_dir()]
50+
roots = [root for root in roots if root.is_dir() or (not root.exists() and not root.suffix)]
4851
if roots:
49-
return roots[0]
52+
first_root = roots[0]
53+
if not first_root.exists():
54+
logger.info(f"Creating directory from first root since it does not exist yet: {first_root}")
55+
first_root.mkdir(parents=True, exist_ok=True)
56+
return first_root
5057

5158
raise ValueError("No allowed_directories have been configured and no roots have been set.")
5259

0 commit comments

Comments
 (0)