home / mcp / java filesystem mcp server

Java Filesystem MCP Server

Provides filesystem operations and web access tools to enable LLM agents to interact with local files and web resources.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "stephanj-mcpjavafilesystem": {
      "command": "java",
      "args": [
        "-Dspring.ai.mcp.server.stdio=true",
        "-Dspring.main.web-application-type=none",
        "-Dlogging.pattern.console=",
        "-jar",
        "~/JavaFileSystemMCP/target/devoxx-filesystem-0.0.1-SNAPSHOT.jar"
      ]
    }
  }
}

You can run a Java-based MCP server that lets AI agents read and write local files, edit text with diffs, search the filesystem, run shell commands, and fetch web content. It communicates over STDIO, making it easy to integrate with MCP clients and automate common filesystem and web tasks from your AI workflows.

How to use

You interact with the server through an MCP client using STDIO transport. Start the server with the Java runtime and the packaged jar, then invoke tools from your MCP client to read, write, search, edit, and fetch web content. The tools are designed to be safe and predictable, providing structured results and clear error messages.

How to install

Prerequisites include a Java 17+ runtime and Maven 3.6+. You will build the project with Maven and run the resulting jar.

mvn clean package
```

```bash
java -jar target/devoxx-filesystem-0.0.1-SNAPSHOT.jar

Configuration and runtime notes

The server uses STDIO for communication and does not expose HTTP endpoints. It is intended to be launched by an MCP client and controlled via the provided command-line arguments.

-Dspring.ai.mcp.server.stdio=true
-Dspring.main.web-application-type=none
-Dlogging.pattern.console=
-jar
~/JavaFileSystemMCP/target/devoxx-filesystem-0.0.1-SNAPSHOT.jar

Security and usage notes

Be aware that the AI agent will operate with the permissions of the user running the server. The agent can read and write files, execute shell commands, and fetch web content. Run the server in a controlled environment and consider applying appropriate filesystem and network restrictions.

Provided tools at a glance

The server exposes a set of filesystem and web tools that let you perform common operations from your MCP client. These tools are implemented as dedicated services, each returning structured results and detailed error information.

Available tools

ReadFileService.readFile

Reads the complete contents of a file from the file system, handling various encodings and returning the file contents or an informative error.

WriteFileService.writeFile

Creates or overwrites a file with new content, creating parent directories if needed.

EditFileService.editFile

Edits a text file line-by-line and returns a git-style diff showing the changes. Supports a dry-run mode.

SearchFilesService.searchFiles

Recursively searches for files and directories from a starting path using glob patterns, case-insensitive.

ListDirectoryService.listDirectory

Provides a detailed listing of files and directories in a given path, with metadata distinguishing files from folders.

GrepFilesService.grepFiles

Searches for a text pattern in files, returning matching files with line numbers and context (supports regex and case-insensitive search).

CreateDirectoryService.createDirectory

Creates new directories or ensures they exist, including nested structures.

BashService.executeBash

Runs a Bash command in the system shell and captures standard output and error.

FetchWebpageService.fetchWebpage

Fetches content from a webpage and returns the page content, with optional timeout configuration.