pouyan6/mcpserver
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.
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/tmpdirectory - Return Type:
String[]
Getting Started
Prerequisites
- Java 21 or later
- Maven 3.6+ or use the included Maven wrapper
Installation
-
Clone the repository:
git clone <repository-url> cd mcpserver -
Build the project:
./mvnw clean compile
Running the Application
-
Start the server:
./mvnw spring-boot:run -
The server will start on port 8081 (configured in
application.properties) -
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
| Property | Value | Description |
|---|---|---|
spring.application.name | mcpserver | Application name |
server.port | 8081 | Server port |
Adding New Tools
- Create a new tool class with the
@Componentannotation - Add methods annotated with
@Tooland provide descriptions - 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
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the file for details.
Related Links
Troubleshooting
Common Issues
- Port already in use: Change the port in
application.propertiesor kill the process using port 8081 - Java version mismatch: Ensure you're using Java 21 or later
- 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.