一个基于Spring AI的MCP Server,实现了调用邮箱服务发送邮件的MCP Tool
MCPpedia last refreshed this data
Config is the same across clients — only the file and path differ.
{
"mcpServers": {
"mail-mcp-server": {
"command": "<see-readme>",
"args": []
}
}
}Are you the author?
Add this badge to your README to show your security score and help users find safe servers.
MCP(Model Context Protocol,模型上下文协议)定义了应用程序和大模型之间交换上下文信息的方式。使开发者能够以一致的方式将各种数据源、工具和接口连接到大模型,就像USB让不同设备能够通过相同的标准连接一样。MCP的目标是创建一个通用标准,使AI应用程序的开发和集成变得更加简单和统一。
No automated test available for this server. Check the GitHub README for setup instructions.
Five weighted categories — click any category to see the underlying evidence.
No known CVEs.
No package registry to scan.
Be the first to review
Have you used this server?
Share your experience — it helps other developers decide.
Sign in to write a review.
Others in communication
Asynchronous coordination layer for AI coding agents: identities, inboxes, searchable threads, and advisory file leases over FastMCP + Git + SQLite
A Model Context Protocol (MCP) server for interacting with Microsoft 365 and Office services through the Graph API
PubNub Model Context Protocol MCP Server for Cursor and Claude
IMAP/SMTP email MCP server — 47 tools, IMAP IDLE push, multi-account, AI triage.
MCP Security Weekly
Get CVE alerts and security updates for Mail Mcp Server and similar servers.
Start a conversation
Ask a question, share a tip, or report an issue.
Sign in to join the discussion.
Spring-AI快速构建MCP Server
应用架构组MCP(Model Context Protocol,模型上下文协议)定义了应用程序和大模型之间交换上下文信息的方式。使开发者能够以一致的方式将各种数据源、工具和接口连接到大模型,就像USB让不同设备能够通过相同的标准连接一样。MCP的目标是创建一个通用标准,使AI应用程序的开发和集成变得更加简单和统一。
说人话:MCP就是一种大模型调用外部接口(function/tool call)的协议标准
引用一张网图,让大家更直观的感受MCP解构:

我们来尝试一个简单的场景,如下图2,让大模型告诉我们今天是星期几?
大模型相当于一个脱机的、静态的智者,它并不知道当前时间,也不知道外面世界发生的变化。
在没有工具调用的情况下,大模型不能回答今天是星期几?这样的问题。
所以我们需要在提示词中提供我们的线索,比如这样问:2025年5月20日是星期几?,如下图3

如果我们让大模型在回答我问题的时候,能够知道今天是几月几日,问题不就解决了吗。于是,(function/tool call)出现了。
当我们给Agent添加了一个获取当前时间的工具后,再问今天是星期几?,大模型就能解答了,如下图4
这样我们就不用每次都把今天的日期输给大模型了,他自己去查,提升了自动化水平,显著提高用户体验。
MCP是将外部服务、数据与大模型结合的一种协议标准,有了MCP就能让大模型获取私域知识、完成特定指令的执行更加便捷。
我相信各大模型都会在后续的版本中强化MCP以提高调用的准确率
OpenAI、Google、Qwen、DeepSeek等各大模型都支持(function/tool call),但是在各LLM平台上,function call API
实现差异较大,开发者在切换LLM平台和大模型时需要重新对接,增加了适配成本,难以形成生态。
MCP的出现就是要解决这个痛点,充当大模型的"标准扩展坞",让大模型能够轻松调用各种接口,并且MCP SERVER一次开发可以对接多个支持MCP的大模型和平台。
MCP由三个核心组件构成:Host、Client、Server。如下图5
Dify、Cursor、Coze等;Host中内置的Client会被激活,负责与恰当的Server建立连接并发送请求;Client调用的服务端。负责执行实际的指令,比如:查询数据库并返回对应的数据、调用邮箱的接口发送一份邮件、访问服务器文件系统并返回文件列表等。

MCP调用过程如下图6-1、图6-2

实现MCP Server的技术框架已经出了很多,python、nodejs、java、golang等语言都有对应的SDK
Spring AI构建MCP Serverjdk >= 17spring-boot >= 3.4.5spring-ai >=1.0.0Spring AI支持STDIO、WebMVC和WebFlux三种通讯方式构建MCP Server:
spring-ai-starter-mcp-server:支持标准输入输出的基本服务,适合本机嵌入spring-ai-starter-mcp-server-webmvc:基于Spring MVC的SSE通讯实现的服务spring-ai-starter-mcp-server-webflux:基于Spring WebFlux的SSE通讯实现的服务我这里使用WebFlux(推荐)构建一个通过行内邮箱发送邮件的MCP Server,步骤如下:
pom.xml中添加依赖<!-- lookup parent from repository -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.4.5</version>
<relativePath />
</parent>
<groupId>com.zhangsd</groupId>
<artifactId>mail-mcp-server</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-bom</artifactId>
<version>1.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- spring ai mcp server依赖 -->
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-mcp-server-webflux</artifactId>
<exclusions>
<exclusion>
<artifactId>spring-boot-starter-logging</artifactId>
<groupId>org.springframework.boot</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- 邮件 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<!-- 日志 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
</dependencies>
/**
* @author zhangshdiong
* @date 2025/5/8 1
... [View full README on GitHub](https://github.com/RTException/mail-mcp-server#readme)