McpServerSample
项目介绍
McpServerSample 是一个基于 Spring Boot 和 Spring AI 的 Model Context Protocol (MCP) 服务器示例项目。 该项目主要提供天气服务功能,通过集成官方天气 API (weather.gov) 实现了以下核心功能:
- 根据经纬度获取指定位置的天气预报信息
- 根据美国州代码获取特定地区的天气警报信息
Power your agent
Install from the publisher. Not a PlugMCP endpoint.
Host a copy with our keys and logs.
No packaged release in the registry yet. Follow the repository README.
Remote URL or a command on your machine? How the two installs differ
Run on PlugMCP
A new server you create. It is not this listing's official endpoint. Use the publisher install when you want their URL and their credentials.
LaunchFrom the publisher
McpServerSample 是一个基于 Spring Boot 和 Spring AI 的 Model Context Protocol (MCP) 服务器示例项目。 该项目主要提供天气服务功能,通过集成官方天气 API (weather.gov) 实现了以下核心功能:
McpServerSample: Java开发的mcpservr示例项目. 是一个基于 Spring Boot 和 Spring AI 的 Model Context Protocol (MCP) 服务器示例项目。 该项目主要提供天气服务功能,通过集成官方天气 API (weather.gov) 实现了以下核心功能.
McpServerSample/
├── src/
│ └── main/
│ ├── java/
│ │ └── com/ai/mcpserver/
│ │ ├── McpServerApplication.java # 应用程序入口类
│ │ └── WeatherService.java # 天气服务实现类
│ └── resources/
├── target/
│ ├── classes/
│ │ ├── application.properties # 应用配置文件
│ │ └── com/
├── pom.xml # Maven 项目配置文件
└── README.md # 项目说明文档
项目提供以下天气相关的服务接口:
getWeatherForecastByLocation
getAlerts
项目通过 Spring AI 的 ToolCallbackProvider 将天气服务方法注册为可供 AI 模型调用的工具。这使得 AI 模型能够直接调用天气服务获取实时天气数据。
克隆或下载项目代码到本地
进入项目根目录
执行 Maven 构建命令:
mvn clean package
在项目根目录执行:
mvn spring-boot:run
构建完成后,在 target 目录下会生成 JAR 文件,执行:
java -jar target/McpServerSample-0.0.1-SNAPSHOT.jar
服务启动后,默认在 8086 端口运行。可以通过以下方式验证服务是否正常启动:
./model-context-protocol/mcp-weather-stdio-server.log 文件中McpServerSample: Java开发的mcpservr示例项目. 是一个基于 Spring Boot 和 Spring AI 的 Model Context Protocol (MCP) 服务器示例项目。 该项目主要提供天气服务功能,通过集成官方天气 API (weather.gov) 实现了以下核心功能.
Tools
No tool list yet. Remote servers get one after the first health check.
FAQ
Copy the stdio config for Cursor, Claude Desktop, Claude Code, or VS Code on this page. It uses the publisher's install, not a PlugMCP proxy.
No required environment variable is listed on this record.
McpServerSample runs locally over stdio.
Last checked 2026-10-27. McpServerSample: Java开发的mcpservr示例项目. 是一个基于 Spring Boot 和 Spring AI 的 Model Context Protocol (MCP) 服务器示例项目。 该项目主要提供天气服务功能,通过集成官方天气 API (weather.gov) 实现了以下核心功能.