Skip to main content
Glama
README.md
# Windows Seek-n-Control

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
[![MCP](https://img.shields.io/badge/MCP-Compatible-green.svg)](https://modelcontextprotocol.io/)

A powerful Windows automation **MCP (Model Context Protocol) server** that enables AI agents to control Windows applications. Provides tools for capturing screenshots with OCR, clicking, and typing in any window.

> 🤖 **Built for AI Agents** - Seamlessly integrates with Claude Desktop, LM Studio, and any MCP-compatible LLM client.

## 🚀 Features

| Tool | Description |
|------|-------------|
| `list_windows` | List all visible windows with titles and dimensions |
| `get_window_info` | Get detailed info about a specific window |
| `snap_window` | Capture screenshot + OCR text extraction |
| `click_window` | Click at window-relative coordinates |
| `type_in_window` | Type text or send keystrokes (supports combos like Ctrl+S) |
| `get_available_keys` | List all available key names |

## 📦 Prerequisites

1. **Python 3.10+**
2. **Tesseract OCR** (Required for text extraction)
   - Download from [UB-Mannheim/tesseract](https://github.com/UB-Mannheim/tesseract/wiki)
3. **Install dependencies**:
   ```bash
   pip install -r requirements.txt
   ```
   Or with uv:
   ```bash
   uv sync
   ```

---

## 🤖 MCP Server Configuration

### Claude Desktop

Add to your Claude Desktop config file:

**Windows**: `%APPDATA%\Claude\claude_desktop_config.json`  
**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`

```json
{
  "mcpServers": {
    "windows-control": {
      "command": "python",
      "args": ["c:/Users/izzat/Desktop/tmpp/windows-seek-n-control/server.py"]
    }
  }
}
```

### With uv (Recommended)

```json
{
  "mcpServers": {
    "windows-control": {
      "command": "uv",
      "args": ["run", "--directory", "c:/Users/izzat/Desktop/tmpp/windows-seek-n-control", "python", "server.py"]
    }
  }
}
```

### Generic MCP Client

```json
{
  "mcpServers": {
    "windows-control": {
      "type": "stdio",
      "command": "python",
      "args": ["/path/to/server.py"],
      "env": {}
    }
  }
}
```

### LM Studio / Other Agents

For agents that support MCP, configure the stdio transport:
- **Command**: `python`
- **Arguments**: `["path/to/server.py"]`
- **Transport**: `stdio`

---

## 🛠️ Development & Testing

### Run with MCP Inspector

```bash
# Start the development server with inspector UI
uv run mcp dev server.py

# Or without uv
npx -y @modelcontextprotocol/inspector python server.py
```

### Direct Execution

```bash
# Run the server directly (will wait for JSON-RPC input on stdin)
python server.py
```

### Install in Claude Desktop

```bash
uv run mcp install server.py --name "Windows Control"
```

---

## 📖 Tool Usage Examples

### List Windows
```json
{
  "tool": "list_windows",
  "arguments": {}
}
```

### Capture Screenshot with OCR
```json
{
  "tool": "snap_window",
  "arguments": {
    "window_title": "Notepad",
    "extract_text": true,
    "output_path": "C:/screenshots/notepad.png"
  }
}
```

### Click in Window
```json
{
  "tool": "click_window",
  "arguments": {
    "window_title": "Chrome",
    "x": 100,
    "y": 200,
    "button": "left",
    "double_click": false
  }
}
```

### Type Text
```json
{
  "tool": "type_in_window",
  "arguments": {
    "window_title": "Notepad",
    "text": "Hello, World!"
  }
}
```

### Send Keyboard Shortcut
```json
{
  "tool": "type_in_window",
  "arguments": {
    "window_title": "Notepad",
    "keys": ["ctrl+s"]
  }
}
```

---

## 🔧 CLI Tools (Legacy)

The original command-line tools are still available:

### 📸 Snap Tool (`snap.py`)
```bash
python snap.py "notepad"                    # Capture & OCR
python snap.py "report.pdf" -o evidence.png # Custom output
```

### 🖱️ Click Tool (`click_tool.py`)
```bash
python click_tool.py "notepad" --x 100 --y 200           # Left click
python click_tool.py "explorer" --x 50 --y 50 --double   # Double click
python click_tool.py "chrome" --x 300 --y 150 --right    # Right click
python click_tool.py --list                               # List windows
```

### ⌨️ Type Tool (`type.py`)
```bash
python type.py "notepad" --text "Hello World"  # Type text
python type.py "word" --key ctrl+s             # Save shortcut
python type.py "chrome" --text "search" --key enter
python type.py --keys                          # List available keys
```

---

## ❓ Troubleshooting

| Issue | Solution |
|-------|----------|
| **"Window not found"** | Use partial titles. Run `list_windows` to see available windows |
| **OCR not working** | Install Tesseract OCR from the link above |
| **Clicks missing** | Ensure window is not covered by admin-level apps |
| **MCP connection failed** | Check the path in your config is correct and absolute |
| **"MCP SDK not installed"** | Run `pip install 'mcp[cli]'` |

---

## 🤝 Contributing

Contributions are welcome! Here's how you can help:

1. **Fork** the repository
2. **Create** a feature branch (`git checkout -b feature/amazing-feature`)
3. **Commit** your changes (`git commit -m 'Add amazing feature'`)
4. **Push** to the branch (`git push origin feature/amazing-feature`)
5. **Open** a Pull Request

### Ideas for Contributions
- Additional MCP tools (drag & drop, scroll, etc.)
- Better error handling and recovery
- Support for multi-monitor setups
- Performance optimizations

---

## 📄 License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

---

## 🙏 Acknowledgments

- [Model Context Protocol](https://modelcontextprotocol.io/) - The standard for AI tool integration
- [Tesseract OCR](https://github.com/tesseract-ocr/tesseract) - Open source OCR engine
- [pywin32](https://github.com/mhammond/pywin32) - Windows API bindings for Python