MCP Spring Boot Server

MCP Spring Boot Server

site icon
2025.03.29 0
Java天气信息服务RESTful APIServer-Sent Events位置服务
MCP Spring Boot Server 是一个基于Spring Boot框架实现的Model Context Protocol (MCP)服务器,主要提供天气信息服务。它通过MCP接口提供RESTful API端点,支持Server-Sent Events (SSE),并集成了Spring Boot 3.x。该服务器适用于需要天气信息服务的应用场景,如天气预报应用、旅行规划应用等。
View on GitHub

Overview

基本能力

产品定位

MCP Spring Boot Server 是一个基于Spring Boot框架实现的Model Context Protocol (MCP)服务器,主要提供天气信息服务。

核心功能

  • 通过MCP提供天气信息服务
  • 提供RESTful API端点
  • 支持Server-Sent Events (SSE)
  • 自动工具注册
  • Spring Boot 3.x集成

适用场景

  • 天气预报应用
  • 旅行规划应用
  • 需要天气信息的其他应用

工具列表

  • mcp-facade-generator: 用于生成MCP Facade的工具

常见问题解答

  1. 编译时出现 IllegalArgumentException
  2. 解决方案: 在IntelliJ IDEA中添加VM选项 -Djps.track.ap.dependencies=false,然后重新构建项目。

使用教程

使用依赖

  • JDK 17或更高版本
  • Maven 3.6.x或更高版本
  • Spring Boot 3.2.0或更高版本

安装教程

  1. 克隆仓库 bash git clone https://github.com/yourusername/mcp-springboot-server.git cd mcp-springboot-server
  2. 构建项目 bash mvn clean install
  3. 运行应用 bash mvn spring-boot:run

调试方式

  1. 使用提供的 ClientSseTest 类进行测试 ```java public class ClientSseTest { public static void main(String[] args) { var transport = new HttpClientSseClientTransport("http://localhost:8080"); var client = McpClient.sync(transport).build();
       try {
           client.initialize();
           client.ping();
    
           // 列出可用的工具
           McpSchema.ListToolsResult toolsList = client.listTools();
           System.out.println("Available Tools = " + toolsList);
    
           client.closeGracefully();
       } catch (Exception e) {
           e.printStackTrace();
       }
    

    } } ```

许可证

该项目遵循 Apache-2.0 开源许可条款,请参阅 Apache-2.0 了解完整条款。