Logo von Java 文件系统与网页 MCP 服务器

Java 文件系统与网页 MCP 服务器

Community
stephanj

This project implements a Model Context Protocol (MCP) server that provides filesystem operations and web access tools for Large Language Model (LLM) agents. It enables AI assistants to interact with…

Herausgeberstephanj
RepositoryMCPJavaFileSystem
SpracheJava
Forks
11
Sterne
25
Verfügbare Tools
0
Transporttypstdio
Kategorien
Links
  • Tools mit KI-Workflows verbinden

    Java 文件系统与网页 MCP 服务器 stellt MCP-Funktionen bereit, die kompatible KI-Clients und Agenten nutzen können.

  • 0 verfügbare Tools

    Sehen Sie sich unten die aufrufbaren Aktionen an, einschließlich Namen und Beschreibungen, sofern der Server diese bereitstellt.

  • Konfiguration zum Kopieren

    Nutzen Sie die Installationsbeispiele, um diesen Server in Ihrem bevorzugten MCP-Client zu konfigurieren.

  • Open-Source-Kennzahlen

    25 Sterne und 11 Forks im verlinkten Repository.

Java Filesystem & Web MCP Server

This project implements a Model Context Protocol (MCP) server that provides filesystem operations and web access tools for Large Language Model (LLM) agents. It enables AI assistants to interact with both the local filesystem and web resources through a set of well-defined operations.

Features

The server provides the following operations:

Filesystem Operations

  • Reading Files: Read the complete contents of a file with proper encoding detection
  • Writing Files: Create or overwrite files with new content
  • Editing Files: Make line-based edits with git-style diff generation
  • Searching Files: Recursively search for files and directories using glob patterns
  • Listing Directories: Get detailed listings of directory contents
  • Directory Creation: Create directories and nested directory structures
  • Grep Files: Search for text patterns within files with line numbers and context, similar to Unix grep command
  • Bash Command: Execute bash commands in the system shell and capture their output

Web Operations

  • Web Page Fetching: Retrieve content from web pages with configurable timeouts
  • HTML Content Extraction: Extract text content from HTML documents

These operations are exposed as tools for Large Language Models using the Model Context Protocol (MCP), allowing AI systems to safely interact with the filesystem and access web resources.

Example of the MCP Java tool with DevoxxGenie

Getting Started

Prerequisites

  • Java 17 or higher
  • Maven 3.6+
  • Spring Boot 3.3.6
  • Spring AI MCP Server components

Building the Project

Build the project using Maven:

bash
mvn clean package

Running the Server

The server supports two transport modes:

SSE Mode (HTTP-based, default)

Run the server for SSE-based communication:

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

This starts an HTTP server on port 8081 with the SSE endpoint at /sse.

STDIO Mode (for MCP clients like Claude Desktop or DevoxxGenie)

For STDIO-based communication (required by most MCP clients):

bash
java -Dspring.ai.mcp.server.stdio=true \
     -Dspring.main.web-application-type=none \
     -Dspring.main.banner-mode=off \
     -Dlogging.pattern.console= \
     -jar target/devoxx-filesystem-0.0.1-SNAPSHOT.jar

Important flags for STDIO mode:

  • -Dspring.ai.mcp.server.stdio=true - Enables STDIO transport
  • -Dspring.main.web-application-type=none - Disables the web server
  • -Dspring.main.banner-mode=off - Disables Spring Boot banner (required to avoid corrupting JSON-RPC communication)
  • -Dlogging.pattern.console= - Disables console logging

Tool Services

Filesystem Tools

ReadFileService

java
readFile(String fullPathFile)

Reads the complete contents of a file from the file system. Handles various text encodings and provides detailed error messages if the file cannot be read.

WriteFileService

java
writeFile(String path, String content)

Creates a new file or completely overwrites an existing file with new content. Creates parent directories if they don't exist.

EditFileService

java
editFile(String path, String edits, Boolean dryRun)

Makes line-based edits to a text file. Each edit replaces exact line sequences with new content. Returns a git-style diff showing the changes made. The dryRun parameter allows viewing changes without applying them.

SearchFilesService

java
searchFiles(String path, String pattern)

Recursively searches for files and directories matching a pattern. Searches through all subdirectories from the starting path. The search is case-insensitive and matches partial names.

ListDirectoryService

java
listDirectory(String path)

Gets a detailed listing of all files and directories in a specified path. Results clearly distinguish between files and directories with additional metadata.

GrepFilesService

java
grepFiles(String directory, String pattern, String fileExtension, Boolean useRegex, Integer contextLines, Integer maxResults, Boolean ignoreCase)

Searches for text patterns within files. Returns matching files with line numbers and context. Similar to the Unix 'grep' command but with additional features for context display. Supports regex patterns, case-insensitive search, and context lines before/after matches.

CreateDirectoryService

java
createDirectory(List<String> directories)

Creates new directories or ensures that directories exist. Can create multiple directories in one operation. If a directory already exists, the operation succeeds silently. Perfect for setting up directory structures for projects or ensuring required paths exist.

BashService

java
executeBash(String command, String workingDirectory, Integer timeoutSeconds)

Execute a Bash command in the system shell and return the output. This tool allows running system commands and capturing their standard output and error streams. Use with caution as some commands may have system-wide effects.

Web Tools

FetchWebpageService

java
fetchWebpage(String url, Integer timeoutMs)

Fetches or reads a webpage from a URL and returns its content. The service uses jsoup to connect to the webpage and retrieve its content. The optional timeoutMs parameter allows setting a custom connection timeout.

Testing

Running Unit Tests

A comprehensive set of unit tests is provided for all service classes. Run them using:

bash
mvn test

The tests use JUnit 5 and Mockito for mocking external dependencies like the jsoup library for web requests.

Running Integration Tests

Integration tests verify the STDIO transport by spawning the server as a subprocess. First build the JAR, then run integration tests:

bash
mvn package -DskipTests
mvn test -Pintegration-tests

Test Clients

Test clients are provided to demonstrate MCP protocol usage:

  • ClientStdio.java - Demonstrates STDIO transport communication
  • ClientSse.java - Demonstrates SSE transport communication

Configuration

The application is configured via application.properties:

properties
spring.main.web-application-type=none
spring.main.banner-mode=off
logging.pattern.console=

spring.ai.mcp.server.name=filesystem-server
spring.ai.mcp.server.version=0.0.1

logging.file.name=,/JavaFileSystemMCP/target/filesystem-server.log

Project Structure

JavaFileSystemMCP/
  src/
    main/
      java/
        com/
          devoxx/
            mcp/
              filesystem/
                tools/
                  EditFileService.java
                  ReadFileService.java
                  WriteFileService.java
                  SearchFilesService.java
                  FetchWebpageService.java
                  ListDirectoryService.java
                  CreateDirectoryService.java
                  GrepFilesService.java
                  BashService.java
                McpServerApplication.java
      resources/
        application.properties
    test/
      java/
        com/
          devoxx/
            mcp/
              filesystem/
                tools/
                  ReadFileServiceTest.java
                  WriteFileServiceTest.java
                  EditFileServiceTest.java
                  SearchFilesServiceTest.java
                  FetchWebpageServiceTest.java
                  ListDirectoryServiceTest.java
                  CreateDirectoryServiceTest.java
                  GrepFilesServiceTest.java
                ClientStdio.java
  pom.xml
  README.md

Dependencies

The project uses:

  • Spring Boot 3.3.6
  • Spring AI MCP Server Components
  • Jackson for JSON processing
  • jsoup for HTML parsing and web content retrieval
  • JUnit 5 and Mockito for testing

Implementation Notes

  • The server is designed to operate using the STDIO transport mechanism
  • Banner mode and console logging are disabled to allow the STDIO transport to work properly
  • Error handling provides detailed information about issues encountered during operations
  • Each tool service includes comprehensive error handling and returns results in a standardized JSON format
  • The EditFileService includes sophisticated diff generation for tracking changes
  • The SearchFilesService supports glob patterns for flexible file matching
  • The FetchWebpageService includes configurable timeouts and robust error handling for web requests

Integration with DevoxxGenie MCP Support

This server can be easily integrated with DevoxxGenie using the MCP (Model Context Protocol) support. Here's how to set it up:

Configuration in DevoxxGenie

  1. In DevoxxGenie, access the MCP Server configuration screen
  2. Configure the server with the following settings:
    • Name: JavaFilesystem (or any descriptive name)

    • Transport Type: STDIO

    • Command: Full path to your Java executable (e.g., /Library/Java/JavaVirtualMachines/liberica-jdk-23.jdk/Contents/Home/bin/java)

    • Arguments:

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

      Enter each argument on a new line. You may need to change the path for -jar to point to where you've built the jar.

      Important: The -Dspring.main.banner-mode=off flag is required to disable the Spring Boot banner, which would otherwise interfere with the JSON-RPC communication over STDIO.

Usage with DevoxxGenie

Once configured, DevoxxGenie will automatically discover the tools provided by this MCP server. The AI assistant can then use these tools to:

  1. Read and write files on the local system
  2. Search for files and directories
  3. List directory contents
  4. Make edits to existing files
  5. Search for text patterns within files (grep)
  6. Create directories and nested directory structures
  7. Execute bash commands in the system shell
  8. Fetch web pages and extract content

All operations will be performed with the permissions of the user running the DevoxxGenie application.

Using with Claude Desktop

Edit your claude_desktop_config.json file with the following:

json
{
  "mcpServers": {
    "filesystem": {
      "command": "/Library/Java/JavaVirtualMachines/liberica-jdk-23.jdk/Contents/Home/bin/java",
      "args": [
        "-Dspring.ai.mcp.server.stdio=true",
        "-Dspring.main.web-application-type=none",
        "-Dspring.main.banner-mode=off",
        "-Dlogging.pattern.console=",
        "-jar",
        "~/JavaFileSystemMCP/target/devoxx-filesystem-0.0.1-SNAPSHOT.jar"
      ]
    }
  }
}

You may need to change the path for -jar to point to where you've built the jar.

Important: The -Dspring.main.banner-mode=off flag is required to disable the Spring Boot banner, which would otherwise interfere with the JSON-RPC communication over STDIO.

Security Considerations

When using this server, be aware that:

  • The LLM agent will have access to read and write files on the host system
  • The agent can execute bash commands with the permissions of the user running the application
  • The agent can fetch content from any accessible web URL
  • Consider running the server with appropriate permissions and in a controlled environment
  • The server does not implement authentication or authorization mechanisms
  • Consider network firewall rules if restricting web access is required

Installation

TypingMind
Voraussetzungen:

Node.js 18+

{
  "mcpServers": {
    "stephanj-mcpjavafilesystem": {
      "command": "",
      "args": []
    }
  }
}

Java 文件系统与网页 MCP 服务器 MCP mit mehreren KI-Modellen nutzen

TypingMind bindet MCP-Tools auf Arbeitsbereichsebene ein. Sobald Java 文件系统与网页 MCP 服务器 verbunden ist, können Sie die Integration mit verschiedenen KI-Modellen in TypingMind verwenden, statt sie für jedes Modell separat einzurichten. Diese MCP-Integration läuft lokal über den TypingMind-MCP-Konnektor auf Ihrem Gerät.

Einrichtungsanleitung für den lokalen Konnektor

Nutzen Sie diese Option, wenn der MCP-Server Zugriff auf lokale Dateien, Apps oder private Ressourcen auf Ihrem Computer benötigt.

1

MCP-Einstellungen öffnen

Gehen Sie in TypingMind zu „Einstellungen“, „Erweiterte Einstellungen“ und dann „Model Context Protocol“ und wählen Sie „Konnektor-Setup“.

  1. Öffnen Sie TypingMind in Ihrem Browser.
  2. Klicken Sie auf das Symbol „Optionen“.
  3. Gehen Sie zu „Erweiterte Einstellungen“.
  4. Öffnen Sie den Abschnitt „Model Context Protocol“.
  5. Klicken Sie auf „Konnektor-Setup“ und wählen Sie „Dieses Gerät“.
Einrichtungsbildschirm des TypingMind-MCP-Konnektors mit ausgewählter Option „Dieses Gerät“
2

Konnektor-Befehl ausführen

Wählen Sie „Dieses Gerät“, kopieren Sie den Befehl aus TypingMind und führen Sie ihn im Terminal aus. Lassen Sie den Prozess laufen, solange Sie MCP verwenden.

  1. Kopieren Sie den in TypingMind angezeigten Einrichtungsbefehl.
  2. Öffnen Sie unter macOS Terminal bzw. unter Windows Windows Terminal.
  3. Fügen Sie den Befehl ein und führen Sie ihn aus.
  4. Bestätigen Sie die Paketinstallation, wenn Sie im Terminal zum Fortfahren aufgefordert werden.
  5. Lassen Sie das Terminalfenster geöffnet und den Prozess darin laufen, solange Sie MCP-Tools verwenden.
3

Java 文件系统与网页 MCP 服务器 als Server hinzufügen

Wenn der Konnektorstatus „Bereit“ anzeigt, klicken Sie auf „Server ändern“ und fügen Sie die MCP-Server-Konfiguration ein.

  1. Warten Sie, bis der Konnektorstatus „Bereit“ anzeigt.
  2. Klicken Sie auf „Server ändern“.
  3. Fügen Sie die MCP-Server-Konfiguration für Java 文件系统与网页 MCP 服务器 ein.
  4. Speichern Sie die Serverliste.
  5. Aktualisieren Sie die Ansicht, um bei Bedarf zu prüfen, ob der Konnektor weiterhin bereit ist.
MCP-Einstellungen in TypingMind mit aktivem Server und der Schaltfläche „Server ändern“
{
  "mcpServers": {
    "stephanj-mcpjavafilesystem": {
      "command": "npx",
      "args": [
        "-y",
        "MCPJavaFileSystem"
      ]
    }
  }
}
4

Verbindung modellübergreifend nutzen

Speichern Sie die Serverliste, öffnen Sie „Plugins“ und aktivieren Sie die MCP-Tools von Java 文件系统与网页 MCP 服务器. Wählen Sie dann ein beliebiges unterstütztes KI-Modell in TypingMind und verwenden Sie die Tools im Chat oder weisen Sie sie einem KI-Agenten zu.

  1. Öffnen Sie die Seite „Plugins“ in TypingMind.
  2. Aktivieren Sie die MCP-Tools von Java 文件系统与网页 MCP 服务器.
  3. Starten Sie einen Chat und wählen Sie das KI-Modell, das Sie verwenden möchten.
  4. Nutzen Sie die MCP-Tools im Chat oder weisen Sie sie einem KI-Agenten zu.
  5. Wechseln Sie bei Bedarf zu einem anderen KI-Modell, ohne die MCP-Verbindung erneut herzustellen.
TypingMind-Chat mit aktivierten MCP-Tools und einem ausgewählten KI-Modell
Können Sie mir mit Java 文件系统与网页 MCP 服务器 bei dieser Aufgabe helfen?
Java 文件系统与网页 MCP 服务器
Gerne. Ich habe es gelesen.
Das habe ich mit Java 文件系统与网页 MCP 服务器 gefunden.

Häufig gestellte Fragen

Wofür wird der MCP-Server Java 文件系统与网页 MCP 服务器 verwendet?

Java 文件系统与网页 MCP 服务器 ist ein MCP-Server, über den kompatible KI-Clients auf externe Tools und Kontext zugreifen können. In TypingMind können Sie diesen MCP-Server einmal hinzufügen und seine Tools in Ihrem KI-Arbeitsbereich verfügbar machen.

Kann ich Java 文件系统与网页 MCP 服务器 MCP mit mehreren KI-Modellen in TypingMind verwenden?

Ja. TypingMind bindet MCP-Tools auf Arbeitsbereichsebene ein. So können Sie Java 文件系统与网页 MCP 服务器 mit verschiedenen KI-Modellen wie Claude, ChatGPT, Gemini oder anderen in TypingMind konfigurierten Modellen verwenden, ohne den MCP-Server für jedes Modell separat einzurichten.

Warum Java 文件系统与网页 MCP 服务器 MCP mit TypingMind nutzen?

TypingMind ist eine der besten Oberflächen für LLM-Chats, da es mehrere KI-Modelle, Prompts, Plugins, KI-Agenten, API-Schlüssel und MCP-Tools in einem Arbeitsbereich vereint. Sobald Java 文件系统与网页 MCP 服务器 verbunden ist, können Sie die zugehörigen MCP-Tools mit Ihren bevorzugten Modellen nutzen und Ihre Chat-Abläufe in TypingMind übersichtlich organisieren.

Wie verbinde ich Java 文件系统与网页 MCP 服务器 MCP mit TypingMind?

Java 文件系统与网页 MCP 服务器 wird über den lokalen MCP-Konnektor von TypingMind angebunden. Das ist die beste Wahl, wenn der MCP-Server auf lokale Dateien, Desktop-Apps, Befehlszeilentools oder private Ressourcen auf Ihrem Computer zugreifen muss.

Welche Tools stellt Java 文件系统与网页 MCP 服务器 MCP in TypingMind bereit?

Java 文件系统与网页 MCP 服务器 stellt MCP-Funktionen bereit, die Sie auf der Plugins-Seite in TypingMind aktivieren und im Chat verwenden oder KI-Agenten zuweisen können.

Muss ich meine API-Schlüssel mit TypingMind teilen, um Java 文件系统与网页 MCP 服务器 MCP zu verwenden?

Nein. TypingMind arbeitet vorrangig lokal, sodass Sie die Kontrolle über Ihre Modellanbieter, API-Schlüssel, Prompts und MCP-Konfiguration behalten. Falls Java 文件系统与网页 MCP 服务器 eine Authentifizierung erfordert, fügen Sie beim Erstellen der Verbindung die erforderlichen Header, OAuth-Einstellungen oder die lokale Konfiguration für diesen MCP-Server hinzu.

Ähnliche MCP-Server

Alle

Jetzt eigenen KI-Arbeitsbereich einrichten

Abonnieren Sie unseren Newsletter und erfahren Sie mehr über neue Funktionen und kommende Gewinnspiele 👇