Token导航 LogoToken导航

MCP Server · 运维云端

MCP Restify

基于Spring Boot的RESTful API服务器,实现Model Context Protocol (MCP),支持流式HTTP响应和JSON-RPC 2.0,适用于AI代理工具交互场景。

stdio官方级别未说明来源级核验工具 3@modelcontextprotocol/inspector
API集成JavaSpring Boot

快速开始

作者 / 组织
shivanshuy
提供方
shivanshuy
运行时
Node.js

工具数量

3

来源目录标注

资源数量

0

来源目录标注

提示词数量

0

来源目录标注

GitHub Star

0

仓库热度

收录来源

1 个

MCP World

选型结论

MCP Restify 属于运维云端类 MCP Server,公开资料标注 3 个工具,通过stdio 本地进程接入,客户端适配情况以官方文档为准,有可以直接复制的安装命令;接入前先确认权限范围。

分类

运维云端

传输方式

stdio

认证方式

无需认证

部署方式

公开资料未说明

安装与配置

安装命令

npx @modelcontextprotocol/inspector

公开命令不是通用的启动方式,拼不出可靠配置示例;请在客户端 MCP 配置里按官方文档填写 command 和 args。

上手步骤

  1. 1

    准备运行环境

    stdio 服务在本地起进程,需要先装好 Node.js,再按安装命令拉取依赖。

  2. 2

    安装服务

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

  3. 3

    写入客户端配置

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

  4. 4

    验证是否可用

    连接成功后客户端会列出 3 个工具,随便调一个只读工具确认能返回结果。

接入前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

详细介绍

🚀 MCP恢复

Spring Boot REST API服务器实现具有可流化HTTP支持的模型上下文协议(MCP)

______________________________________________________________________

📋 目录

- 初始化 - 列出工具 - 呼叫工具

______________________________________________________________________

🎯 概述

MCP恢复 是一个可用于生产的SpringBoot应用程序,它公开了实现 模型上下文协议(MCP)它为AI代理提供了一个无状态的HTTP接口,用于与工具和服务进行交互。

主要亮点

  • ✅ JSON-RPC 2.0 顺从的
  • ✅ 可流式传输的HTTP 支持(分块回复)
  • ✅ 无状态 操作(云就绪)
  • ✅ 工具发现 通过 @McpTool 注释
  • ✅ Outlook集成 用于电子邮件操作

______________________________________________________________________

✨ 特性

  • 🔌 RESTful MCP服务器 -基于HTTP的MCP协议实现
  • 📡 可流式传输的HTTP -支持分块JSON响应
  • 🛠️ 工具管理 -MCP工具的自动发现和注册
  • 📧 Outlook集成 -从Microsoft Outlook读取电子邮件
  • 🔍 JSON-RPC 2.0 -完全符合协议要求
  • 🚀 生产就绪 -基于Spring Boot构建,具有全面的错误处理功能

______________________________________________________________________

📦 先决条件

在开始之前,请确保已安装以下内容:

  • Java 17或更高版本
  • Maven 3.6+

验证安装

java -version
# Should show: openjdk version "17" or higher

mvn -version
# Should show: Apache Maven 3.6.0 or higher

______________________________________________________________________

🔧 安装

  1. 克隆或导航到项目目录:
cd mcp-restify
  1. 无需额外安装 -所有依赖项都由Maven管理,并将在构建过程中自动下载。

______________________________________________________________________

🏗️ 构建

使用Maven构建项目:

mvn clean package

此命令将:

  • ✅ 清理以前的构建工件
  • ✅ 编译所有源代码
  • ✅ 运行单元测试
  • ✅ 将应用程序打包到JAR文件中

输出: target/mcp-restify-1.0.0.jar

编译选项

在构建过程中跳过测试:

mvn clean package -DskipTests

使用详细输出进行构建:

mvn clean package -X

______________________________________________________________________

🚀 启动服务器

选项1:使用Maven(开发)

mvn spring-boot:run

选项2:使用JAR文件(生产)

java -jar target/mcp-restify-1.0.0.jar

选项3:使用自定义配置文件运行

java -jar target/mcp-restify-1.0.0.jar --spring.profiles.active=prod

服务器状态

服务器将于启动 http://localhost:9092

您应该看到类似于以下内容的输出:

Tomcat started on port 9092 (http) with context path ''
Started McpRestifyApplication in X.XXX seconds
Registered MCP tools: 3

______________________________________________________________________

📡 MCP端点文档

MCP服务器公开了一个处理所有MCP协议方法的REST端点:

POST http://localhost:9092/mcp

所有请求必须遵循 JSON-RPC 2.0 规范。

______________________________________________________________________

请求头

对MCP端点的每个请求都必须包含以下标头:

标题值必填描述
Content-Typeapplication/json✅ Yes指定请求正文格式
Acceptapplication/json, text/event-stream✅ 是指定可接受的响应格式

标题示例:

Content-Type: application/json
Accept: application/json, text/event-stream
注: 当 Accept: text/event-stream 如果包含,服务器将返回一个可流式传输的HTTP响应 Transfer-Encoding: chunked.

______________________________________________________________________

初始化

初始化MCP协议连接并检索服务器功能。

请求有效载荷:

{
  "jsonrpc": "2.0",
  "method": "initialize",
  "params": {
    "protocolVersion": "2024-11-05",
    "capabilities": {},
    "clientInfo": {
      "name": "mcp-client",
      "version": "1.0.0"
    }
  },
  "id": 1
}

答复:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "protocolVersion": "2024-11-05",
    "capabilities": {
      "tools": {}
    },
    "serverInfo": {
      "name": "mcp-restify",
      "version": "1.0.0"
    }
  }
}

______________________________________________________________________

列出工具

检索所有可用MCP工具的列表。

请求有效载荷:

{
  "jsonrpc": "2.0",
  "method": "tools/list",
  "params": {},
  "id": 2
}

答复:

{
  "jsonrpc": "2.0",
  "id": 2,
  "result": {
    "tools": [
      {
        "name": "hello",
        "description": "A simple hello tool that returns hello world string.",
        "inputSchema": {
          "type": "object",
          "properties": {},
          "required": []
        }
      },
      {
        "name": "readOutlookEmails",
        "description": "Read emails from Outlook mailbox. Can retrieve a list of emails with optional filtering.",
        "inputSchema": {
          "type": "object",
          "properties": {
            "maxResults": {
              "type": "integer",
              "description": "Maximum number of emails to retrieve (default: 10)"
            },
            "folderId": {
              "type": "string",
              "description": "Mail folder ID (default: 'inbox')"
            }
          },
          "required": ["maxResults"]
        }
      },
      {
        "name": "readOutlookEmailById",
        "description": "Read a specific email from Outlook by its message ID.",
        "inputSchema": {
          "type": "object",
          "properties": {
            "messageId": {
              "type": "string",
              "description": "The ID of the message to retrieve"
            }
          },
          "required": ["messageId"]
        }
      }
    ]
  }
}

______________________________________________________________________

呼叫工具

使用提供的参数执行特定的MCP工具。

请求有效载荷:

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "hello",
    "arguments": {},
    "_meta": {
      "progressToken": 2
    }
  },
  "id": 3
}

请求参数:

字段类型必填描述
namestring✅ 是要调用的工具的名称
argumentsobject✅ 是特定于工具的参数(可以为空 {})
_meta.progressTokennumber⚠️ 可选用于进度跟踪的令牌

答复:

{
  "jsonrpc": "2.0",
  "id": 3,
  "result": {
    "content": [
      {
        "type": "text",
        "text": "hello world"
      }
    ]
  }
}

______________________________________________________________________

📤 响应格式

所有响应均遵循JSON-RPC 2.0规范:

成功响应

{
  "jsonrpc": "2.0",
  "id": ,
  "result": 
}

错误响应

{
  "jsonrpc": "2.0",
  "id": ,
  "error": {
    "code": ,
    "message": "",
    "data": ""
  }
}

错误代码

代码含义描述
-32600无效请求发送的JSON不是有效的Request对象
-32601找不到方法该方法不存在/不可用
-32602无效参数无效方法参数
-32603内部错误内部JSON-RPC错误

______________________________________________________________________

🛠️ 可用工具

工具名称描述参数
hello返回一个简单的“hello world”问候语无
readOutlookEmails从Outlook邮箱读取电子邮件maxResults (整数), folderId (字符串,可选)
readOutlookEmailById通过邮件ID读取特定电子邮件messageId (字符串)

______________________________________________________________________

💡 示例

示例1:初始化(cURL)

curl -X POST http://localhost:9092/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{
    "jsonrpc": "2.0",
    "method": "initialize",
    "params": {
      "protocolVersion": "2024-11-05",
      "capabilities": {},
      "clientInfo": {
        "name": "mcp-client",
        "version": "1.0.0"
      }
    },
    "id": 1
  }'

示例2:列表工具(cURL)

curl -X POST http://localhost:9092/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{
    "jsonrpc": "2.0",
    "method": "tools/list",
    "params": {},
    "id": 2
  }'

示例3:调用Hello工具(cURL)

curl -X POST http://localhost:9092/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{
    "jsonrpc": "2.0",
    "method": "tools/call",
    "params": {
      "name": "hello",
      "arguments": {},
      "_meta": {
        "progressToken": 2
      }
    },
    "id": 3
  }'

示例4:PowerShell

$headers = @{
    "Content-Type" = "application/json"
    "Accept" = "application/json, text/event-stream"
}

$body = @{
    jsonrpc = "2.0"
    method = "tools/call"
    params = @{
        name = "hello"
        arguments = @{}
        _meta = @{
            progressToken = 2
        }
    }
    id = 3
} | ConvertTo-Json -Depth 10

$response = Invoke-RestMethod -Uri "http://localhost:9092/mcp" `
    -Method Post `
    -Body $body `
    -Headers $headers

$response | ConvertTo-Json -Depth 10

示例5:Python

import requests
import json

url = "http://localhost:9092/mcp"
headers = {
    "Content-Type": "application/json",
    "Accept": "application/json, text/event-stream"
}

payload = {
    "jsonrpc": "2.0",
    "method": "tools/call",
    "params": {
        "name": "hello",
        "arguments": {},
        "_meta": {
            "progressToken": 2
        }
    },
    "id": 3
}

response = requests.post(url, headers=headers, json=payload)
print(json.dumps(response.json(), indent=2))

示例6:JavaScript(Node.js)

const fetch = require('node-fetch');

const url = 'http://localhost:9092/mcp';
const headers = {
    'Content-Type': 'application/json',
    'Accept': 'application/json, text/event-stream'
};

const payload = {
    jsonrpc: '2.0',
    method: 'tools/call',
    params: {
        name: 'hello',
        arguments: {},
        _meta: {
            progressToken: 2
        }
    },
    id: 3
};

fetch(url, {
    method: 'POST',
    headers: headers,
    body: JSON.stringify(payload)
})
.then(res => res.json())
.then(data => console.log(JSON.stringify(data, null, 2)))
.catch(err => console.error('Error:', err));

______________________________________________________________________

⚙️ 配置

配置通过以下方式管理 src/main/resources/application.properties:

# Server Configuration
server.port=9092
spring.application.name=mcp-restify

# Outlook/Microsoft Graph Configuration (Optional)
outlook.client-id=${OUTLOOK_CLIENT_ID:}
outlook.client-secret=${OUTLOOK_CLIENT_SECRET:}
outlook.tenant-id=${OUTLOOK_TENANT_ID:}

# Logging Configuration
logging.level.com.restify.mcp=DEBUG
logging.level.org.springframework=INFO

环境变量

对于Outlook集成,请设置以下环境变量:

export OUTLOOK_CLIENT_ID=your-client-id
export OUTLOOK_CLIENT_SECRET=your-client-secret
export OUTLOOK_TENANT_ID=your-tenant-id

______________________________________________________________________

🔍 故障排除

端口已在使用中

如果端口9092已在使用中,请将其更改为 application.properties:

server.port=9093

服务器未启动

  1. 验证Java版本:
   java -version
   # Should be 17 or higher
  1. 检查Maven安装:
   mvn -version
  1. 查看服务器日志 有关特定错误消息
  1. 检查端口冲突:
   # Windows
   netstat -ano | findstr :9092

   # Linux/Mac
   lsof -i :9092

400错误请求错误

  • ✅ 确保请求正文是有效的JSON
  • ✅ 验证 Content-Type: application/json 标题已设置
  • ✅ 验证 Accept: application/json, text/event-stream 标题已设置
  • ✅ 检查JSON-RPC格式是否正确(jsonrpc: "2.0" 是必需的)
  • ✅ 确保 method 字段是以下字段之一: initialize, tools/list, tools/call

空响应

  • ✅ 检查服务器日志是否有错误
  • ✅ 验证工具名称是否存在(使用 tools/list 检查)
  • ✅ 确保工具参数与工具的输入模式匹配

MCP检验员测试

对于交互式测试,请使用MCP检查器:

npx @modelcontextprotocol/inspector

然后将其配置为连接到:

http://localhost:9092/mcp

______________________________________________________________________

🧪 测试

运行所有测试

mvn test

运行特定测试

# Test HelloTool
mvn test -Dtest=HelloToolTest

# Test MCP Server Integration
mvn test -Dtest=McpServerIntegrationTest

覆盖测试

mvn test jacoco:report

______________________________________________________________________

📚 额外资源

______________________________________________________________________

📝 许可证

该项目根据MIT许可证获得许可。

______________________________________________________________________

🤝 贡献

欢迎投稿!请随时提交拉取请求。

______________________________________________________________________

由...制作❤️ 使用Spring Boot

工具与能力

工具数量

3

资源数量

0

提示词数量

0

能力标签

RESTfulAPIJava本地部署JSON-RPC2.0流式HTTPAI工具集成SpringBoot

数量来自来源目录的标注,具体工具清单以官方文档为准。

典型使用场景

看服务状态

查询容器、日志和监控指标,定位异常。

执行部署变更

在权限范围内触发发布、回滚和环境切换。

核对资源用量

汇总用量,找出闲置和超额的部分。

选择建议

值得选的地方

  • 只提供 3 个工具,职责集中,接入后不容易误操作。
  • 有现成的安装命令,不用自己找入口,照着跑就能起服务。
  • 公开说明写得比较完整,接入前能看清能力边界。

先想清楚的地方

  • stdio 方式要求本地装好 Node.js,换机器要重新装一遍。
  • 第三方目录整理,版本更新和行为细节以官方仓库为准。

更适合

  • 需要在运维云端场景里让模型直接调用外部能力的人。
  • 想先快速试一下、能接受在本地跑服务的人。

不太适合

  • 完全不想在本地装环境的人。
  • 需要厂商级 SLA 和技术支持的生产环境。

同类对比

5 个同类
MCP Server工具数传输方式安装命令收录来源最后核验
MCP Restify

MCP World · 本页

3stdio有1 个2026-05-17
Ui Tars Desktop 8a825770

MCP World

0stdio有1 个2026-05-17
Elie222 MCP

MCP World

0未说明未标注1 个2026-05-17
Arizeai Phoenix MCP

MCP World

0stdio有3 个2026-05-17
Unity MCP 87ee506e

MCP World

42HTTP有2 个2026-05-17

按同分类和工具数量挑出最接近的几条,字段以各自详情页为准。

常见问题

5 条

MCP Restify 怎么安装?

公开资料给出的安装命令是 npx @modelcontextprotocol/inspector,运行环境为 Node.js。装完后按客户端要求写进 MCP 配置,重启客户端生效。

MCP Restify 怎么在 Claude Desktop、Cursor 里配置?

它是stdio 本地进程,客户端配置里要写启动命令和参数,运行环境是 Node.js;保存后完全退出客户端再打开,配置才会生效。

MCP Restify 收费吗?

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

MCP Restify 需要 API Key 吗?

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

MCP Restify 支持哪些客户端?

公开资料没有标注具体客户端;能配置本地 MCP 命令的客户端都能接,配置方式参照官方文档。

来源信息

继续浏览同类 MCP