# spring-ai-mcp-client

> MCP Server

This repository provides a Spring AI-based Model Context Protocol (MCP) client for interacting with MCP-supported servers, enabling AI chat interactions using Anthropic and OpenAI models. This repository provides a Spring

## Overview

- **Category:** AI
- **Language:** Java
- **Stars:** 45
- **Forks:** 0
- **Owner:** ogulcanarbc
- **GitHub:** https://github.com/ogulcanarbc/spring-ai-mcp-client
- **Created:** 2025-02-22T19:19:34+00:00
- **Updated:** 2025-03-28T06:42:37+00:00
- **Source:** https://model-context-protocol.com/servers/spring-ai-mcp-client-chat-interactions

## Setup

## Setup

### 1. Clone Repository
        
        ```bash
git clone <repo-url>
cd spring-ai-mcp-client
```

### 2. MCP Server Configuration

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

```json mcpservers.json
{
    "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:

```yaml
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

    ```bash
mvn clean install
mvn spring-boot:run
```

## Tools

## Available Tools

1.  Protocol version negotiation (ensures compatibility with servers)
2.  Capability negotiation (determines available features)
3.  Message transport and JSON-RPC communication (handles communication)
4.  Tool discovery and execution (discovers and executes tools)
5.  Resource access and management (manages resources)
6.  Prompt system interactions (interacts with prompt system)
7.  Optional features like roots management and sampling support (provides additional features)
8.  Supports openai and anthropic models (supports different models)
