mcp-server-project

ylcn91/mcp-server-project

3.2

If you are the rightful owner of mcp-server-project 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.

MCP Server - Spring AI provides tools for AI assistants to perform recipe searches, POI lookups, and weather information retrieval.

Tools
7
Resources
0
Prompts
0

MCP Server - Spring AI

Provides three tools for AI assistants: recipe search, points of interest (POI) lookup, and weather information.

✨ Features

  • 🍳 Recipe Search: Find recipes from a curated database with 90+ diverse recipes
  • πŸ“ POI Discovery: Locate nearby points of interest using real OpenStreetMap Overpass API
  • 🌀️ Weather Queries: Get current weather information from real Open-Meteo API
  • πŸ”„ Multiple Transports: Supports STDIO (MCP Inspector/Claude Desktop) and HTTP modes
  • πŸ—οΈ Hexagonal Architecture: Clean, maintainable code following ports & adapters pattern
  • ⚑ High Performance: Redis caching, connection pooling, and optimized queries
  • 🐳 Docker Ready: Complete containerization with Docker Compose
  • πŸ“Š Observability: Health checks, metrics, and comprehensive logging

🎯 Quick Start

Prerequisites

  • Java 21 (OpenJDK or Oracle JDK)
  • Maven 3.9+
  • Docker & Docker Compose (recommended)
  • PostgreSQL 15+ (if running without Docker)
  • Redis 7+ (if running without Docker)

1. Clone and Build

git clone <repository-url>
cd mcp-server-project
mvn clean package -DskipTests

2. Start Dependencies with Docker

# Start PostgreSQL and Redis
docker-compose up -d postgres redis

# Wait for services to be ready
docker-compose ps

3. Run the MCP Server

For detailed instructions on running the server with a local database and connecting via MCP Inspector, please see the πŸ§ͺ Testing section below.

πŸ› οΈ Available Tools

1. getRecipe

Searches for recipes from a database of 90+ diverse recipes.

Parameters:

  • query (required): Search term for recipes
  • maxResults (optional): Maximum results to return (default: 10, max: 50)

Example Queries:

  • "turkish" β†’ Turkish cuisine (DΓΆner, Baklava, Hummus, etc.)
  • "dessert" β†’ Sweet treats (Chocolate Cake, Tiramisu, etc.)
  • "vegan" β†’ Plant-based recipes
  • "comfort" β†’ Comfort food (Mac & Cheese, Pot Pie, etc.)

2. getRecentRecipes

Retrieves recently searched recipes from the database.

Parameters:

  • limit (optional): Maximum number of recent recipes (default: 10, max: 20)

3. findPoi

Finds points of interest using real OpenStreetMap data.

Parameters:

  • lat (required): Latitude (-90 to 90)
  • lon (required): Longitude (-180 to 180)
  • radiusMeters (optional): Search radius (default: 1000, max: 50000)
  • poiType (optional): Filter by type

Supported POI Types: restaurant, cafe, hospital, school, bank, hotel, museum, police, supermarket, fuel, parking, and more.

4. getSupportedPoiTypes

Returns all supported POI types for searching.

5. getWeather

Retrieves current weather using real Open-Meteo API.

Parameters:

  • lat (required): Latitude
  • lon (required): Longitude

6. isWeatherAvailable

Checks if weather data is available for a location.

Parameters:

  • lat (required): Latitude
  • lon (required): Longitude

7. getWeatherDataAttribution

Returns the attribution text for the weather data source.

πŸ—οΈ Architecture

src/main/java/com/doksanbir/mcpserver/
β”œβ”€β”€ domain/                 # Core business logic
β”‚   β”œβ”€β”€ entity/            # JPA entities (Recipe)
β”‚   └── valueobject/       # Value objects (RecipeInfo, WeatherInfo, etc.)
β”œβ”€β”€ application/           # Application layer
β”‚   β”œβ”€β”€ port/
β”‚   β”‚   β”œβ”€β”€ input/         # Use case interfaces
β”‚   β”‚   └── output/        # Repository & API interfaces
β”‚   └── usecase/           # Use case implementations
β”œβ”€β”€ infrastructure/        # External integrations
β”‚   β”œβ”€β”€ persistence/       # Database implementations
β”‚   β”œβ”€β”€ external/          # REAL API clients (Overpass, OpenMeteo)
β”‚   └── cache/             # Redis + In-memory caching
β”œβ”€β”€ adapter/               # Adapters layer
β”‚   └── mcp/tool/          # MCP tools (@Tool annotations)
└── config/                # Spring configuration

πŸ”§ Configuration

Environment Variables

VariableDescriptionDefault
SPRING_PROFILES_ACTIVEActive profile (stdio or http)stdio
SPRING_DATASOURCE_URLPostgreSQL connection URLjdbc:postgresql://localhost:5432/mcpserver
SPRING_DATASOURCE_USERNAMEDatabase usernamemcpserver
SPRING_DATASOURCE_PASSWORDDatabase passwordmcpserver
SPRING_DATA_REDIS_HOSTRedis hostlocalhost
SPRING_DATA_REDIS_PORTRedis port6379

Profile-Specific Configurations

STDIO Profile (application-stdio.yml)
  • βœ… Console output: Completely disabled
  • βœ… Logging: File-only (logs/mcp-server-stdio.log)
  • βœ… Banner: Disabled
  • βœ… Web server: Disabled (NONE mode)
HTTP Profile (application-http.yml)
  • βœ… REST endpoints: Enabled on port 8080
  • βœ… Health checks: /actuator/health
  • βœ… Metrics: /actuator/metrics

🐳 Docker Deployment

Complete Stack with Docker Compose

# Build and start everything
docker-compose up -d

# Check services
docker-compose ps

# View logs
docker-compose logs -f mcp-server-http

STDIO Mode in Docker

# Start STDIO service
docker-compose --profile stdio up -d mcp-server-stdio

# Follow logs
docker-compose logs -f mcp-server-stdio

πŸ§ͺ Testing

This section provides instructions for testing the server locally using the MCP Inspector or Claude Desktop.

1. Local Database Setup

This project requires a running PostgreSQL database. Before running the application, you must configure your database credentials in the src/main/resources/application.yml file.

Open src/main/resources/application.yml and update the following spring.datasource properties to match your local PostgreSQL setup:

spring:
  datasource:
    url: jdbc:postgresql://localhost:5432/mcpserver
    username: your_postgres_username
    password: your_postgres_password

Note: Ensure a database named mcpserver exists and that the user has full permissions on it.

If you encounter a Flyway checksum mismatch error upon first run, it means a migration file has changed after it was first applied. You can fix this by running the Flyway repair command with Maven:

mvn flyway:repair

2. Running with MCP Inspector

Once your database is set up, you can connect the server to the MCP Inspector.

  1. Launch MCP Inspector:

    npx mcp-inspector
    
  2. Configure the Server Entry:

    • Transport Type: STDIO
    • Command: java
    • Arguments: Copy and paste the following line, making sure to replace /path/to/your/project with the absolute path to the mcp-server-project directory on your machine.
    -Dspring.profiles.active=stdio -jar /path/to/your/project/target/mcp-server-1.0.0.jar
    

    For example, if your project is at /Users/yalcindoksanbir/mcp-server-project, the arguments would be:

    -Dspring.profiles.active=stdio -jar /Users/yalcindoksanbir/mcp-server-project/target/mcp-server-1.0.0.jar
    
  3. Click "Connect". The server will start, and you can begin calling tools.

3. Running with Claude Desktop

To use this MCP server with Claude Desktop, you need to create a configuration file and register the server within Claude Desktop.

  1. Create MCP Configuration File: Create a file named mcp-config.json with the following content:

    {
      "mcpServers": {
        "mcp-doksanbir": {
          "command": "/bin/bash",
          "args": [
            "/path/to/your/project/run-mcp-silent.sh"
          ]
        }
      }
    }
    

    Replace /path/to/your/project with the absolute path to your project directory.

  2. Configure Claude Desktop:

    • Open Claude Desktop
    • Go to Settings β†’ Developer
    • Under "MCP Configuration File", click "Choose File" and select your mcp-config.json
    • Restart Claude Desktop
  3. Testing with Claude:

    • Start a new conversation with Claude
    • Claude will now have access to the recipe, POI, and weather tools
    • Try queries like:
      • "Find me Italian recipes"
      • "What points of interest are near latitude 40.7128, longitude -74.0060?"
      • "What's the weather like at latitude 51.5074, longitude -0.1278?"
  4. Examples of Claude Interactions:

    Claude Recipe Search Claude searching for recipes

    Claude POI Search Claude finding points of interest

    Claude Weather Information Claude retrieving weather information

    Claude Tool List Claude displaying available tools

4. Example Tool Responses

Here are some examples of successful tool calls and their responses.

getSupportedPoiTypes

Response:

[
  "restaurant",
  "cafe",
  "hotel",
  "hospital",
  "pharmacy",
  "bank",
  "atm",
  "gas_station",
  "parking",
  "park",
  "museum",
  "school",
  "university",
  "shopping_mall",
  "supermarket",
  "cinema",
  "theater",
  "gym",
  "library",
  "police",
  "post_office",
  "place_of_worship",
  "tourist_attraction",
  "bar",
  "nightclub",
  "pub",
  "fast_food",
  "bus_station",
  "train_station",
  "subway_entrance",
  "airport",
  "taxi"
]

πŸš€ Advanced Configuration

Silent Mode for Claude Desktop

For optimal performance with Claude Desktop, the server can be run in silent mode with all logging disabled. This prevents any log output from interfering with the JSON-RPC communication.

  1. Use the provided run-mcp-silent.sh script: This script disables all logging and configures the server for clean JSON-RPC communication.

  2. MCP Configuration File for Silent Mode:

    {
      "mcpServers": {
        "mcp-doksanbir": {
          "command": "/bin/bash",
          "args": [
            "/path/to/your/project/run-mcp-silent.sh"
          ]
        }
      }
    }
    
  3. Script Configuration: The run-mcp-silent.sh script uses the following JVM arguments to disable all logging:

    -Dspring.profiles.active=stdio
    -Dspring.main.banner-mode=off
    -Dlogging.level.root=OFF
    -Dlogging.level.org=OFF
    -Dlogging.pattern.console=
    -Dspring.jpa.show-sql=false
    -Dhibernate.show_sql=false
    -Dorg.hibernate.SQL=false
    

    This ensures a clean communication channel between Claude Desktop and the MCP server.

πŸ“Š Monitoring & Management

Health Checks

When running in HTTP mode, the server exposes health endpoints at /actuator/health.

# Check overall health
curl http://localhost:8080/actuator/health

# Check specific components
curl http://localhost:8080/actuator/health/db
curl http://localhost:8080/actuator/health/redis

Managing Data

The server uses Flyway for database migrations. To reset the database:

# Clean and migrate
mvn flyway:clean flyway:migrate

πŸ”’ Security Considerations

  • The server is designed for local use or in a secure internal network
  • No authentication is implemented in the basic version
  • For production deployment, consider adding:
    • API authentication
    • Rate limiting
    • Input validation
    • Data sanitization

For more information on Docker deployment security, see the .

🀝 Contributing

Contributions are welcome! Please follow these steps:

  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