OS

ogulcanarbc/spring-ai-mcp-client

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

44 stars 2 forks 质量 45 趋势 0

MCP 客户端应用,利用 Spring AI。它与支持 MCP 协议的服务器集成,实现 AI 驱动的聊天交互。

概览

模型上下文协议(MCP)客户端应用采用 Spring AI 和 Anthropic Claude 模型(或 OpenAI)。它与支持 MCP 协议的服务器集成,实现 AI 驱动的聊天交互。 MCP 客户端是模型上下文协议(MCP)架构中的关键组件,负责建立和管理与 MCP 服务器的连接。它实现协议的客户端,处理: - 协议版本协商以确保与服务器兼容 - 能力协商以确定可用功能 - 消息传输和 JSON-RPC 通信 - 工具发现与执行 - 资源访问与管理 - 提示系统交互 - 可选功能如根管理和采样支持 - 支持 openai 和 anthropic 模型 Java 17+ Maven 或 Gradle Docker(可选)Anthropic API 密钥 或 OpenAI API 密钥 - 来自Anthropic控制台的Anthropic API密钥。- 来自OpenAI控制台的OpenAI API密钥。

概述(AI 翻译)

模型上下文协议(MCP)客户端应用采用 Spring AI 和 Anthropic Claude 模型(或 OpenAI)。它与支持 MCP 协议的服务器集成,实现 AI 驱动的聊天交互。

什么是春季MCP客户端

MCP 客户端是模型上下文协议(MCP)架构中的关键组件,负责建立和管理与 MCP 服务器的连接。 它实现协议的客户端,处理:

  • 协议版本协商以确保与服务器的兼容性
  • 能力协商以确定可用功能
  • 消息传输与JSON-RPC通信
  • 工具发现与执行
  • 资源访问与管理
  • 提示系统交互
  • 可选功能,如根管理和采样支持
  • 支持 openai 和 anthropic 模型

要求

Java 17+ 梅文或格拉德尔 Docker(可选) Anthropic API 密钥 或 OpenAI API 密钥

  • 来自Anthropic控制台的Anthropic API密钥。
  • OpenAI API密钥,来自OpenAI控制台。

安装

1.克隆仓库

Git 克隆 CD SPRING-AI-MCP-CLIENT

2.MCP 服务器配置

MCP服务器信息必须添加到MCP服务器中。

本页由 AI 翻译,技术细节请以原文为准。

README

spring-ai-mcp-client

The Model Context Protocol (MCP) client application utilizes Spring AI and Anthropic Claude models (Or OpenAI). It integrates with MCP protocol-supported servers to enable AI-powered chat interactions.

What is Spring MCP Client

The MCP Client is a key component in the Model Context Protocol (MCP) architecture, responsible for establishing and managing connections with MCP servers. It implements the client-side of the protocol, handling:

- Protocol version negotiation to ensure compatibility with servers
- Capability negotiation to determine available features
- Message transport and JSON-RPC communication
- Tool discovery and execution
- Resource access and management
- Prompt system interactions
- Optional features like roots management and sampling support
- Supports openai and anthropic models

Requirements

Java 17+
Maven or Gradle
Docker (Optional)
Anthropic API key Or OpenAI API key

Installation

1. Clone Repository

    git clone 
    cd spring-ai-mcp-client

2. MCP Server Configuration

The MCP server information must be added to the mcp-servers.json file as follows.

{
    "mcpServers":{
        "any-mcp-server":{
          "command":"node",
          "args":[
            "any-mcp-server/build/index.js"
          ]
        }
    }
}

3. Spring Configuration

The application.yml file should be configured as follows:

spring:
  ai:
    mcp:
      client:
        enabled: true
        name: any-mcp-server # MCP server name
        version: 1.0.0
        type: SYNC
        request-timeout: 20s
        stdio:
          root-change-notification: true
          servers-configuration: classpath:mcp-servers.json # MCP server config such/same as claude desktop configs.
    anthropic:
      api-key: ${ANTHROPIC_API_KEY}
#   openai:
#     api-key:  ${OPENAI_API_KEY}  
server:
  port: 8081

4. Run Applicaton

mvn clean install
mvn spring-boot:run

Usage

Once the application is running, it can be accessed via the following endpoint:

You can start a chat with the following cURL command:

curl -X GET "http://localhost:8081/ai?message=Hello" -H "Accept: application/json"

在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers":{ "any-mcp-server":{ "command":"node", "args":[ "any-mcp-server/build/index.js" ] } } }