mcpserver

pouyan6/mcpserver

3.1

If you are the rightful owner of mcpserver and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

A Spring Boot-based Model Context Protocol (MCP) server that provides file system tools for AI interactions.

Tools
1
Resources
0
Prompts
0

MCP Server

A Spring Boot-based Model Context Protocol (MCP) server that provides file system tools for AI interactions.

Overview

This project implements an MCP server using Spring Boot and Spring AI framework. It exposes file system operations as tools that can be consumed by AI models through the MCP protocol.

Features

  • File System Tools: Provides tools to list files in specified directories
  • MCP Protocol Support: Built on Spring AI's MCP server implementation
  • RESTful API: Exposes MCP endpoints through Spring Web MVC
  • Modular Architecture: Clean separation of tools and configuration

Technology Stack

  • Java 21
  • Spring Boot 3.4.4
  • Spring AI 1.0.0-M6 (with MCP server support)
  • Maven for dependency management

Project Structure

src/
├── main/
│   ├── java/com/example/mcpserver/
│   │   ├── McpServerApplication.java      # Main Spring Boot application
│   │   ├── McpServerConfiguration.java    # MCP tool configuration
│   │   └── FileTool.java                  # File system tool implementation
│   └── resources/
│       └── application.properties         # Application configuration
└── test/
    └── java/com/example/mcpserver/
        └── McpServerApplicationTests.java # Unit tests

Tools Available

FileTool

  • Method: listFiles()
  • Description: Returns all files in the /Users/pouyan/tmp directory
  • Return Type: String[]

Getting Started

Prerequisites

  • Java 21 or later
  • Maven 3.6+ or use the included Maven wrapper

Installation

  1. Clone the repository:

    git clone <repository-url>
    cd mcpserver
    
  2. Build the project:

    ./mvnw clean compile
    

Running the Application

  1. Start the server:

    ./mvnw spring-boot:run
    
  2. The server will start on port 8081 (configured in application.properties)

  3. Access the MCP server endpoints at:

    http://localhost:8081
    

Building for Production

Create a production-ready JAR:

./mvnw clean package
java -jar target/mcpserver-0.0.1-SNAPSHOT.jar

Configuration

Application Properties

PropertyValueDescription
spring.application.namemcpserverApplication name
server.port8081Server port

Adding New Tools

  1. Create a new tool class with the @Component annotation
  2. Add methods annotated with @Tool and provide descriptions
  3. Register the tool in McpServerConfiguration.java

Example:

@Component
public class MyTool {
    
    @Tool(description = "Description of what this tool does")
    public String myToolMethod(String parameter) {
        // Tool implementation
        return "result";
    }
}

API Documentation

The MCP server exposes standard MCP protocol endpoints. Refer to the MCP specification for detailed API documentation.

Development

Testing

Run the test suite:

./mvnw test

Code Style

The project follows standard Java and Spring Boot conventions.

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the file for details.

Related Links

Troubleshooting

Common Issues

  1. Port already in use: Change the port in application.properties or kill the process using port 8081
  2. Java version mismatch: Ensure you're using Java 21 or later
  3. Maven build issues: Try cleaning the project with ./mvnw clean

Logs

Check application logs for debugging information. Logs will show tool registration and MCP server startup details.