This is a demo MCP project integrated with a File System MCP Server & Git MCP which can (add, update, read, Delete) the file into you local system and give you git repo info
📁 MCP File System + Git Integration with Spring Boot + OpenAI
🚀 This project showcases how to integrate Model Context Protocol (MCP) servers with a Spring Boot backend and OpenAI LLM, enabling AI-driven file system and Git operations using natural language.
✨ Overview
With this setup, you can:
- 📂 Perform file operations (create, read, update, delete)
- 🧾 Interact with Git repositories (commits, files, search)
- 🤖 Use plain English prompts instead of writing code
- 🔒 Restrict access securely using MCP configuration
🔥 Key Highlights
- Natural language → real system actions
- Multiple MCP servers (Filesystem + Git)
- Secure and controlled access
- AI dynamically selects the correct tool
- Production-ready architecture using Spring AI
🚀 Features
📂 File System MCP
- Create, read, update, delete files
- Directory traversal and search
- File metadata access
🧾 Git MCP
- View commit history
- Read repository files
- Search code in repository
- Explore repository structure
🏗️ Tech Stack
- Java 21 + Spring Boot
- Spring AI
- OpenAI API
- Model Context Protocol (MCP)
- Node.js (Filesystem MCP via npx)
- Python (Git MCP via uv)
📂 Project Structure
D:\Spring AI\
│
├── mcp-example # Spring Boot backend
├── mcp-server # Primary working directory
├── personal_Data # Secondary directory
├── servers # MCP Git server source
│ └── src
│ └── git
⚙️ Setup Instructions
1️⃣ Clone the Repository
git clone <your-repo-url>
cd mcp-example
2️⃣ Set OpenAI API Key
Windows
setx OPENAI_API_KEY "your-api-key"
Mac/Linux
export OPENAI_API_KEY="your-api-key"
🧩 MCP Server Configuration
🔹 Filesystem MCP
{
"mcpServers": {
"filesystem": {
"command": "C:\\Program Files\\nodejs\\npx.cmd",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"D:/Spring AI/mcp-server",
"D:/Spring AI/personal_Data"
]
}
}
}
🔹 Git MCP (Local Setup)
Step 1: Clone MCP Servers
cd "D:/Spring AI"
git clone https://github.com/modelcontextprotocol/servers.git
Step 2: Verify Path
D:/Spring AI/servers/src/git
Step 3: Test Git MCP Server
cd "D:/Spring AI/servers/src/git"
uv run mcp-server-git
👉 If terminal looks stuck → server is running correctly
👉 Press Ctrl + C to stop
Step 4: Update servers.json
{
"mcpServers": {
"filesystem": {
"command": "C:\\Program Files\\nodejs\\npx.cmd",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"D:/Spring AI/mcp-server",
"D:/Spring AI/personal_Data"
]
},
"git": {
"command": "uv",
"args": [
"--directory",
"D:/Spring AI/servers/src/git",
"run",
"mcp-server-git"
]
}
}
}
🚀 Run the Application
mvn spring-boot:run
🧪 API Usage
Endpoint
POST http://localhost:8081/ai/chat?q=<your prompt>
💡 Example Prompts
📂 File Operations
Create a file test.txt in D:/Spring AI/mcp-server
Read the file test.txt
Delete test.txt
🧾 Git Operations
Show last 3 commits from D:/Spring AI/mcp-server
List files in repository D:/Spring AI/mcp-server
Search for "controller" in repo D:/Spring AI/mcp-server
🧠 How It Works
- User sends natural language prompt
- OpenAI understands intent
- Spring AI selects appropriate MCP tool
- MCP server executes the operation
- Response is returned to user
🔒 Security
- Access restricted to configured directories
- Git operations limited to specified repository
- Prevents unauthorized system access
⚠️ Common Issues & Fixes
| Issue | Solution |
| ----------------- | ---------------------------- |
| npx not found | Add Node.js to PATH |
| uv not found | Install via pip install uv |
| Git not working | Ensure .git folder exists |
| MCP not triggered | Use full path in prompt |
| JDBC error | Disable JDBC chat memory |
🚀 Future Improvements
- AI-based code summarization
- Git PR review assistant
- Web UI dashboard
- Multi-repository support
👨💻 Author
Prateek Gupta
⭐ Support
If you found this useful:
- ⭐ Star this repository
- 🔁 Share with others
📌 Troubleshooting Quick Check
cd "D:/Spring AI/servers/src/git"
uv run mcp-server-git
✔ Ensure path is correct
✔ Ensure repository has .git