AI助手MCP服务器

一个强大的模型上下文协议(MCP)服务器,为AI助手如Google Antigravity和Claude Code提供对Windows笔记本电脑的全面访问,实现自动化、文件管理和网页浏览。

  • by ViswaSrimaan
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 ViswaSrimaan/mcp_servers

使用说明

🖥️ 笔记本电脑助理MCP服务器

一个强大的 模型上下文协议(MCP) 为AI助手提供以下功能的服务器 谷歌反重力 和 克劳德代码 全面访问您的Windows笔记本电脑,以实现自动化、文件管理和网页浏览。


🎯 为什么使用此MCP服务器?

优势 描述
🤖 全笔记本电脑控制 让AI助手代表您管理文件、运行命令和控制应用程序
⚡ 自动化 自动化重复性任务,如文件组织、系统监控和应用程序管理
� 系统洞察 获取有关CPU、内存、电池、网络和正在运行的进程的实时信息
🌐 web集成 通过人工智能搜索网页、获取网页内容、直接下载文件
🛡️ 设计安全 破坏性操作需要使用限时令牌进行明确确认
🔌 通用兼容性 适用于Google Antigravity、Claude Code、Claude Desktop和任何兼容MCP的客户端

🏗️ 建筑

graph TB
    subgraph "AI Clients"
        A[Google Antigravity]
        B[Claude Code]
        C[Claude Desktop]
    end

    subgraph "MCP Protocol Layer"
        D[MCP Server<br/>laptop-assistant]
    end

    subgraph "Tool Modules"
        E[System Tools]
        F[File Tools]
        G[Web Tools]
        H[App Tools]
        I[Utility Tools]
        I2[Desktop Tools]
        J[Safety Module]
    end

    subgraph "Performance Layer"
        P1[Shared HTTP Client]
        P2[Perf Logging]
    end

    subgraph "System Resources"
        K[Windows OS]
        L[File System]
        M[Network/Web]
        N[Applications]
    end

    A -->|stdio/sse| D
    B -->|stdio/sse| D
    C -->|stdio/sse| D

    D --> E
    D --> F
    D --> G
    D --> H
    D --> I
    D --> I2
    D --> J
    D --> P1
    D --> P2

    E --> K
    F --> L
    G --> M
    H --> N
    I --> K
    I --> L

    J -.->|Confirms| E
    J -.->|Confirms| F
    J -.->|Confirms| H

模块概述

graph LR
    subgraph "server.py"
        A[FastMCP Server]
    end

    subgraph "src/tools/"
        B[system_tools.py<br/>7 tools]
        C[file_tools.py<br/>9 tools]
        D[web_tools.py<br/>3 tools]
        E[app_tools.py<br/>5 tools]
        F[utility_tools.py<br/>4 tools]
        F2[desktop_tools.py<br/>5 tools]
    end

    subgraph "src/"
        G[safety.py<br/>Confirmation System]
        H[security_config.py<br/>Security Hardening]
        I[http_client.py<br/>Connection Pool + Retry]
        J[perf.py<br/>Performance Logging]
    end

    A --> B
    A --> C
    A --> D
    A --> E
    A --> F
    A --> F2
    A --> G
    A --> H
    A --> I
    A --> J

🛠️ 可用工具

系统工具

工具 说明
get_system_info CPU、内存、磁盘和操作系统信息
run_command 执行PowerShell命令⚠️ (需要确认)
list_processes 查看按CPU/内存排序的运行进程
kill_process 终止进程⚠️
get_battery_status 电池电量和充电状态
shutdown_restart 关机、重启或休眠⚠️
get_network_info 网络接口和流量统计

文件管理

工具 说明
list_files 列出目录内容
read_file 读取文件内容(文本文件)
write_file 创建或修改文件
create_directory 递归创建目录
delete_file 删除文件/目录⚠️
move_file 移动或重命名文件⚠️
copy_file 复制文件或目录
search_files 按glob模式搜索文件
get_file_info 详细的文件元数据

Web工具

工具 说明
web_search 通过DuckDuckGo搜索网络
fetch_webpage 从网页中提取文本
download_file 从URL下载文件

应用程序管理

工具 说明
open_application 打开应用程序、文件或URL
list_installed_apps 列出已安装的应用程序(winget)
search_available_apps 搜索要安装的可用应用程序
install_app 通过winget安装应用程序
uninstall_app 卸载应用程序⚠️
update_app 更新应用程序⚠️

桌面自动化

工具 说明
send_notification 发送桌面通知(吐司/气球)
schedule_task 安排重复任务(任务计划程序)⚠️
list_scheduled_tasks 列出计划任务
delete_scheduled_task 删除计划任务⚠️
get_window_list 列出打开的应用程序窗口

公用事业

工具 说明
get_clipboard 读取剪贴板内容
set_clipboard 设置剪贴板内容
take_screenshot 捕获屏幕截图

⚠️ = 需要通过以下方式确认的破坏性操作 confirm_action


⚡ 性能优化

特性 描述
🔄 连接池 共享 httpx.AsyncClient 最多有20个连接和10个keepalive
🔁 使用回退重试 在429/5xx错误上自动重试,具有指数回退+抖动
🧵 异步卸载 全部封锁 psutil剪贴板和屏幕截图调用通过以下线程运行 asyncio.to_thread()
📊 进度通知 下载、安装和文件搜索期间的实时进度报告
⏱️ 性能日志记录 @timed 所有34个工具上的装饰器都记录执行时间
🏥 健康检查 server://health 资源公开正常运行时间、内存和工具计数
🚀 运输选项 支持 stdio, sse,以及 streamable-http 通过 MCP_TRANSPORT 有人是。

环境变量

变量 默认值 选项
MCP_TRANSPORT stdio stdio, sse, streamable-http
MCP_LOG_LEVEL INFO DEBUG, INFO, WARNING, ERROR
MCP_ALLOWED_DIRECTORIES (所有用户目录) 逗号分隔的允许路径列表

📦 安装

先决条件

步骤1:克隆存储库

git clone https://github.com/ViswaSrimaan/mcp_servers.git
cd mcp_servers

第二步:创建虚拟环境

python -m venv .venv
.venv\Scripts\activate

步骤3:安装依赖项

pip install mcp psutil httpx beautifulsoup4 pyperclip Pillow duckduckgo-search

⚙️ 配置

谷歌反重力

  1. 打开反重力设置或在以下位置找到MCP配置文件:

    %USERPROFILE%\.gemini\antigravity\mcp_config.json
    
  2. 添加以下配置:

{
  "mcpServers": {
    "laptop-assistant": {
      "type": "stdio",
      "command": "<path-to-repo>\\.venv\\Scripts\\python.exe",
      "args": [
        "<path-to-repo>\\server.py"
      ]
    }
  }
}
  1. 替换 <path-to-repo> 使用您的实际存储库路径,例如:

    "command": "C:\\Users\\YourName\\mcp_servers\\.venv\\Scripts\\python.exe",
    "args": ["C:\\Users\\YourName\\mcp_servers\\server.py"]
    
  2. 重新启动Antigravity以加载新的MCP服务器。


克劳德代码(VS代码扩展)

  1. 创建或编辑 .mcp.json 在您的工作区根目录中:
{
  "mcpServers": {
    "laptop-assistant": {
      "type": "stdio",
      "command": "<path-to-repo>\\.venv\\Scripts\\python.exe",
      "args": [
        "<path-to-repo>\\server.py"
      ]
    }
  }
}
  1. 替换 <path-to-repo> 使用您的实际存储库路径。

  2. 重新加载VS Code窗口以激活MCP服务器。


适用于Claude桌面应用程序

  1. 在以下位置打开配置文件:

    %APPDATA%\Claude\claude_desktop_config.json
    
  2. 添加MCP服务器配置:

{
  "mcpServers": {
    "laptop-assistant": {
      "command": "<path-to-repo>\\.venv\\Scripts\\python.exe",
      "args": [
        "<path-to-repo>\\server.py"
      ]
    }
  }
}
  1. 替换 <path-to-repo> 使用您的实际存储库路径。

  2. 重新启动克劳德桌面。


🚀 使用示例

配置后,您可以要求您的AI助手:

系统管理

"What's my current CPU and memory usage?"
"Show me the top 10 processes using the most memory"
"What's my battery status?"
"Run the command 'ipconfig /all'"

文件操作

"List all files in my Documents folder"
"Create a new folder called 'Projects' on my Desktop"
"Search for all Python files in my workspace"
"Read the contents of config.json"

网络和下载

"Search the web for Python best practices"
"Fetch the content from https://example.com"
"Download the file from this URL to my Downloads folder"

应用程序管理

"What applications do I have installed?"
"Search for VS Code in available apps"
"Open Notepad"
"Open https://github.com in my browser"

桌面自动化

"Send a notification 'Task Complete' with message 'The build finished successfully'"
"Schedule a task 'DailyBackup' to run 'backup.bat' daily at 10:00"
"List all scheduled tasks"
"Get a list of all open windows"

🔒 安全与安保

安全加固

此MCP服务器包括针对常见攻击媒介的全面安全保护:

保护 说明
🛡️ 路径横向保护 阻止对系统目录(Windows、程序文件等)的访问
🛡️ SSRF预防 阻止对内部IP、本地主机和云元数据端点的请求
🛡️ 命令注入保护 Shell命令需要用户明确确认
🛡️ 执行限制 只能打开安全的应用程序和文件类型
🛡️ 写保护 阻止写入可执行文件(.exe、.bat、.ps1等)

安全配置

您可以选择将文件操作限制到特定目录:

# Set allowed directories (comma-separated)
$env:MCP_ALLOWED_DIRECTORIES = "C:\Users\YourName\Documents,C:\Projects"

两相确认系统

破坏性操作使用基于令牌的确认系统:

sequenceDiagram
    participant AI as AI Assistant
    participant MCP as MCP Server
    participant User as User/System

    AI->>MCP: kill_process(pid=1234)
    MCP->>MCP: Generate confirmation token
    MCP-->>AI: Returns token + warning message
    Note over AI: AI must explicitly confirm
    AI->>MCP: confirm_action(token="abc123")
    MCP->>User: Process terminated
    MCP-->>AI: Success response

受保护的操作

以下操作需要明确确认:

操作 原因
run_command 通过提示注入防止命令注入
delete_file 防止意外数据丢失
move_file 可以覆盖现有文件
kill_process 可能影响系统稳定性
shutdown_restart 系统关键操作
uninstall_app 删除已安装的软件
update_app 修改已安装的软件
schedule_task 创建系统级计划任务
delete_scheduled_task 删除计划任务

安全特性

  • ✅ 需要确认 -破坏性行为需要明确确认
  • ✅ 令牌到期 -确认令牌将在5分钟后过期
  • ✅ 用户权限 -命令使用您的用户权限(非管理员权限)运行
  • ✅ 超时保护 -命令具有可配置的超时(最大300秒)
  • ✅ 被阻止的目录 -系统目录受到保护
  • ✅ SSRF保护 -内部网络访问被阻止
  • ✅ 执行白名单 -只能打开安全的应用程序
  • ✅ 日志记录 -记录所有操作以进行调试

📁 项目结构

mcp_servers/
├── server.py              # Main MCP server entry point (lifespan, health resource, transport)
├── src/
│   ├── __init__.py
│   ├── safety.py          # Confirmation token system
│   ├── security_config.py # Security hardening configuration
│   ├── http_client.py     # Shared HTTP client with connection pooling & retry
│   ├── perf.py            # @timed decorator & logging configuration
│   └── tools/
│       ├── __init__.py
│       ├── system_tools.py    # System info, commands, processes
│       ├── file_tools.py      # File management operations
│       ├── web_tools.py       # Web search, fetch, download
│       ├── app_tools.py       # Application management (winget)
│       ├── utility_tools.py   # Clipboard, screenshots, open apps
│       └── desktop_tools.py   # Desktop automation, notifications, task scheduler
├── test_security.py       # Security test suite
├── SECURITY_REPORT.md     # Security audit report
├── CONTRIBUTING.md        # Contribution guidelines
├── .venv/                 # Python virtual environment
├── .gitignore
└── README.md

� 故障排除

常见问题

问题 解决方案
MCP服务器未连接 确保虚拟环境路径正确且Python可访问
“找不到模块”错误 快跑 pip install -r requirements.txt 或手动安装依赖项
命令超时 增加 timeout 参数(最多300秒)
权限被拒绝错误 某些操作需要以管理员身份运行
机翼指令失败 确保Windows软件包管理器已安装并更新

测试服务器

您可以测试服务器是否正确启动:

cd <path-to-repo>
.venv\Scripts\activate
python server.py

如果运行正确,您将看到: Laptop Assistant MCP server initialized with all tools registered.


🤝 贡献

欢迎投稿!以下是您可以提供帮助的方式:

  1. 分叉 仓库
  2. 创建 特征分支(git checkout -b feature/new-tool)
  3. 提交 您的更改(git commit -m 'Add new tool')
  4. 推 到分行(git push origin feature/new-tool)
  5. 打开 拉取请求

添加新工具

要添加新工具,请在相应的 src/tools/*.py 文件:

@mcp.tool()
def your_new_tool(param: str) -> str:
    """Description of what the tool does.
    
    Args:
        param: Description of the parameter.
    """
    # Your implementation
    return json.dumps({"result": "success"})

📝 许可证

MIT许可证-请参阅 许可证 了解详情。


👤 作者

Viswa Srimaan - @ViswaSrimaan


⭐ Star This Repo

如果你觉得这个有用,请考虑给它一颗星! ⭐