Spring AI MCP Demo 6a8424c8

MCPAI代理

提供方 sandipanchakraborty2016

AI代理 未标注 无需鉴权 社区 / 第三方 Claude

一个展示Spring AI中模型上下文协议(MCP)的演示项目,包括MCP服务器、客户端和模型无关的主机实现。

一句话选型结论

按资料字段整理

Spring AI MCP Demo 6a8424c8 属于AI代理类 MCP 服务器,传输方式未标注,无需鉴权,可直接接入 Claude,没有现成安装命令,需按官方文档接入。接入前先确认权限范围;涉及写入、删除或付款的操作,建议先在测试环境验证。

分类AI代理 传输方式未标注 鉴权无需鉴权 部署方式未标注
GitHub 星标 0 仓库热度,无公开仓库时显示未标注
工具数 未标注 暴露给模型的工具数量
资源 / 提示词 0 / 0 资源与提示词模板数量
维护方 社区 / 第三方 核验等级 仅资料核对

工具与能力

AI代理
数量来自来源目录的标注,具体工具清单以官方文档为准
工具数量未标注暴露给模型可调用的工具个数
资源数量0可读取的资源条目
提示词数量0内置提示词模板数量

能力标签

支持客户端

适用场景

SpringAIJava本地部署模型上下文协议模型无关工具集成AI服务

安装与配置

未标注 无需鉴权
上游未给出传输方式
  1. 1
    准备运行环境

    按官方文档确认运行环境(常见为 Node.js 或 Python),装好后再执行安装命令。

  2. 2
    安装服务

    复制上面的安装命令执行;命令里带占位符的位置,换成自己的密钥或路径。

  3. 3
    写入客户端配置

    在客户端的 MCP 配置里填好启动命令和参数,保存后完全退出客户端再打开,让新配置生效。

  4. 4
    验证是否可用

    连接成功后随便调一个只读工具,确认能返回结果,再接入正式流程。

典型使用场景

3 类
按分类与标签整理的常见用法,具体以官方文档为准
给代理接外部能力

让代理在任务中途调用搜索、数据库等真实工具。

多步任务编排

把一串操作拆成步骤,由代理按顺序执行。

自动化重复流程

把固定流程交给代理跑,减少手工操作。

选择建议

选之前先看这几条
按条目字段给出的判断,不替你决定用不用

值得选的地方

  • 已适配 Claude,换客户端不用重新研究配置。
  • 资料标注无需鉴权,装好就能连。

先想清楚的地方

  • 没有现成安装命令,需要按官方文档自己填启动命令和参数。
  • 资料没标注工具数量,实际能力要装好后确认。
  • 版本更新与行为细节以官方仓库为准。

更适合

  • 需要在AI代理场景里让模型直接调用外部能力的人。
  • 已经在用 Claude 的用户,接入路径最短。
  • 想先快速试一下、能接受在本地或自有环境跑服务的人。

不太适合

  • 需要厂商级 SLA 和技术支持的生产环境。

同类对比

6 个同类
同分类里挑最接近的几条,字段以各自详情页为准
MCP 服务器工具数传输方式部署方式安装命令最后核验
Spring AI MCP Demo 6a8424c8当前 未标注 未标注 未标注 无 2026-05-17
Filesystem 560c4363 13 未标注 本地部署 无 2026-05-17
Server Everything (everything) 11 stdio · 本地进程 本地部署 有 2026-05-17
Time 7365cb6d 2 SSE · 服务端推送 远程部署 有 2026-05-18
Everything Claude Code 未标注 stdio · 本地进程 本地部署 有 2026-05-17
Openmemory 557e1585 未标注 stdio · 本地进程 本地部署 有 2026-05-17

服务器档案

AI代理
字段来自项目仓库与公开索引,中文说明由本站标注
提供方sandipanchakraborty2016上游标注的维护方 sandipanchakraborty2016
分类AI代理本站按上游分类展示
连接方式未标注上游未给出传输方式
鉴权方式无需鉴权远程服务建议用最小权限凭据
维护方社区 / 第三方核验等级 仅资料核对
包名 / 运行时未标注 · 未标注本地安装时用到的包标识与运行时
部署类型未标注上游给出的部署形态
最近核验2026-05-17上游最后核验时间

详细介绍

13.2 KB
来自项目仓库与上游目录的原文,未做删改

Spring AI MCP Demo

A comprehensive demonstration of the Model Context Protocol (MCP) using Spring AI, featuring a fully-functional MCP server, client, and model-agnostic host implementations with multiple tool examples.

> 📘 Architecture Guide: See ARCHITECTURE.md for detailed explanation of MCP protocol usage vs REST wrappers.

🎯 Project Overview

This project showcases Spring AI's MCP implementation with:
- MCP Server (Port 8080): Exposes multiple tools via Server-Sent Events (SSE) and @McpTool annotations
- MCP Client (Port 8081): REST API wrapper for direct tool access (convenience endpoints, not using MCP protocol)
- MCP Host OpenAI (Port 8082): ✅ TRUE MCP DEMO - AI chat using OpenAI GPT with tools via MCP protocol
- MCP Host Claude (Port 8083): ✅ TRUE MCP DEMO - AI chat using Anthropic Claude with tools via MCP protocol
- Spring Boot 3.4.12 and Spring AI 1.1.0-M2
- Docker support for containerized deployment
- Model-Agnostic Design: Same MCP tools work with different AI providers

🔍 MCP Protocol vs REST APIs

  • MCP Protocol (SSE + JSON-RPC): Used in mcp-host where ChatModel calls tools ✅
  • REST Wrapper APIs: Used in mcp-client for direct tool testing (not MCP protocol) ⚠️

🌟 Key Feature: Model-Agnostic MCP

This demo proves MCP's model-agnostic nature:
- One MCP Server provides tools (calculator, time, files, storage)
- Multiple AI Models can use the same tools:
- OpenAI GPT models (mcp-host on port 8082)
- Anthropic Claude models (mcp-host-claude on port 8083)
- No server changes needed to support different models
- Same tools, different intelligence - compare how different models use identical tools

🏗️ Architecture```

┌──────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ MCP Host │ │ MCP Host │ │ MCP Client │
│ (OpenAI) │ │ (Claude) │ │ (Port 8081) │
│ Port 8082 │ │ Port 8083 │ │ │
│ │ │ │ │ REST API │
│ GPT-4 + Tools │ │ Claude + Tools │ │ Endpoints │
└────────┬─────────┘ └────────┬─────────┘ └────────┬────────┘
│ │ │
│ │ │
│ Uses MCP Tools │ Uses MCP Tools │ Calls MCP Tools
│ │ │
└───────────────────────────┴───────────────────────────┘
│
│ SSE/HTTP
▼
┌─────────────────┐
│ MCP Server │
│ (Port 8080) │
└─────────────────┘
│
│ Exposes Tools
▼
┌──────────────────┐
│ • Time Service │
│ • Calculator │
│ • File Ops │
│ • Data Storage │
└──────────────────┘


**Model-Agnostic Design**: Both OpenAI and Claude hosts use the **same** MCP server and tools!

## 🚀 Available Tools

### Time Service
- `getCurrentTime()` - Returns current timestamp

### Calculator Service
- `add(a, b)` - Addition
- `subtract(a, b)` - Subtraction
- `multiply(a, b)` - Multiplication
- `divide(a, b)` - Division
- `power(base, exponent)` - Exponentiation
- `sqrt(number)` - Square root

### File Service
- `readFile(filename)` - Read file contents
- `writeFile(filename, content)` - Create or overwrite file
- `appendToFile(filename, content)` - Append to existing file
- `listFiles()` - List all files in workspace
- `deleteFile(filename)` - Delete a file
- `getFileInfo(filename)` - Get file size and metadata
- `getWorkspacePath()` - Get workspace directory path

### Data Storage Service
- `store(key, value)` - Store key-value pair
- `retrieve(key)` - Retrieve value by key
- `delete(key)` - Delete entry
- `listKeys()` - List all keys
- `clear()` - Clear all data
- `count()` - Count entries

## 📋 Prerequisites

- **Java 21 JDK** (not just JRE - includes compiler)
- **Maven 3.6+**
- **Docker** and **Docker Compose** (for containerized deployment)

### Installing Java 21 JDK```bash
# Ubuntu/Debian
sudo apt-get update && sudo apt-get install openjdk-21-jdk

# Verify installation
javac -version  # Should show: javac 21.x.x

🏃 Quick Start

Docker Compose (Recommended)

Start all services (MCP Server + Client + Both AI Hosts):```bash
docker-compose up --build


This starts:
- **MCP Server** on port 8080
- **MCP Client** on port 8081
- **MCP Host (OpenAI)** on port 8082
- **MCP Host (Claude)** on port 8083

### Environment Variables

Before starting, set your API keys:```bash
# For OpenAI host
export SPRING_AI_OPENAI_API_KEY="your-openai-api-key"

# For Claude host
export ANTHROPIC_API_KEY="your-anthropic-api-key"

Or create a .env file:```properties
SPRING_AI_OPENAI_API_KEY=your-openai-api-key
ANTHROPIC_API_KEY=your-anthropic-api-key


### Local Development (Individual Services)

1. **Build all projects**```bash
   mvn clean package -f mcp-server/pom.xml
   mvn clean package -f mcp-client/pom.xml
   mvn clean package -f mcp-host/pom.xml
   mvn clean package -f mcp-host-claude/pom.xml
   ```

2. **Start services individually**```bash
   # Terminal 1: MCP Server
   cd mcp-server && mvn spring-boot:run

   # Terminal 2: MCP Client
   cd mcp-client && mvn spring-boot:run

   # Terminal 3: MCP Host (OpenAI)
   cd mcp-host && mvn spring-boot:run

   # Terminal 4: MCP Host (Claude)
   cd mcp-host-claude && mvn spring-boot:run
   ```

## 🔌 API Examples

### Comparing OpenAI vs Claude (Model-Agnostic Demo)

Both hosts provide identical endpoints - test with the same queries to compare!

#### MCP Host - OpenAI (Port 8082)```bash
# Get host information
curl http://localhost:8082/

# Check available MCP tools
curl http://localhost:8082/api/mcp-info

# Simple calculation
curl "http://localhost:8082/api/demo?query=What+is+25+times+4"

MCP Host - Claude (Port 8083)```bash

Get host information

curl http://localhost:8083/

Check available MCP tools (same tools, different model!)

curl http://localhost:8083/api/mcp-info

Same calculation with Claude

curl "http://localhost:8083/api/demo?query=What+is+25+times+4"


**Try both and compare**: Ask the same question to OpenAI and Claude hosts - they use the same MCP tools but may respond differently!

### MCP Client - Direct Tool Access

#### List Available Tools```bash
curl http://localhost:8081/api/tools

Time Service```bash

curl http://localhost:8081/api/time


### Calculator Operations```bash
# Addition
curl "http://localhost:8081/api/calculator/add?a=10&b=5"

# Division
curl "http://localhost:8081/api/calculator/divide?a=20&b=4"

# Power
curl "http://localhost:8081/api/calculator/power?base=2&exponent=8"

File Operations```bash

List files

curl "http://localhost:8081/api/files/list"

Write a file

curl -X POST "http://localhost:8081/api/files/write?filename=test.txt&content=Hello%20World"

Read a file

curl "http://localhost:8081/api/files/read?filename=test.txt"

Append to file

curl -X POST "http://localhost:8081/api/files/append?filename=test.txt&content=%0ANew%20line"

Get file info

curl "http://localhost:8081/api/files/info?filename=test.txt"

Delete file

curl -X DELETE "http://localhost:8081/api/files/delete?filename=test.txt"

Get workspace path

curl "http://localhost:8081/api/files/workspace"


### Data Storage```bash
# Store data
curl -X POST "http://localhost:8081/api/storage/store?key=username&value=john_doe"

# Retrieve data
curl "http://localhost:8081/api/storage/retrieve?key=username"

# List all keys
curl "http://localhost:8081/api/storage/list"

# Delete entry
curl -X DELETE "http://localhost:8081/api/storage/delete?key=username"

🌐 Deployment

See DEPLOYMENT.md for detailed deployment instructions for:
- Render.com (Free tier)
- Railway.app
- Fly.io
- Other cloud platforms

📁 Project Structure```

spring-ai-mcp-demo/
├── mcp-server/ # MCP Server (provides tools)
│ ├── src/main/java/
│ │ └── com/example/mcpserver/
│ │ ├── McpServerApplication.java
│ │ ├── TimeService.java # @McpTool
│ │ ├── CalculatorService.java # @McpTool
│ │ ├── FileService.java # @McpTool
│ │ ├── DataStorageService.java # @McpTool
│ │ └── HealthController.java
│ ├── Dockerfile
│ └── pom.xml
│
├── mcp-client/ # MCP Client (calls tools directly)
│ ├── src/main/java/
│ │ └── com/example/mcpclient/
│ │ ├── McpClientApplication.java
│ │ ├── ClientController.java
│ │ └── HealthController.java
│ ├── Dockerfile
│ └── pom.xml
│
├── mcp-host/ # MCP Host with OpenAI
│ ├── src/main/java/
│ │ └── com/example/mcphost/
│ │ ├── McpHostApplication.java
│ │ ├── ChatController.java # AI chat endpoints
│ │ └── HealthController.java
│ ├── Dockerfile
│ └── pom.xml
│
├── mcp-host-claude/ # MCP Host with Claude (Anthropic)
│ ├── src/main/java/
│ │ └── com/example/mcphostclaude/
│ │ ├── McpHostClaudeApplication.java
│ │ ├── ClaudeChatController.java
│ │ ├── ClaudeConfig.java
│ │ └── HealthController.java
│ ├── Dockerfile
│ └── pom.xml
│
├── docker-compose.yml # Orchestrates all 4 services
├── render.yaml # Deployment configuration
└── README.md


## 🔧 Configuration

### MCP Server Configuration
`mcp-server/src/main/resources/application.properties`:```properties
server.port=8080
spring.ai.mcp.server.transport=sse
spring.ai.mcp.server.sse.message-endpoint=/mcp/message

MCP Client Configuration

mcp-client/src/main/resources/application.properties:```properties
server.port=8081
spring.ai.mcp.client.transport=sse
spring.ai.mcp.client.sse.base-url=http://localhost:8080
spring.ai.mcp.client.sse.message-endpoint=/mcp/message


### MCP Host (OpenAI) Configuration
`mcp-host/src/main/resources/application.properties`:```properties
server.port=8082
spring.ai.openai.api-key=${SPRING_AI_OPENAI_API_KEY:demo-key}
spring.ai.openai.chat.options.model=gpt-4
spring.ai.mcp.client.sse.base-url=${SPRING_AI_MCP_CLIENT_SSE_BASE_URL:http://localhost:8080}

MCP Host (Claude) Configuration

mcp-host-claude/src/main/resources/application.properties:```properties
server.port=8083
spring.ai.anthropic.api-key=${ANTHROPIC_API_KEY:demo-key}
spring.ai.anthropic.chat.options.model=claude-3-5-sonnet-20241022
spring.ai.mcp.client.sse.base-url=${SPRING_AI_MCP_CLIENT_SSE_BASE_URL:http://localhost:8080}


## 🧪 Testing

### Health Checks```bash
# MCP Server health
curl http://localhost:8080/health

# MCP Client health
curl http://localhost:8081/health

# MCP Host (OpenAI) health
curl http://localhost:8082/health

# MCP Host (Claude) health
curl http://localhost:8083/health

Testing Model-Agnostic MCP

Same query to both AI models:```bash

Ask OpenAI

curl "http://localhost:8082/api/demo?query=What+time+is+it+and+calculate+50+divided+by+5"

Ask Claude (same tools, different reasoning!)

curl "http://localhost:8083/api/demo?query=What+time+is+it+and+calculate+50+divided+by+5"


### Tool Discovery```bash
# List all available tools from MCP Client
curl http://localhost:8081/api/tools

# Check MCP info from OpenAI host
curl http://localhost:8082/api/mcp-info

# Check MCP info from Claude host
curl http://localhost:8083/api/mcp-info

📚 Learn More

  • Spring AI Documentation
  • Model Context Protocol Specification
  • Spring Boot Documentation

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📄 License

This project is licensed under the MIT License.

🙋 Support

For issues and questions, please open an issue in the repository.

常见问题

6 问
答案由本站依据条目字段整理,不引用上游原文
Spring AI MCP Demo 6a8424c8 怎么安装?

资料没有给出安装命令,请到官方仓库或文档按说明接入;这类条目多数是生态应用,或尚未发布可安装包。

Spring AI MCP Demo 6a8424c8 怎么在 Claude 里配置?

它的传输方式未标注,在客户端的 MCP 配置里填好启动命令和参数,保存后完全退出客户端再打开,配置才会生效。

Spring AI MCP Demo 6a8424c8 收费吗?

本站不代收费用,也没有标注具体价格。是否收费取决于服务本身和背后的接口额度,正式使用前按官方说明确认。

Spring AI MCP Demo 6a8424c8 需要 API Key 吗?

资料标注为无需认证,装好就能连;如果实际调用时报鉴权错误,按官方文档补上凭据。

Spring AI MCP Demo 6a8424c8 支持哪些客户端?

资料标注支持 Claude;其他客户端只要能配置 MCP Server,也能用同样的命令或地址接入。

Spring AI MCP Demo 6a8424c8 能提供哪些能力?

资料显示能力标签包括 Spring AI、Java、Claude、AI服务。具体工具清单以官方文档为准。

热门专题

按标签挑服务器
全部专题 →

服务器信息以作者仓库与官方文档为准;分类、传输方式与鉴权方式的中文说明为中文整理,最近核验 2026-05-17。