IPC MCP服务器
A.NET 10基于HTTP的MCP服务器,用于Windows IPC操作。
特性
- 命名管道:列出、读取、发送、等待消息
- 内存映射文件:列表、读取、写入
- P/调用IPC:直接访问Windows API
- COM对象:与COM组件交互
设置
选项1:作为Windows服务运行(推荐)
以最高权限自动运行的Windows服务安装:
# Run PowerShell as Administrator
.\install_service.ps1 -Token "your-secret-token-here"该服务将:
- 系统启动时自动运行
- 以LocalSystem权限运行(最高可用权限)
- 登录到
logs\stdout.log和logs\stderr.log - 可通过以下方式访问
http://localhost:23481/mcp
服务管理:
# Check status
.\manage_service.ps1 status
# Start/Stop/Restart
.\manage_service.ps1 start
.\manage_service.ps1 stop
.\manage_service.ps1 restart
# View logs
.\manage_service.ps1 logs
# Edit service configuration
.\manage_service.ps1 edit
# Remove service
.\manage_service.ps1 remove要求:
- NSSM(非吸气式服务管理器)-如果找不到,将通过翼子板自动安装
- 安装服务的管理员权限
选项2:手动运行
- 构建服务器:
cd IpcMcp
dotnet build -c Release- 使用令牌以管理员身份运行(推荐):
.\run_server.ps1 -Token "your-secret-token-here"在中配置 mcp.json:
{
"ipc": {
"url": "http://localhost:23481",
"headers": {
"Authorization": "Bearer your-secret-token-here"
}
}
}安全说明:
- 服务器只接受来自localhost(127.0.0.1)的连接
- 身份验证需要令牌
- 在生产中使用强随机令牌
可用工具
命名管道
list_named_pipes-列出所有可用的命名管道read_named_pipe-从命名管道读取send_named_pipe_message-向指定管道发送消息wait_for_named_pipe_message-等待命名管道上的消息
内存映射文件
list_mapped_files-列出内存映射文件read_mapped_file-从内存映射文件读取send_mapped_file_message-写入内存映射文件
P/调用
list_pinvoke_pipes-通过P/Invoke列出管道send_pinvoke_message-通过P/Invoke发送消息
组件对象模型
list_com_objects-列出可用的COM对象send_com_message-通过COM发送消息
使用示例
列出命名管道
{
"tool": "list_named_pipes",
"arguments": {}
}阅读命名管道
{
"tool": "read_named_pipe",
"arguments": {
"pipeName": "my-pipe",
"timeout": 5000
}
}向指定管道发送消息
{
"tool": "send_named_pipe_message",
"arguments": {
"pipeName": "my-pipe",
"message": "Hello from MCP!",
"timeout": 5000
}
}配置
通过环境变量设置端口:
$env:IPC_MCP_PORT = "9090"
.\run_server.ps1安全
⚠️ 此服务器提供对Windows IPC机制的访问!
- 以管理员权限运行以获得完全访问权限(服务以LocalSystem运行)
- 某些操作可能需要提升权限
- 在生产环境中谨慎使用
- 服务安装脚本将服务设置为以具有最高权限的LocalSystem运行
