📦
Computer
获取电脑相关配置的mcp - mcp入门上手案例
0 installs
Trust: 34 — Low
Other
Ask AI about Computer
Powered by Claude · Grounded in docs
I know everything about Computer. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Loading tools...
Reviews
Documentation
MCP Server - Computer
一个基于 Spring AI MCP Server 的电脑配置信息查询服务,支持跨平台(Windows、macOS、Linux)获取系统配置信息。
功能特性
- ✅ 获取操作系统基本信息(名称、版本、架构)
- ✅ 获取用户信息(账户名、主目录、工作目录)
- ✅ 获取 Java 运行时环境版本
- ✅ 支持 Windows、macOS、Linux 平台特定信息获取
- ✅ 基于 Spring AI MCP Server 标准协议
技术栈
- Java 17
- Spring Boot 3.4.3
- Spring AI 1.0.0-M6
- Lombok
- FastJSON 2.0.28
项目结构
mcp-server-computer/
├── src/
│ └── main/
│ ├── java/
│ │ └── cn/bugstack/mcp/server/computer/
│ │ ├── domain/
│ │ │ ├── model/ # 领域模型
│ │ │ └── service/ # 领域服务
│ │ └── McpServerComputerApplication.java
│ └── resources/
│ └── application.yml # 配置文件
└── pom.xml
快速开始
环境要求
- JDK 17+
- Maven 3.6+
构建项目
mvn clean package
运行项目
java -jar target/mcp-server-computer-1.0.0.jar
配置说明
配置文件位于 src/main/resources/application.yml:
spring:
application:
name: mcp-server-computer
ai:
mcp:
server:
name: ${spring.application.name}
version: 1.0.0
main:
banner-mode: off
web-application-type: none # stdio 模式
功能说明
获取电脑配置
通过 @Tool 注解暴露的工具方法,AI 可以调用 queryConfig 方法获取电脑配置信息。
返回信息包括:
- 操作系统名称(osName)
- 操作系统版本(osVersion)
- 操作系统架构(osArch)
- 用户账户名(userName)
- 用户主目录(userHome)
- 当前工作目录(userDir)
- Java 版本(javaVersion)
- 平台特定系统信息(osInfo)
平台特定信息获取:
- Windows: 通过
systeminfo命令获取详细信息 - macOS: 通过
system_profiler SPHardwareDataType获取硬件信息 - Linux: 通过
lshw -short获取硬件信息
使用示例
当作为 MCP Server 运行时,AI 可以通过以下方式调用:
{
"method": "tools/call",
"params": {
"name": "queryConfig",
"arguments": {
"computer": "my-computer"
}
}
}
开发说明
核心类说明
- McpServerComputerApplication: Spring Boot 主启动类,配置 MCP Server
- ComputerService: 核心服务类,提供
queryConfig工具方法 - ComputerFunctionRequest: 请求模型
- ComputerFunctionResponse: 响应模型
添加新功能
- 在
ComputerService中添加新的@Tool注解方法 - 定义对应的请求和响应模型
- 重新构建并运行
日志
日志文件位置:data/log/mcp-server-computer.log
许可证
本项目采用 MIT 许可证。
作者
Daniel G
