Token导航 LogoToken导航TokenDH.com
Spring MCP Server Claude Desktop Example logo
AI代理未说明官方级别未说明来源级核验

Spring MCP Server Claude Desktop Example

MCP Server

通过Spring AI的Model Context Protocol(MCP)功能实现Claude AI对外部工具(如天气查询)的调用。

工具数

0

提示词数

0

GitHub Stars

1

资源数

0
Kotlin位置天气ClaudeSpring AIClaude DesktopClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

farrar142-examples

提供方

farrar142-examples

最后核验

2026/5/17 20:22

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

概述

此示例展示了如何利用Spring AI的模型上下文协议(MCP)功能在Claude AI中调用外部工具。

核心功能

MyTool.getWeather: 返回任意天气信息的工具方法 McpConfig.myTools: 将MyTool注册为ToolCallbackProvider

执行方法

  1. 运行Spring Boot应用程序
   ./gradlew bootRun
  1. 运行Claude桌面应用程序
  2. 在Claude Desktop设置中添加MCP服务器

이미지

   {
      "mcpServers": {
         "spring-ai-mcp-weather": {
            "command": "npx",
            "args": ["-y", "mcp-remote", "http://localhost:8080/mcp", "--allow-http"]
         }
      }
   }
  1. 重启 Claude Desktop
  2. 开始与Claude AI对话

- 例:“今天首尔的天气怎么样?”

提交日志

  1. 使用Spring Initializr创建项目

- 模型上下文协议服务器 - Spring Web

  1. 将Spring AI版本更改为1.1.0-M1

- 当前1.0.3版本不支持Streamable HTTP

   // build.gradle.kts
   extra["springAiVersion"] = "1.1.0-M1"
  1. application.yml 配置
   #application.yml
   spring:
    ai:
      mcp:
         server:
            protocol: STREAMABLE
            enabled: true
  1. 工具编写
   //MyTool.kt
   class MyTool {
      private val weathers = arrayOf("Sunny","Rainy","Cloudy")
      @Tool
      fun getWeather(location:String) = weathers.random()
   }
  1. 将Tool注册为Bean
   @Configuration
   class McpConfig {
       @Bean
       fun myTools(): ToolCallbackProvider = MethodToolCallbackProvider.builder().toolObjects(MyTool()).build()
   }
  1. 修改claude_desktop_config.json

이미지

   {
      "mcpServers": {
         "spring-ai-mcp-weather": {
            "command": "npx",
            "args": ["-y", "mcp-remote", "http://localhost:8080/mcp", "--allow-http"]
         }
      }
   }
  1. SpringBoot运行后重启Claude Desktop

目录标签

目录标签

Kotlin位置天气ClaudeSpring AI本地部署AI工具集成SpringAIClaudeAI天气查询MCP协议

支持客户端

Claude DesktopClaude

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明none部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP