i3wm MCP 服务器
通过Claude及其他AI助手用自然语言控制i3窗口管理器
A. 模型上下文协议(MCP) 服务器提供程序化控制的 i3 窗口管理器这个服务器提供了涵盖i3功能的各种工具,使人工智能助手能够通过自然对话来管理窗口、工作区、布局、间隙等。
   
Vibecode警报
主要与Claude(一种AI模型)有共鸣
概述
i3wm MCP服务器将AI助手与i3的强大平铺式窗口管理器相连接,实现了:
- 自然语言控制“将此窗口移动到工作区2”→ 立即执行
- 复杂的自动化在一个请求中串联多个窗口操作
- 情境感知查询窗口状态、绑定模式和配置
示例交互:
User: "Set 10px gaps between windows and make them look nice"
Claude: *Sets inner gaps to 10px, outer gaps to 5px*
User: "Move my Firefox to the right monitor and make it fullscreen"
Claude: *Identifies Firefox window, moves to specified output, enables fullscreen*
User: "What version of i3 am I running?"
Claude: *Returns: i3 version 4.23 (2023-10-29)*快速入门
安装
前提条件: Python 3.8+,i3 窗口管理器
- 克隆仓库:
git clone https://github.com/caninja/i3wm-mcp.git
cd i3wm-mcp- 安装依赖项:
sudo pacman -Sy python-pydantic
pipx install mcp
pipx install fastmcp
# depending on setup, maybe the following is enough for you
python -m venv venv
./venv/bin/pip install fastmcp pydantic - 添加给克劳德:
使用MCP CLI(推荐):
# Add the server to Claude configuration
claude mcp add --transport stdio i3 /absolute/path/to/i3wm-mcp/venv/bin/python /absolute/path/to/i3wm-mcp/i3_mcp.py或者手动编辑 ~/.claude.json:
{
"mcpServers": {
"i3": {
"command": "python",
"args": ["/absolute/path/to/i3wm-mcp/i3_mcp.py"]
}
}
}- 重启Claude 并开始使用自然语言来控制i3!
验证
独立测试服务器:
# Verify syntax
python -m py_compile i3_mcp.py
# Test server startup (will timeout after 5s - this is expected)
timeout 5s python i3_mcp.py || echo "✓ Server ready"尝试:
- “我有哪些工作区?”
- “将内边距设置为10像素”
- “将我的Firefox窗口置于焦点”
______________________________________________________________________
待办事项(或“全部”)
- 为模型添加文档以实现更简洁的查询
