computer-control-mcp 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- computer_control_mcp-0.1.0/.gitattributes +18 -0
- computer_control_mcp-0.1.0/.gitignore +52 -0
- computer_control_mcp-0.1.0/.python-version +1 -0
- computer_control_mcp-0.1.0/LICENSE +21 -0
- computer_control_mcp-0.1.0/MANIFEST.in +10 -0
- computer_control_mcp-0.1.0/PKG-INFO +151 -0
- computer_control_mcp-0.1.0/README.md +126 -0
- computer_control_mcp-0.1.0/computer_control_mcp/__init__.py +11 -0
- computer_control_mcp-0.1.0/computer_control_mcp/__main__.py +30 -0
- computer_control_mcp-0.1.0/computer_control_mcp/cli.py +114 -0
- computer_control_mcp-0.1.0/computer_control_mcp/core.py +386 -0
- computer_control_mcp-0.1.0/computer_control_mcp/gui.py +126 -0
- computer_control_mcp-0.1.0/docs/api.md +47 -0
- computer_control_mcp-0.1.0/docs/index.md +62 -0
- computer_control_mcp-0.1.0/pyproject.toml +51 -0
- computer_control_mcp-0.1.0/setup.py +16 -0
- computer_control_mcp-0.1.0/test_image.png +0 -0
- computer_control_mcp-0.1.0/tests/README.md +22 -0
- computer_control_mcp-0.1.0/tests/conftest.py +10 -0
- computer_control_mcp-0.1.0/tests/test_computer_control.py +132 -0
- computer_control_mcp-0.1.0/uv.lock +8 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Auto detect text files and perform LF normalization
|
|
2
|
+
* text=auto
|
|
3
|
+
|
|
4
|
+
# Python files
|
|
5
|
+
*.py text diff=python
|
|
6
|
+
|
|
7
|
+
# Documentation
|
|
8
|
+
*.md text
|
|
9
|
+
*.rst text
|
|
10
|
+
*.txt text
|
|
11
|
+
|
|
12
|
+
# Exclude files from exporting
|
|
13
|
+
.gitattributes export-ignore
|
|
14
|
+
.gitignore export-ignore
|
|
15
|
+
.github export-ignore
|
|
16
|
+
.pytest_cache export-ignore
|
|
17
|
+
__pycache__ export-ignore
|
|
18
|
+
*.pyc export-ignore
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Python-generated files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[oc]
|
|
4
|
+
build/
|
|
5
|
+
dist/
|
|
6
|
+
wheels/
|
|
7
|
+
*.egg-info/
|
|
8
|
+
*.egg
|
|
9
|
+
|
|
10
|
+
# Virtual environments
|
|
11
|
+
.venv/
|
|
12
|
+
venv/
|
|
13
|
+
ENV/
|
|
14
|
+
|
|
15
|
+
# Distribution / packaging
|
|
16
|
+
.Python
|
|
17
|
+
develop-eggs/
|
|
18
|
+
downloads/
|
|
19
|
+
eggs/
|
|
20
|
+
.eggs/
|
|
21
|
+
lib/
|
|
22
|
+
lib64/
|
|
23
|
+
parts/
|
|
24
|
+
sdist/
|
|
25
|
+
var/
|
|
26
|
+
*.egg-info/
|
|
27
|
+
.installed.cfg
|
|
28
|
+
|
|
29
|
+
# Unit test / coverage reports
|
|
30
|
+
htmlcov/
|
|
31
|
+
.tox/
|
|
32
|
+
.coverage
|
|
33
|
+
.coverage.*
|
|
34
|
+
.cache
|
|
35
|
+
nosetests.xml
|
|
36
|
+
coverage.xml
|
|
37
|
+
*.cover
|
|
38
|
+
.hypothesis/
|
|
39
|
+
.pytest_cache/
|
|
40
|
+
|
|
41
|
+
# Environments
|
|
42
|
+
.env
|
|
43
|
+
|
|
44
|
+
# IDE files
|
|
45
|
+
.idea/
|
|
46
|
+
.vscode/
|
|
47
|
+
*.swp
|
|
48
|
+
*.swo
|
|
49
|
+
|
|
50
|
+
# OS specific files
|
|
51
|
+
.DS_Store
|
|
52
|
+
Thumbs.db
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.12
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Computer Control MCP Authors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: computer-control-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Computer control capabilities using PyAutoGUI through a Model Context Protocol (MCP) server
|
|
5
|
+
Project-URL: Homepage, https://github.com/AB498/computer-control-mcp
|
|
6
|
+
Project-URL: Issues, https://github.com/AB498/computer-control-mcp/issues
|
|
7
|
+
Project-URL: Documentation, https://github.com/AB498/computer-control-mcp#readme
|
|
8
|
+
Author-email: Computer Control MCP Authors <example@example.com>
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
17
|
+
Classifier: Topic :: Utilities
|
|
18
|
+
Requires-Python: >=3.12
|
|
19
|
+
Requires-Dist: mcp[cli]
|
|
20
|
+
Requires-Dist: pillow
|
|
21
|
+
Requires-Dist: pyautogui
|
|
22
|
+
Requires-Dist: pygetwindow
|
|
23
|
+
Requires-Dist: watchdog
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# Computer Control MCP
|
|
27
|
+
|
|
28
|
+
A Python package that provides computer control capabilities using PyAutoGUI through a Model Context Protocol (MCP) server.
|
|
29
|
+
|
|
30
|
+
## Project Structure
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
computer-control-mcp/
|
|
34
|
+
├── docs/ # Documentation
|
|
35
|
+
│ ├── index.md # Main documentation
|
|
36
|
+
│ └── api.md # API reference
|
|
37
|
+
├── src/ # Source code
|
|
38
|
+
│ └── computer_control_mcp/ # Main package
|
|
39
|
+
│ ├── __init__.py # Package initialization
|
|
40
|
+
│ ├── __main__.py # Entry point for running as a module
|
|
41
|
+
│ ├── core.py # Core functionality
|
|
42
|
+
│ ├── cli.py # Command-line interface
|
|
43
|
+
│ └── gui.py # GUI for testing
|
|
44
|
+
├── tests/ # Test files
|
|
45
|
+
│ ├── conftest.py # Pytest configuration
|
|
46
|
+
│ └── test_computer_control.py # Tests for core functionality
|
|
47
|
+
├── LICENSE # MIT license
|
|
48
|
+
├── MANIFEST.in # Package manifest
|
|
49
|
+
├── pyproject.toml # Project configuration
|
|
50
|
+
└── README.md # This file
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Installation
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pip install computer-control-mcp
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Or with uv:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
uv pip install computer-control-mcp
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Features
|
|
66
|
+
|
|
67
|
+
- Control mouse movements and clicks
|
|
68
|
+
- Type text at the current cursor position
|
|
69
|
+
- Take screenshots of the entire screen or specific windows
|
|
70
|
+
- List and activate windows
|
|
71
|
+
- Press keyboard keys
|
|
72
|
+
- Drag and drop operations
|
|
73
|
+
|
|
74
|
+
## Usage
|
|
75
|
+
|
|
76
|
+
### Basic Example
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from computer_control_mcp.core import mcp
|
|
80
|
+
|
|
81
|
+
# Click at specific coordinates
|
|
82
|
+
mcp.click_screen(x=100, y=100)
|
|
83
|
+
|
|
84
|
+
# Type text
|
|
85
|
+
mcp.type_text(text="Hello, world!")
|
|
86
|
+
|
|
87
|
+
# Take a screenshot
|
|
88
|
+
screenshot = mcp.take_screenshot(mode="whole_screen")
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Command-line Interface
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# Run the MCP server
|
|
95
|
+
computer-control-mcp server
|
|
96
|
+
|
|
97
|
+
# Click at coordinates
|
|
98
|
+
computer-control-mcp click 100 100
|
|
99
|
+
|
|
100
|
+
# Type text
|
|
101
|
+
computer-control-mcp type "Hello, world!"
|
|
102
|
+
|
|
103
|
+
# Take a screenshot
|
|
104
|
+
computer-control-mcp screenshot --mode whole_screen
|
|
105
|
+
|
|
106
|
+
# List all windows
|
|
107
|
+
computer-control-mcp list-windows
|
|
108
|
+
|
|
109
|
+
# Launch the GUI test harness
|
|
110
|
+
computer-control-mcp gui
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Running as a Module
|
|
114
|
+
|
|
115
|
+
You can run the package as a module:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
python -m computer_control_mcp
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Development
|
|
122
|
+
|
|
123
|
+
### Setting up the Development Environment
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
# Clone the repository
|
|
127
|
+
git clone https://github.com/yourusername/computer-control-mcp.git
|
|
128
|
+
cd computer-control-mcp
|
|
129
|
+
|
|
130
|
+
# Create a virtual environment and install dependencies
|
|
131
|
+
python -m venv .venv
|
|
132
|
+
.venv\Scripts\activate # On Windows
|
|
133
|
+
source .venv/bin/activate # On Unix/macOS
|
|
134
|
+
|
|
135
|
+
# Install in development mode
|
|
136
|
+
pip install -e .
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Running Tests
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
python -m pytest
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## API Reference
|
|
146
|
+
|
|
147
|
+
See the [API Reference](docs/api.md) for detailed information about the available functions and classes.
|
|
148
|
+
|
|
149
|
+
## License
|
|
150
|
+
|
|
151
|
+
MIT
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# Computer Control MCP
|
|
2
|
+
|
|
3
|
+
A Python package that provides computer control capabilities using PyAutoGUI through a Model Context Protocol (MCP) server.
|
|
4
|
+
|
|
5
|
+
## Project Structure
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
computer-control-mcp/
|
|
9
|
+
├── docs/ # Documentation
|
|
10
|
+
│ ├── index.md # Main documentation
|
|
11
|
+
│ └── api.md # API reference
|
|
12
|
+
├── src/ # Source code
|
|
13
|
+
│ └── computer_control_mcp/ # Main package
|
|
14
|
+
│ ├── __init__.py # Package initialization
|
|
15
|
+
│ ├── __main__.py # Entry point for running as a module
|
|
16
|
+
│ ├── core.py # Core functionality
|
|
17
|
+
│ ├── cli.py # Command-line interface
|
|
18
|
+
│ └── gui.py # GUI for testing
|
|
19
|
+
├── tests/ # Test files
|
|
20
|
+
│ ├── conftest.py # Pytest configuration
|
|
21
|
+
│ └── test_computer_control.py # Tests for core functionality
|
|
22
|
+
├── LICENSE # MIT license
|
|
23
|
+
├── MANIFEST.in # Package manifest
|
|
24
|
+
├── pyproject.toml # Project configuration
|
|
25
|
+
└── README.md # This file
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install computer-control-mcp
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Or with uv:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
uv pip install computer-control-mcp
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Features
|
|
41
|
+
|
|
42
|
+
- Control mouse movements and clicks
|
|
43
|
+
- Type text at the current cursor position
|
|
44
|
+
- Take screenshots of the entire screen or specific windows
|
|
45
|
+
- List and activate windows
|
|
46
|
+
- Press keyboard keys
|
|
47
|
+
- Drag and drop operations
|
|
48
|
+
|
|
49
|
+
## Usage
|
|
50
|
+
|
|
51
|
+
### Basic Example
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from computer_control_mcp.core import mcp
|
|
55
|
+
|
|
56
|
+
# Click at specific coordinates
|
|
57
|
+
mcp.click_screen(x=100, y=100)
|
|
58
|
+
|
|
59
|
+
# Type text
|
|
60
|
+
mcp.type_text(text="Hello, world!")
|
|
61
|
+
|
|
62
|
+
# Take a screenshot
|
|
63
|
+
screenshot = mcp.take_screenshot(mode="whole_screen")
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Command-line Interface
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# Run the MCP server
|
|
70
|
+
computer-control-mcp server
|
|
71
|
+
|
|
72
|
+
# Click at coordinates
|
|
73
|
+
computer-control-mcp click 100 100
|
|
74
|
+
|
|
75
|
+
# Type text
|
|
76
|
+
computer-control-mcp type "Hello, world!"
|
|
77
|
+
|
|
78
|
+
# Take a screenshot
|
|
79
|
+
computer-control-mcp screenshot --mode whole_screen
|
|
80
|
+
|
|
81
|
+
# List all windows
|
|
82
|
+
computer-control-mcp list-windows
|
|
83
|
+
|
|
84
|
+
# Launch the GUI test harness
|
|
85
|
+
computer-control-mcp gui
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Running as a Module
|
|
89
|
+
|
|
90
|
+
You can run the package as a module:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
python -m computer_control_mcp
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Development
|
|
97
|
+
|
|
98
|
+
### Setting up the Development Environment
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# Clone the repository
|
|
102
|
+
git clone https://github.com/yourusername/computer-control-mcp.git
|
|
103
|
+
cd computer-control-mcp
|
|
104
|
+
|
|
105
|
+
# Create a virtual environment and install dependencies
|
|
106
|
+
python -m venv .venv
|
|
107
|
+
.venv\Scripts\activate # On Windows
|
|
108
|
+
source .venv/bin/activate # On Unix/macOS
|
|
109
|
+
|
|
110
|
+
# Install in development mode
|
|
111
|
+
pip install -e .
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Running Tests
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
python -m pytest
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## API Reference
|
|
121
|
+
|
|
122
|
+
See the [API Reference](docs/api.md) for detailed information about the available functions and classes.
|
|
123
|
+
|
|
124
|
+
## License
|
|
125
|
+
|
|
126
|
+
MIT
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Computer Control MCP - Python package for computer control via MCP.
|
|
3
|
+
|
|
4
|
+
This package provides computer control capabilities using PyAutoGUI through a
|
|
5
|
+
Model Context Protocol (MCP) server.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from computer_control_mcp.core import mcp, main
|
|
9
|
+
|
|
10
|
+
__version__ = "0.1.0"
|
|
11
|
+
__all__ = ["mcp", "main"]
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Entry point for running the Computer Control MCP as a module.
|
|
3
|
+
|
|
4
|
+
This module serves as the main entry point for the package.
|
|
5
|
+
When executed directly (e.g., with `python -m computer_control_mcp`),
|
|
6
|
+
it will run the MCP server.
|
|
7
|
+
|
|
8
|
+
When used with `uvx computer-control-mcp`, it will also run the server.
|
|
9
|
+
|
|
10
|
+
For CLI functionality, use:
|
|
11
|
+
computer-control-mcp <command>
|
|
12
|
+
uvx computer-control-mcp <command>
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
import sys
|
|
16
|
+
from computer_control_mcp.core import main as run_server
|
|
17
|
+
from computer_control_mcp.cli import main as run_cli
|
|
18
|
+
|
|
19
|
+
def main():
|
|
20
|
+
"""Main entry point for the package."""
|
|
21
|
+
# If no arguments are provided, run the server
|
|
22
|
+
if len(sys.argv) == 1:
|
|
23
|
+
print("Starting Computer Control MCP server...")
|
|
24
|
+
run_server()
|
|
25
|
+
# Otherwise, pass the arguments to the CLI
|
|
26
|
+
else:
|
|
27
|
+
run_cli()
|
|
28
|
+
|
|
29
|
+
if __name__ == "__main__":
|
|
30
|
+
main()
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Command-line interface for Computer Control MCP.
|
|
3
|
+
|
|
4
|
+
This module provides a command-line interface for interacting with the Computer Control MCP.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import argparse
|
|
8
|
+
import sys
|
|
9
|
+
from computer_control_mcp.core import mcp, main as run_server
|
|
10
|
+
|
|
11
|
+
def parse_args():
|
|
12
|
+
"""Parse command-line arguments."""
|
|
13
|
+
parser = argparse.ArgumentParser(description="Computer Control MCP CLI")
|
|
14
|
+
|
|
15
|
+
subparsers = parser.add_subparsers(dest="command", help="Command to run")
|
|
16
|
+
|
|
17
|
+
# Server command
|
|
18
|
+
server_parser = subparsers.add_parser("server", help="Run the MCP server")
|
|
19
|
+
|
|
20
|
+
# Click command
|
|
21
|
+
click_parser = subparsers.add_parser("click", help="Click at specified coordinates")
|
|
22
|
+
click_parser.add_argument("x", type=int, help="X coordinate")
|
|
23
|
+
click_parser.add_argument("y", type=int, help="Y coordinate")
|
|
24
|
+
|
|
25
|
+
# Type text command
|
|
26
|
+
type_parser = subparsers.add_parser("type", help="Type text at current cursor position")
|
|
27
|
+
type_parser.add_argument("text", help="Text to type")
|
|
28
|
+
|
|
29
|
+
# Screenshot command
|
|
30
|
+
screenshot_parser = subparsers.add_parser("screenshot", help="Take a screenshot")
|
|
31
|
+
screenshot_parser.add_argument("--mode", choices=["all_windows", "single_window", "whole_screen"],
|
|
32
|
+
default="whole_screen", help="Screenshot mode")
|
|
33
|
+
screenshot_parser.add_argument("--title", help="Window title pattern (for single_window mode)")
|
|
34
|
+
screenshot_parser.add_argument("--regex", action="store_true", help="Use regex for title matching")
|
|
35
|
+
screenshot_parser.add_argument("--output", help="Output file path")
|
|
36
|
+
|
|
37
|
+
# List windows command
|
|
38
|
+
subparsers.add_parser("list-windows", help="List all open windows")
|
|
39
|
+
|
|
40
|
+
# GUI command
|
|
41
|
+
subparsers.add_parser("gui", help="Launch the GUI test harness")
|
|
42
|
+
|
|
43
|
+
return parser.parse_args()
|
|
44
|
+
|
|
45
|
+
def main():
|
|
46
|
+
"""Main entry point for the CLI."""
|
|
47
|
+
args = parse_args()
|
|
48
|
+
|
|
49
|
+
if args.command == "server":
|
|
50
|
+
run_server()
|
|
51
|
+
|
|
52
|
+
elif args.command == "click":
|
|
53
|
+
# Call the tool using the call_tool method
|
|
54
|
+
import asyncio
|
|
55
|
+
result = asyncio.run(mcp.call_tool("click_screen", {"x": args.x, "y": args.y}))
|
|
56
|
+
print(result)
|
|
57
|
+
|
|
58
|
+
elif args.command == "type":
|
|
59
|
+
# Call the tool using the call_tool method
|
|
60
|
+
import asyncio
|
|
61
|
+
result = asyncio.run(mcp.call_tool("type_text", {"text": args.text}))
|
|
62
|
+
print(result)
|
|
63
|
+
|
|
64
|
+
elif args.command == "screenshot":
|
|
65
|
+
if args.mode == "single_window" and not args.title:
|
|
66
|
+
print("Error: --title is required for single_window mode")
|
|
67
|
+
sys.exit(1)
|
|
68
|
+
|
|
69
|
+
# Call the tool using the call_tool method
|
|
70
|
+
import asyncio
|
|
71
|
+
result = asyncio.run(mcp.call_tool("take_screenshot", {
|
|
72
|
+
"mode": args.mode,
|
|
73
|
+
"title_pattern": args.title,
|
|
74
|
+
"use_regex": args.regex
|
|
75
|
+
}))
|
|
76
|
+
|
|
77
|
+
if args.output:
|
|
78
|
+
# Save the screenshot to a file
|
|
79
|
+
with open(args.output, "wb") as f:
|
|
80
|
+
f.write(result.image.data)
|
|
81
|
+
print(f"Screenshot saved to {args.output}")
|
|
82
|
+
else:
|
|
83
|
+
print("Screenshot taken successfully")
|
|
84
|
+
|
|
85
|
+
elif args.command == "list-windows":
|
|
86
|
+
# Call the tool using the call_tool method
|
|
87
|
+
import asyncio
|
|
88
|
+
result = asyncio.run(mcp.call_tool("list_windows", {}))
|
|
89
|
+
|
|
90
|
+
# Parse the result
|
|
91
|
+
windows = []
|
|
92
|
+
for item in result:
|
|
93
|
+
if hasattr(item, 'text'):
|
|
94
|
+
try:
|
|
95
|
+
import json
|
|
96
|
+
window_info = json.loads(item.text)
|
|
97
|
+
windows.append(window_info)
|
|
98
|
+
except json.JSONDecodeError:
|
|
99
|
+
print(f"Failed to parse window info: {item.text}")
|
|
100
|
+
|
|
101
|
+
# Display the windows
|
|
102
|
+
for i, window in enumerate(windows):
|
|
103
|
+
print(f"{i+1}. {window.get('title')} ({window.get('width')}x{window.get('height')})")
|
|
104
|
+
|
|
105
|
+
elif args.command == "gui":
|
|
106
|
+
from computer_control_mcp.gui import main as run_gui
|
|
107
|
+
run_gui()
|
|
108
|
+
|
|
109
|
+
else:
|
|
110
|
+
print("Error: No command specified")
|
|
111
|
+
sys.exit(1)
|
|
112
|
+
|
|
113
|
+
if __name__ == "__main__":
|
|
114
|
+
main()
|