farisahmed123/spring-weather-mcp-server
3.2
If you are the rightful owner of spring-weather-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
A Spring Boot MCP server designed for handling weather data, utilizing an H2 in-memory database and providing RESTful endpoints for data access.
Spring Weather MCP Server
A Spring Boot MCP (Model Context Protocol) server for weather data.
Endpoints
- GET /api/greet?name=YourName — Returns a greeting.
- GET /api/weather — Returns all weather data.
- GET /api/weather/{city} — Returns weather data for a specific city.
Database
- Uses H2 in-memory database by default.
- Sample data is loaded from src/main/resources/data.sql.
Running
- Install Java 17+ and Gradle.
- In this directory, run:
or using the Gradle wrapper:
gradle bootRun./gradlew bootRun - Access endpoints at http://localhost:8080/api/...
MCP Structure
- Model: model/Weather.java
- Context: context/WeatherService.java, context/DBService.java
- Protocol: protocol/WeatherController.java, protocol/GreetController.java, protocol/DBController.java
Configuration
Create src/main/resources/application.properties with your database configuration:
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect