spring-ai-mcp-client

by ogulcanarbc

45 stars
444 downloads
Not rated
GitHub

About

mcp client application that utilizes spring ai. it integrates with mcp protocol-supported servers to enable ai-powered chat interactions.

Details

Author
ogulcanarbc
GitHub stars
45
Downloads
444
Categories
Other

- Client-side MCP protocol implementation including version negotiation
- Supports Anthropic Claude and OpenAI models
- Manages communication via JSON‑RPC over stdio transport
- Enables tool discovery, execution, resource access, and prompt interactions
- Optional support for roots management and sampling
- Configurable request timeout, server name, and sync type

Clone the repository, configure MCP server details in an mcp-servers.json file, set your Anthropic or OpenAI API key, and provide Spring Boot configuration in application.yml. Then run mvn spring-boot:run and access the chat endpoint at http://localhost:8081/ai with a GET request containing a message parameter.

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

- Anthropic API key from the Anthropic Console.
- OpenAI API key from the OpenAI Console.

Installation

### 1. Clone Repository 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}

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.