hooks-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.
- hooks_mcp-0.1.0/.github/workflows/all-checks.yml +35 -0
- hooks_mcp-0.1.0/.gitignore +3 -0
- hooks_mcp-0.1.0/.vscode/settings.json +7 -0
- hooks_mcp-0.1.0/LICENSE.txt +7 -0
- hooks_mcp-0.1.0/PKG-INFO +253 -0
- hooks_mcp-0.1.0/README.md +240 -0
- hooks_mcp-0.1.0/actions_mcp.yaml +70 -0
- hooks_mcp-0.1.0/hooks_mcp/__init__.py +1 -0
- hooks_mcp-0.1.0/hooks_mcp/config.py +208 -0
- hooks_mcp-0.1.0/hooks_mcp/executor.py +190 -0
- hooks_mcp-0.1.0/hooks_mcp/server.py +193 -0
- hooks_mcp-0.1.0/hooks_mcp/utils.py +126 -0
- hooks_mcp-0.1.0/pyproject.toml +29 -0
- hooks_mcp-0.1.0/tests/__init__.py +1 -0
- hooks_mcp-0.1.0/tests/test_config.py +296 -0
- hooks_mcp-0.1.0/tests/test_executor.py +356 -0
- hooks_mcp-0.1.0/tests/test_security.py +321 -0
- hooks_mcp-0.1.0/tests/test_server.py +778 -0
- hooks_mcp-0.1.0/tests/test_shell_quoting.py +156 -0
- hooks_mcp-0.1.0/tests/test_utils.py +180 -0
- hooks_mcp-0.1.0/uv.lock +761 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
name: All Checks
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
|
|
6
|
+
jobs:
|
|
7
|
+
checks:
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
|
|
10
|
+
steps:
|
|
11
|
+
- name: Checkout code
|
|
12
|
+
uses: actions/checkout@v4
|
|
13
|
+
|
|
14
|
+
- name: Install the latest version of uv
|
|
15
|
+
uses: astral-sh/setup-uv@v6
|
|
16
|
+
with:
|
|
17
|
+
enable-cache: true
|
|
18
|
+
|
|
19
|
+
- name: Set up Python
|
|
20
|
+
run: uv python install
|
|
21
|
+
|
|
22
|
+
- name: Install dependencies
|
|
23
|
+
run: uv sync --all-extras --dev
|
|
24
|
+
|
|
25
|
+
- name: Run all tests
|
|
26
|
+
run: uv run python -m pytest ./tests/
|
|
27
|
+
|
|
28
|
+
- name: Run linter
|
|
29
|
+
run: uvx ruff check --extend-select I,F401
|
|
30
|
+
|
|
31
|
+
- name: Check formatting
|
|
32
|
+
run: uvx ruff format --check .
|
|
33
|
+
|
|
34
|
+
- name: Run type checker
|
|
35
|
+
run: uv run pyright .
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2025 Steve Cosman
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
hooks_mcp-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hooks-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MCP server that exposes project-specific development tools (tests, linters, etc.) via YAML configuration
|
|
5
|
+
Author: Steve Cosman
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE.txt
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Requires-Dist: mcp>=1.0.0
|
|
10
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
11
|
+
Requires-Dist: pyyaml>=6.0
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
<p align="center">
|
|
15
|
+
<picture>
|
|
16
|
+
<img width="310" height="65" alt="actionsMCP" src="https://github.com/user-attachments/assets/d5cddfe2-8a7f-4cfb-881f-efae085c35e9" />
|
|
17
|
+
</picture>
|
|
18
|
+
</p>
|
|
19
|
+
<h3 align="center">
|
|
20
|
+
MCP server that exposes project-specific development tools (tests, linters, etc.) via a YAML configuration
|
|
21
|
+
</h3>
|
|
22
|
+
|
|
23
|
+
## Overview
|
|
24
|
+
|
|
25
|
+
1. **Simple setup:** one YAML file is all it takes to create a custom MCP server for your coding agents. Similar to package.json scripts or Github Actions workflows, but commands run as MCP server functions. Add the YAML to your repo to share with your team.
|
|
26
|
+
2. **Tool discovery:** coding agents know which dev-tools are available and the exact arguments they require. No more guessing CLI strings.
|
|
27
|
+
3. **Improved security:** limit the commands agents can run without approval. Add extra validation of the arguments agents generate (e.g. ensure a file path exists inside the project).
|
|
28
|
+
4. **Works anywhere MCP works:** Cursor, Windsurf, Cline, etc
|
|
29
|
+
5. **And more:** strip ANSI codes/control characters, `.env` file loading, define required secrets without checking them in, supports exit codes/stdout/stderr, etc
|
|
30
|
+
|
|
31
|
+
[](https://github.com/scosman/actions_mcp/actions/workflows/all-checks.yml)
|
|
32
|
+
|
|
33
|
+
## Quick Start
|
|
34
|
+
|
|
35
|
+
1. Install with [uv](https://docs.astral.sh/uv/concepts/tools/):
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
uv tool install actions-mcp
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
2. Create an [`actions_mcp.yaml`](#configuration-file-specification) file in your project root defining your tools. For example:
|
|
42
|
+
|
|
43
|
+
```yaml
|
|
44
|
+
actions:
|
|
45
|
+
- name: "all_tests"
|
|
46
|
+
description: "Run all tests in the project"
|
|
47
|
+
command: "uv run python -m pytest ./tests"
|
|
48
|
+
|
|
49
|
+
- name: "check_format"
|
|
50
|
+
description: "Check if the source code is formatted correctly"
|
|
51
|
+
command: "uvx ruff format --check ."
|
|
52
|
+
|
|
53
|
+
- name: "typecheck"
|
|
54
|
+
description: "Typecheck the source code"
|
|
55
|
+
command: "uv run pyright ."
|
|
56
|
+
|
|
57
|
+
- name: "test_file"
|
|
58
|
+
description: "Run tests in a specific file or directory"
|
|
59
|
+
command: "python -m pytest $TEST_PATH"
|
|
60
|
+
parameters:
|
|
61
|
+
- name: "TEST_PATH"
|
|
62
|
+
type: "project_file_path"
|
|
63
|
+
description: "Path to test file or directory"
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
3. Run the server:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
uvx actions-mcp
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
See [running ActionsMCP](#running-actionsmcp) for more runtime options.
|
|
73
|
+
|
|
74
|
+
## Configuration File Specification
|
|
75
|
+
|
|
76
|
+
The `actions_mcp.yaml` file defines the tools that will be exposed through the MCP server.
|
|
77
|
+
|
|
78
|
+
See this project's [actions_mcp.yaml](./actions_mcp.yaml) as an example.
|
|
79
|
+
|
|
80
|
+
### Top-level Fields
|
|
81
|
+
|
|
82
|
+
- `server_name` (optional): Name of the MCP server (default: "ActionsMCP")
|
|
83
|
+
- `server_description` (optional): Description of the MCP server (default: "Project-specific development tools exposed via MCP")
|
|
84
|
+
- `actions` (required): Array of action definitions
|
|
85
|
+
|
|
86
|
+
### Action Fields
|
|
87
|
+
|
|
88
|
+
Each action in the `actions` array can have the following fields:
|
|
89
|
+
|
|
90
|
+
- `name` (required): Unique identifier for the tool
|
|
91
|
+
- `description` (required): Human-readable description of what the tool does
|
|
92
|
+
- `command` (required): The CLI command to execute. May include dynamic parameters like `$TEST_FILE_PATH`.
|
|
93
|
+
- `parameters` (optional): Definitions of each parameter used in the command.
|
|
94
|
+
- `run_path` (optional): Relative path from project root where the command should be executed. Useful for mono-repos.
|
|
95
|
+
- `timeout` (optional): Timeout in seconds for command execution (default: 60 seconds)
|
|
96
|
+
|
|
97
|
+
### Parameter Fields
|
|
98
|
+
|
|
99
|
+
Each parameter in an action's `parameters` array can have the following fields:
|
|
100
|
+
|
|
101
|
+
- `name` (required): The parameter name to substitute into the command. For example `TEST_FILE_PATH`.
|
|
102
|
+
- `type` (required): One of the following parameter types:
|
|
103
|
+
- `project_file_path`: A local path within the project, relative to project root. Validated to ensure it's within project boundaries and exists.
|
|
104
|
+
- `required_env_var`: An environment variable that must be set before the server starts. Not specified by the calling model.
|
|
105
|
+
- `optional_env_var`: An optional environment variable. Not specified by the calling model.
|
|
106
|
+
- `insecure_string`: Any string from the model. No validation. Use with caution.
|
|
107
|
+
- `description` (optional): Human-readable description of the parameter
|
|
108
|
+
- `default` (optional): Default value for the parameter
|
|
109
|
+
|
|
110
|
+
## Parameter Types Explained
|
|
111
|
+
|
|
112
|
+
### project_file_path
|
|
113
|
+
|
|
114
|
+
This parameter type ensures security by validating that paths are within the project boundaries:
|
|
115
|
+
|
|
116
|
+
```yaml
|
|
117
|
+
- name: "test_file"
|
|
118
|
+
description: "Run tests in a specific file"
|
|
119
|
+
command: "python -m pytest $TEST_FILE"
|
|
120
|
+
parameters:
|
|
121
|
+
- name: "TEST_FILE"
|
|
122
|
+
type: "project_file_path"
|
|
123
|
+
description: "Path to test file"
|
|
124
|
+
default: "./tests"
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
The server will validate that `TEST_FILE` is within the project and exists.
|
|
128
|
+
|
|
129
|
+
### required_env_var
|
|
130
|
+
|
|
131
|
+
These parameters must be set in the environment before starting the server. If they are not set, the server will fail on startup asking the user to set the variables.
|
|
132
|
+
|
|
133
|
+
```yaml
|
|
134
|
+
- name: "deploy"
|
|
135
|
+
description: "Deploy the application"
|
|
136
|
+
command: "deploy-tool --key=$DEPLOY_KEY"
|
|
137
|
+
parameters:
|
|
138
|
+
- name: "DEPLOY_KEY"
|
|
139
|
+
type: "required_env_var"
|
|
140
|
+
description: "Deployment key for the service"
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
ActionMCP will load env vars from the environment, and any set in a `.env` file in your working directory.
|
|
144
|
+
|
|
145
|
+
### optional_env_var
|
|
146
|
+
|
|
147
|
+
Similar to `required_env_var` but optional:
|
|
148
|
+
|
|
149
|
+
```yaml
|
|
150
|
+
- name: "build"
|
|
151
|
+
description: "Build the application"
|
|
152
|
+
command: "build-tool"
|
|
153
|
+
parameters:
|
|
154
|
+
- name: "BUILD_FLAGS"
|
|
155
|
+
type: "optional_env_var"
|
|
156
|
+
description: "Additional build flags"
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### insecure_string
|
|
160
|
+
|
|
161
|
+
Allows any string input from the coding assistant without validation. Use with caution:
|
|
162
|
+
|
|
163
|
+
```yaml
|
|
164
|
+
- name: "grep_code"
|
|
165
|
+
description: "Search code for pattern"
|
|
166
|
+
command: "grep -r $PATTERN src/"
|
|
167
|
+
parameters:
|
|
168
|
+
- name: "PATTERN"
|
|
169
|
+
type: "insecure_string"
|
|
170
|
+
description: "Pattern to search for"
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Running ActionsMCP
|
|
174
|
+
|
|
175
|
+
We recommend running ActionsMCP with [uvx](https://docs.astral.sh/uv/concepts/tools/):
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
# Install
|
|
179
|
+
uv tool install actions-mcp
|
|
180
|
+
# Run
|
|
181
|
+
uvx actions-mcp
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Optional command line arguments include:
|
|
185
|
+
- `--working-directory`/`-wd`: Typically the path to your project root. Set if not running from project root.
|
|
186
|
+
- The last argument is the path to the `actions_mcp.yaml` file, if not using the default `./actions_mcp.yaml`
|
|
187
|
+
|
|
188
|
+
### Running with Coding Assistants
|
|
189
|
+
|
|
190
|
+
#### Cursor
|
|
191
|
+
|
|
192
|
+
[](https://cursor.com/install-mcp?name=ActionsMCP&config=eyJjb21tYW5kIjoidXZ4IGFjdGlvbnMtbWNwIC0td29ya2luZy1kaXJlY3RvcnkgLiJ9)
|
|
193
|
+
|
|
194
|
+
Or open this [cursor deeplink](cursor://anysphere.cursor-deeplink/mcp/install?name=ActionsMCP&config=eyJjb21tYW5kIjoidXZ4IGFjdGlvbnMtbWNwIC0td29ya2luZy1kaXJlY3RvcnkgLiJ9).
|
|
195
|
+
|
|
196
|
+
#### Windsurf/VSCode/etc
|
|
197
|
+
|
|
198
|
+
Most other IDEs use a variant of [mcp.json](https://code.visualstudio.com/docs/copilot/chat/mcp-servers#_add-an-mcp-server-to-your-workspace). Create an entry for ActionMCP.
|
|
199
|
+
|
|
200
|
+
**Note:** Be sure it's run from the root of your project, or manually pass the working directory on startup:
|
|
201
|
+
|
|
202
|
+
```json
|
|
203
|
+
{
|
|
204
|
+
"ActionsMCP": {
|
|
205
|
+
"command": "uvx",
|
|
206
|
+
"args": [
|
|
207
|
+
"actions-mcp",
|
|
208
|
+
"--working-directory",
|
|
209
|
+
"."
|
|
210
|
+
]
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Security Features
|
|
216
|
+
|
|
217
|
+
### Security Benefits
|
|
218
|
+
|
|
219
|
+
ActionsMCP implements several security measures to help improve security of giving agents access to terminal commands:
|
|
220
|
+
|
|
221
|
+
1. **Allow List of Commands**: Your agents can only run the commands you give it access to in your `actions_mcp.yaml`, not arbitrary terminal commands.
|
|
222
|
+
|
|
223
|
+
2. **Path Parameter Validation** All `project_file_path` parameters are validated to ensure they:
|
|
224
|
+
- Are within the project directory
|
|
225
|
+
- Actually exist in the project
|
|
226
|
+
|
|
227
|
+
3. **Environment Variable Controls**:
|
|
228
|
+
- `required_env_var` and `optional_env_var` parameters are managed by the developer, not the coding assistant. This prevents coding assistants from accessing sensitive variables.
|
|
229
|
+
|
|
230
|
+
3. **Safe Command Execution**:
|
|
231
|
+
- Uses Python `subprocess.run` with `shell=False` to prevent shell injection
|
|
232
|
+
- Uses `shlex.split` to properly separate command arguments
|
|
233
|
+
- Implements timeouts to prevent infinite running commands
|
|
234
|
+
|
|
235
|
+
### Security Risks
|
|
236
|
+
|
|
237
|
+
There are some risks to using ActionsMCP:
|
|
238
|
+
|
|
239
|
+
1. If your agent can edit your `actions_mcp.yaml`, it can add commands which it can then run via MCP
|
|
240
|
+
|
|
241
|
+
2. If your agent can add code to your project and any of your actions will invoke arbitrary code (like a test runner), the agent can use this pattern to run arbitrary code
|
|
242
|
+
|
|
243
|
+
3. ActionMCP may contain bugs or security issues
|
|
244
|
+
|
|
245
|
+
We don't promise it's perfect, but it's probably better than giving an agent unfettered terminal access. Running inside a container is always recommended for agents.
|
|
246
|
+
|
|
247
|
+
## Origin Story
|
|
248
|
+
|
|
249
|
+
I built this for my own use building [Kiln](https://getkiln.ai). The first draft was written by Qwen-Coder-405b, and then it was edited by me. See the [initial commit](https://github.com/scosman/actions_mcp/commit/62fdd5917a1469b64e9dbad73fd713cb0f2454a5) for the prompt.
|
|
250
|
+
|
|
251
|
+
## License
|
|
252
|
+
|
|
253
|
+
MIT
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<img width="310" height="65" alt="actionsMCP" src="https://github.com/user-attachments/assets/d5cddfe2-8a7f-4cfb-881f-efae085c35e9" />
|
|
4
|
+
</picture>
|
|
5
|
+
</p>
|
|
6
|
+
<h3 align="center">
|
|
7
|
+
MCP server that exposes project-specific development tools (tests, linters, etc.) via a YAML configuration
|
|
8
|
+
</h3>
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
1. **Simple setup:** one YAML file is all it takes to create a custom MCP server for your coding agents. Similar to package.json scripts or Github Actions workflows, but commands run as MCP server functions. Add the YAML to your repo to share with your team.
|
|
13
|
+
2. **Tool discovery:** coding agents know which dev-tools are available and the exact arguments they require. No more guessing CLI strings.
|
|
14
|
+
3. **Improved security:** limit the commands agents can run without approval. Add extra validation of the arguments agents generate (e.g. ensure a file path exists inside the project).
|
|
15
|
+
4. **Works anywhere MCP works:** Cursor, Windsurf, Cline, etc
|
|
16
|
+
5. **And more:** strip ANSI codes/control characters, `.env` file loading, define required secrets without checking them in, supports exit codes/stdout/stderr, etc
|
|
17
|
+
|
|
18
|
+
[](https://github.com/scosman/actions_mcp/actions/workflows/all-checks.yml)
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
1. Install with [uv](https://docs.astral.sh/uv/concepts/tools/):
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
uv tool install actions-mcp
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
2. Create an [`actions_mcp.yaml`](#configuration-file-specification) file in your project root defining your tools. For example:
|
|
29
|
+
|
|
30
|
+
```yaml
|
|
31
|
+
actions:
|
|
32
|
+
- name: "all_tests"
|
|
33
|
+
description: "Run all tests in the project"
|
|
34
|
+
command: "uv run python -m pytest ./tests"
|
|
35
|
+
|
|
36
|
+
- name: "check_format"
|
|
37
|
+
description: "Check if the source code is formatted correctly"
|
|
38
|
+
command: "uvx ruff format --check ."
|
|
39
|
+
|
|
40
|
+
- name: "typecheck"
|
|
41
|
+
description: "Typecheck the source code"
|
|
42
|
+
command: "uv run pyright ."
|
|
43
|
+
|
|
44
|
+
- name: "test_file"
|
|
45
|
+
description: "Run tests in a specific file or directory"
|
|
46
|
+
command: "python -m pytest $TEST_PATH"
|
|
47
|
+
parameters:
|
|
48
|
+
- name: "TEST_PATH"
|
|
49
|
+
type: "project_file_path"
|
|
50
|
+
description: "Path to test file or directory"
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
3. Run the server:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
uvx actions-mcp
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
See [running ActionsMCP](#running-actionsmcp) for more runtime options.
|
|
60
|
+
|
|
61
|
+
## Configuration File Specification
|
|
62
|
+
|
|
63
|
+
The `actions_mcp.yaml` file defines the tools that will be exposed through the MCP server.
|
|
64
|
+
|
|
65
|
+
See this project's [actions_mcp.yaml](./actions_mcp.yaml) as an example.
|
|
66
|
+
|
|
67
|
+
### Top-level Fields
|
|
68
|
+
|
|
69
|
+
- `server_name` (optional): Name of the MCP server (default: "ActionsMCP")
|
|
70
|
+
- `server_description` (optional): Description of the MCP server (default: "Project-specific development tools exposed via MCP")
|
|
71
|
+
- `actions` (required): Array of action definitions
|
|
72
|
+
|
|
73
|
+
### Action Fields
|
|
74
|
+
|
|
75
|
+
Each action in the `actions` array can have the following fields:
|
|
76
|
+
|
|
77
|
+
- `name` (required): Unique identifier for the tool
|
|
78
|
+
- `description` (required): Human-readable description of what the tool does
|
|
79
|
+
- `command` (required): The CLI command to execute. May include dynamic parameters like `$TEST_FILE_PATH`.
|
|
80
|
+
- `parameters` (optional): Definitions of each parameter used in the command.
|
|
81
|
+
- `run_path` (optional): Relative path from project root where the command should be executed. Useful for mono-repos.
|
|
82
|
+
- `timeout` (optional): Timeout in seconds for command execution (default: 60 seconds)
|
|
83
|
+
|
|
84
|
+
### Parameter Fields
|
|
85
|
+
|
|
86
|
+
Each parameter in an action's `parameters` array can have the following fields:
|
|
87
|
+
|
|
88
|
+
- `name` (required): The parameter name to substitute into the command. For example `TEST_FILE_PATH`.
|
|
89
|
+
- `type` (required): One of the following parameter types:
|
|
90
|
+
- `project_file_path`: A local path within the project, relative to project root. Validated to ensure it's within project boundaries and exists.
|
|
91
|
+
- `required_env_var`: An environment variable that must be set before the server starts. Not specified by the calling model.
|
|
92
|
+
- `optional_env_var`: An optional environment variable. Not specified by the calling model.
|
|
93
|
+
- `insecure_string`: Any string from the model. No validation. Use with caution.
|
|
94
|
+
- `description` (optional): Human-readable description of the parameter
|
|
95
|
+
- `default` (optional): Default value for the parameter
|
|
96
|
+
|
|
97
|
+
## Parameter Types Explained
|
|
98
|
+
|
|
99
|
+
### project_file_path
|
|
100
|
+
|
|
101
|
+
This parameter type ensures security by validating that paths are within the project boundaries:
|
|
102
|
+
|
|
103
|
+
```yaml
|
|
104
|
+
- name: "test_file"
|
|
105
|
+
description: "Run tests in a specific file"
|
|
106
|
+
command: "python -m pytest $TEST_FILE"
|
|
107
|
+
parameters:
|
|
108
|
+
- name: "TEST_FILE"
|
|
109
|
+
type: "project_file_path"
|
|
110
|
+
description: "Path to test file"
|
|
111
|
+
default: "./tests"
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
The server will validate that `TEST_FILE` is within the project and exists.
|
|
115
|
+
|
|
116
|
+
### required_env_var
|
|
117
|
+
|
|
118
|
+
These parameters must be set in the environment before starting the server. If they are not set, the server will fail on startup asking the user to set the variables.
|
|
119
|
+
|
|
120
|
+
```yaml
|
|
121
|
+
- name: "deploy"
|
|
122
|
+
description: "Deploy the application"
|
|
123
|
+
command: "deploy-tool --key=$DEPLOY_KEY"
|
|
124
|
+
parameters:
|
|
125
|
+
- name: "DEPLOY_KEY"
|
|
126
|
+
type: "required_env_var"
|
|
127
|
+
description: "Deployment key for the service"
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
ActionMCP will load env vars from the environment, and any set in a `.env` file in your working directory.
|
|
131
|
+
|
|
132
|
+
### optional_env_var
|
|
133
|
+
|
|
134
|
+
Similar to `required_env_var` but optional:
|
|
135
|
+
|
|
136
|
+
```yaml
|
|
137
|
+
- name: "build"
|
|
138
|
+
description: "Build the application"
|
|
139
|
+
command: "build-tool"
|
|
140
|
+
parameters:
|
|
141
|
+
- name: "BUILD_FLAGS"
|
|
142
|
+
type: "optional_env_var"
|
|
143
|
+
description: "Additional build flags"
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### insecure_string
|
|
147
|
+
|
|
148
|
+
Allows any string input from the coding assistant without validation. Use with caution:
|
|
149
|
+
|
|
150
|
+
```yaml
|
|
151
|
+
- name: "grep_code"
|
|
152
|
+
description: "Search code for pattern"
|
|
153
|
+
command: "grep -r $PATTERN src/"
|
|
154
|
+
parameters:
|
|
155
|
+
- name: "PATTERN"
|
|
156
|
+
type: "insecure_string"
|
|
157
|
+
description: "Pattern to search for"
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Running ActionsMCP
|
|
161
|
+
|
|
162
|
+
We recommend running ActionsMCP with [uvx](https://docs.astral.sh/uv/concepts/tools/):
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
# Install
|
|
166
|
+
uv tool install actions-mcp
|
|
167
|
+
# Run
|
|
168
|
+
uvx actions-mcp
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Optional command line arguments include:
|
|
172
|
+
- `--working-directory`/`-wd`: Typically the path to your project root. Set if not running from project root.
|
|
173
|
+
- The last argument is the path to the `actions_mcp.yaml` file, if not using the default `./actions_mcp.yaml`
|
|
174
|
+
|
|
175
|
+
### Running with Coding Assistants
|
|
176
|
+
|
|
177
|
+
#### Cursor
|
|
178
|
+
|
|
179
|
+
[](https://cursor.com/install-mcp?name=ActionsMCP&config=eyJjb21tYW5kIjoidXZ4IGFjdGlvbnMtbWNwIC0td29ya2luZy1kaXJlY3RvcnkgLiJ9)
|
|
180
|
+
|
|
181
|
+
Or open this [cursor deeplink](cursor://anysphere.cursor-deeplink/mcp/install?name=ActionsMCP&config=eyJjb21tYW5kIjoidXZ4IGFjdGlvbnMtbWNwIC0td29ya2luZy1kaXJlY3RvcnkgLiJ9).
|
|
182
|
+
|
|
183
|
+
#### Windsurf/VSCode/etc
|
|
184
|
+
|
|
185
|
+
Most other IDEs use a variant of [mcp.json](https://code.visualstudio.com/docs/copilot/chat/mcp-servers#_add-an-mcp-server-to-your-workspace). Create an entry for ActionMCP.
|
|
186
|
+
|
|
187
|
+
**Note:** Be sure it's run from the root of your project, or manually pass the working directory on startup:
|
|
188
|
+
|
|
189
|
+
```json
|
|
190
|
+
{
|
|
191
|
+
"ActionsMCP": {
|
|
192
|
+
"command": "uvx",
|
|
193
|
+
"args": [
|
|
194
|
+
"actions-mcp",
|
|
195
|
+
"--working-directory",
|
|
196
|
+
"."
|
|
197
|
+
]
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Security Features
|
|
203
|
+
|
|
204
|
+
### Security Benefits
|
|
205
|
+
|
|
206
|
+
ActionsMCP implements several security measures to help improve security of giving agents access to terminal commands:
|
|
207
|
+
|
|
208
|
+
1. **Allow List of Commands**: Your agents can only run the commands you give it access to in your `actions_mcp.yaml`, not arbitrary terminal commands.
|
|
209
|
+
|
|
210
|
+
2. **Path Parameter Validation** All `project_file_path` parameters are validated to ensure they:
|
|
211
|
+
- Are within the project directory
|
|
212
|
+
- Actually exist in the project
|
|
213
|
+
|
|
214
|
+
3. **Environment Variable Controls**:
|
|
215
|
+
- `required_env_var` and `optional_env_var` parameters are managed by the developer, not the coding assistant. This prevents coding assistants from accessing sensitive variables.
|
|
216
|
+
|
|
217
|
+
3. **Safe Command Execution**:
|
|
218
|
+
- Uses Python `subprocess.run` with `shell=False` to prevent shell injection
|
|
219
|
+
- Uses `shlex.split` to properly separate command arguments
|
|
220
|
+
- Implements timeouts to prevent infinite running commands
|
|
221
|
+
|
|
222
|
+
### Security Risks
|
|
223
|
+
|
|
224
|
+
There are some risks to using ActionsMCP:
|
|
225
|
+
|
|
226
|
+
1. If your agent can edit your `actions_mcp.yaml`, it can add commands which it can then run via MCP
|
|
227
|
+
|
|
228
|
+
2. If your agent can add code to your project and any of your actions will invoke arbitrary code (like a test runner), the agent can use this pattern to run arbitrary code
|
|
229
|
+
|
|
230
|
+
3. ActionMCP may contain bugs or security issues
|
|
231
|
+
|
|
232
|
+
We don't promise it's perfect, but it's probably better than giving an agent unfettered terminal access. Running inside a container is always recommended for agents.
|
|
233
|
+
|
|
234
|
+
## Origin Story
|
|
235
|
+
|
|
236
|
+
I built this for my own use building [Kiln](https://getkiln.ai). The first draft was written by Qwen-Coder-405b, and then it was edited by me. See the [initial commit](https://github.com/scosman/actions_mcp/commit/62fdd5917a1469b64e9dbad73fd713cb0f2454a5) for the prompt.
|
|
237
|
+
|
|
238
|
+
## License
|
|
239
|
+
|
|
240
|
+
MIT
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# ActionsMCP Configuration File for use with the actions-mcp repo!
|
|
2
|
+
|
|
3
|
+
actions:
|
|
4
|
+
- name: "all_tests"
|
|
5
|
+
description: "Run all tests in the project"
|
|
6
|
+
command: "uv run python -m pytest ./tests/"
|
|
7
|
+
|
|
8
|
+
- name: "lint"
|
|
9
|
+
description: "Lint the source code, checking for errors and warnings"
|
|
10
|
+
command: "uvx ruff check --extend-select I,F401"
|
|
11
|
+
|
|
12
|
+
- name: "lint_fix"
|
|
13
|
+
description: "Lint the source code, fixing errors and warnings which it can fix. Not all errors can be fixed automatically."
|
|
14
|
+
command: "uvx ruff check --extend-select I,F401 --fix"
|
|
15
|
+
|
|
16
|
+
- name: "check_format"
|
|
17
|
+
description: "Check if the source code is formatted correctly"
|
|
18
|
+
command: "uvx ruff format --check ."
|
|
19
|
+
|
|
20
|
+
- name: "format"
|
|
21
|
+
description: "Format the source code"
|
|
22
|
+
command: "uvx ruff format ."
|
|
23
|
+
|
|
24
|
+
- name: "typecheck"
|
|
25
|
+
description: "Typecheck the source code"
|
|
26
|
+
command: "uv run pyright ."
|
|
27
|
+
|
|
28
|
+
- name: "test_file"
|
|
29
|
+
description: "Run tests in a specific file or directory"
|
|
30
|
+
command: "uv run python -m pytest $TEST_PATH"
|
|
31
|
+
parameters:
|
|
32
|
+
- name: "TEST_PATH"
|
|
33
|
+
type: "project_file_path"
|
|
34
|
+
description: "Path to test file or directory"
|
|
35
|
+
|
|
36
|
+
- name: "test_specific"
|
|
37
|
+
description: "Run a specific test by name"
|
|
38
|
+
command: "uv run python -m pytest $TEST_PATH -k $TEST_NAME"
|
|
39
|
+
parameters:
|
|
40
|
+
- name: "TEST_PATH"
|
|
41
|
+
type: "project_file_path"
|
|
42
|
+
description: "Path to test file or directory"
|
|
43
|
+
default: "./tests"
|
|
44
|
+
- name: "TEST_NAME"
|
|
45
|
+
type: "insecure_string"
|
|
46
|
+
description: "Name of the test to run"
|
|
47
|
+
|
|
48
|
+
# Example: Command that requires an environment variable. MCP Server will fail to start if the environment variable is not set.
|
|
49
|
+
# - name: "deploy"
|
|
50
|
+
# description: "Deploy the application (requires DEPLOY_KEY environment variable)"
|
|
51
|
+
# command: "echo Deploying with key $DEPLOY_KEY"
|
|
52
|
+
# parameters:
|
|
53
|
+
# - name: "DEPLOY_KEY"
|
|
54
|
+
# type: "required_env_var"
|
|
55
|
+
# description: "Deployment key for the service"
|
|
56
|
+
|
|
57
|
+
# # Example: Command with optional environment variable. MCP Server will start even if the environment variable is not set.
|
|
58
|
+
# - name: "build"
|
|
59
|
+
# description: "Build the application"
|
|
60
|
+
# command: "echo Building application with key $DEPLOY_KEY"
|
|
61
|
+
# parameters:
|
|
62
|
+
# - name: "DEPLOY_KEY"
|
|
63
|
+
# type: "optional_env_var"
|
|
64
|
+
# description: "Deployment key for the service"
|
|
65
|
+
|
|
66
|
+
# # Example: Command that runs from a specific directory. Useful for mono-repos.
|
|
67
|
+
# - name: "docs_check"
|
|
68
|
+
# description: "Check documentation"
|
|
69
|
+
# command: "echo Checking documentation in the app/webserver directory"
|
|
70
|
+
# run_path: "app/webserver"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Actions MCP - An MCP server that exposes project-specific development tools via YAML configuration."""
|