cli-mcp-server 0.2.0__tar.gz → 0.2.2__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.
- {cli_mcp_server-0.2.0 → cli_mcp_server-0.2.2}/PKG-INFO +46 -33
- {cli_mcp_server-0.2.0 → cli_mcp_server-0.2.2}/README.md +42 -30
- cli_mcp_server-0.2.2/glama.json +6 -0
- {cli_mcp_server-0.2.0 → cli_mcp_server-0.2.2}/pyproject.toml +2 -2
- {cli_mcp_server-0.2.0 → cli_mcp_server-0.2.2}/src/cli_mcp_server/server.py +52 -16
- {cli_mcp_server-0.2.0 → cli_mcp_server-0.2.2}/uv.lock +5 -5
- {cli_mcp_server-0.2.0 → cli_mcp_server-0.2.2}/.gitignore +0 -0
- {cli_mcp_server-0.2.0 → cli_mcp_server-0.2.2}/.python-version +0 -0
- {cli_mcp_server-0.2.0 → cli_mcp_server-0.2.2}/LICENSE +0 -0
- {cli_mcp_server-0.2.0 → cli_mcp_server-0.2.2}/src/cli_mcp_server/__init__.py +0 -0
@@ -1,14 +1,15 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: cli-mcp-server
|
3
|
-
Version: 0.2.
|
3
|
+
Version: 0.2.2
|
4
4
|
Summary: Command line interface for MCP clients with secure execution and customizable security policies
|
5
5
|
Project-URL: Homepage, https://github.com/MladenSU/cli-mcp-server
|
6
6
|
Project-URL: Documentation, https://github.com/MladenSU/cli-mcp-server#readme
|
7
7
|
Project-URL: Repository, https://github.com/MladenSU/cli-mcp-server.git
|
8
8
|
Project-URL: Bug Tracker, https://github.com/MladenSU/cli-mcp-server/issues
|
9
9
|
Author-email: Mladen <fangs-lever6n@icloud.com>
|
10
|
+
License-File: LICENSE
|
10
11
|
Requires-Python: >=3.10
|
11
|
-
Requires-Dist: mcp>=1.
|
12
|
+
Requires-Dist: mcp>=1.1.0
|
12
13
|
Description-Content-Type: text/markdown
|
13
14
|
|
14
15
|
# CLI MCP Server
|
@@ -16,14 +17,15 @@ Description-Content-Type: text/markdown
|
|
16
17
|
---
|
17
18
|
|
18
19
|
A secure Model Context Protocol (MCP) server implementation for executing controlled command-line operations with
|
19
|
-
comprehensive security
|
20
|
-
features.
|
20
|
+
comprehensive security features.
|
21
21
|
|
22
22
|

|
23
23
|

|
24
24
|

|
25
25
|
[](https://smithery.ai/protocol/cli-mcp-server)
|
26
26
|
|
27
|
+
<a href="https://glama.ai/mcp/servers/q89277vzl1"><img width="380" height="200" src="https://glama.ai/mcp/servers/q89277vzl1/badge" /></a>
|
28
|
+
|
27
29
|
---
|
28
30
|
|
29
31
|
# Table of Contents
|
@@ -50,30 +52,32 @@ features.
|
|
50
52
|
## Overview
|
51
53
|
|
52
54
|
This MCP server enables secure command-line execution with robust security measures including command whitelisting, path
|
53
|
-
validation, and
|
54
|
-
execution controls. Perfect for providing controlled CLI access to LLM applications while maintaining security.
|
55
|
+
validation, and execution controls. Perfect for providing controlled CLI access to LLM applications while maintaining security.
|
55
56
|
|
56
57
|
## Features
|
57
58
|
|
58
59
|
- 🔒 Secure command execution with strict validation
|
59
|
-
- ⚙️ Configurable command and flag whitelisting
|
60
|
-
- 🛡️ Path traversal prevention
|
60
|
+
- ⚙️ Configurable command and flag whitelisting with 'all' option
|
61
|
+
- 🛡️ Path traversal prevention and validation
|
61
62
|
- 🚫 Shell operator injection protection
|
62
63
|
- ⏱️ Execution timeouts and length limits
|
63
64
|
- 📝 Detailed error reporting
|
64
65
|
- 🔄 Async operation support
|
66
|
+
- 🎯 Working directory restriction and validation
|
65
67
|
|
66
68
|
## Configuration
|
67
69
|
|
68
70
|
Configure the server using environment variables:
|
69
71
|
|
70
|
-
| Variable | Description
|
71
|
-
|
72
|
-
| `ALLOWED_DIR`
|
73
|
-
| `ALLOWED_COMMANDS`
|
74
|
-
| `ALLOWED_FLAGS`
|
75
|
-
| `MAX_COMMAND_LENGTH
|
76
|
-
| `COMMAND_TIMEOUT`
|
72
|
+
| Variable | Description | Default |
|
73
|
+
|---------------------|------------------------------------------------------|-------------------|
|
74
|
+
| `ALLOWED_DIR` | Base directory for command execution (Required) | None (Required) |
|
75
|
+
| `ALLOWED_COMMANDS` | Comma-separated list of allowed commands or 'all' | `ls,cat,pwd` |
|
76
|
+
| `ALLOWED_FLAGS` | Comma-separated list of allowed flags or 'all' | `-l,-a,--help` |
|
77
|
+
| `MAX_COMMAND_LENGTH`| Maximum command string length | `1024` |
|
78
|
+
| `COMMAND_TIMEOUT` | Command execution timeout (seconds) | `30` |
|
79
|
+
|
80
|
+
Note: Setting `ALLOWED_COMMANDS` or `ALLOWED_FLAGS` to 'all' will allow any command or flag respectively.
|
77
81
|
|
78
82
|
## Installation
|
79
83
|
|
@@ -90,19 +94,28 @@ npx @smithery/cli install cli-mcp-server --client claude
|
|
90
94
|
Executes whitelisted CLI commands within allowed directories.
|
91
95
|
|
92
96
|
**Input Schema:**
|
93
|
-
|
94
|
-
|
95
|
-
{
|
97
|
+
```json
|
98
|
+
{
|
96
99
|
"command": {
|
97
100
|
"type": "string",
|
98
|
-
"description": "
|
101
|
+
"description": "Single command to execute (e.g., 'ls -l' or 'cat file.txt')"
|
99
102
|
}
|
100
103
|
}
|
101
|
-
|
104
|
+
```
|
105
|
+
|
106
|
+
**Security Notes:**
|
107
|
+
- Shell operators (&&, |, >, >>) are not supported
|
108
|
+
- Commands must be whitelisted unless ALLOWED_COMMANDS='all'
|
109
|
+
- Flags must be whitelisted unless ALLOWED_FLAGS='all'
|
110
|
+
- All paths are validated to be within ALLOWED_DIR
|
102
111
|
|
103
112
|
### show_security_rules
|
104
113
|
|
105
|
-
Displays current security configuration and restrictions
|
114
|
+
Displays current security configuration and restrictions, including:
|
115
|
+
- Working directory
|
116
|
+
- Allowed commands
|
117
|
+
- Allowed flags
|
118
|
+
- Security limits (max command length and timeout)
|
106
119
|
|
107
120
|
## Usage with Claude Desktop
|
108
121
|
|
@@ -110,7 +123,7 @@ Add to your `~/Library/Application\ Support/Claude/claude_desktop_config.json`:
|
|
110
123
|
|
111
124
|
> Development/Unpublished Servers Configuration
|
112
125
|
|
113
|
-
|
126
|
+
```json
|
114
127
|
{
|
115
128
|
"mcpServers": {
|
116
129
|
"cli-mcp-server": {
|
@@ -131,7 +144,7 @@ Add to your `~/Library/Application\ Support/Claude/claude_desktop_config.json`:
|
|
131
144
|
}
|
132
145
|
}
|
133
146
|
}
|
134
|
-
|
147
|
+
```
|
135
148
|
|
136
149
|
> Published Servers Configuration
|
137
150
|
|
@@ -158,23 +171,25 @@ Add to your `~/Library/Application\ Support/Claude/claude_desktop_config.json`:
|
|
158
171
|
|
159
172
|
## Security Features
|
160
173
|
|
161
|
-
- ✅ Command whitelist enforcement
|
162
|
-
- ✅ Flag validation
|
163
|
-
- ✅ Path traversal prevention
|
174
|
+
- ✅ Command whitelist enforcement with 'all' option
|
175
|
+
- ✅ Flag validation with 'all' option
|
176
|
+
- ✅ Path traversal prevention and normalization
|
164
177
|
- ✅ Shell operator blocking
|
165
178
|
- ✅ Command length limits
|
166
179
|
- ✅ Execution timeouts
|
167
180
|
- ✅ Working directory restrictions
|
181
|
+
- ✅ Symlink resolution and validation
|
168
182
|
|
169
183
|
## Error Handling
|
170
184
|
|
171
185
|
The server provides detailed error messages for:
|
172
186
|
|
173
|
-
- Security violations
|
174
|
-
- Command timeouts
|
187
|
+
- Security violations (CommandSecurityError)
|
188
|
+
- Command timeouts (CommandTimeoutError)
|
175
189
|
- Invalid command formats
|
176
190
|
- Path security violations
|
177
|
-
- Execution failures
|
191
|
+
- Execution failures (CommandExecutionError)
|
192
|
+
- General command errors (CommandError)
|
178
193
|
|
179
194
|
## Development
|
180
195
|
|
@@ -183,8 +198,6 @@ The server provides detailed error messages for:
|
|
183
198
|
- Python 3.10+
|
184
199
|
- MCP protocol library
|
185
200
|
|
186
|
-
## Development
|
187
|
-
|
188
201
|
### Building and Publishing
|
189
202
|
|
190
203
|
To prepare the package for distribution:
|
@@ -224,6 +237,6 @@ Upon launching, the Inspector will display a URL that you can access in your bro
|
|
224
237
|
|
225
238
|
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
226
239
|
|
227
|
-
|
240
|
+
---
|
228
241
|
|
229
242
|
For more information or support, please open an issue on the project repository.
|
@@ -3,14 +3,15 @@
|
|
3
3
|
---
|
4
4
|
|
5
5
|
A secure Model Context Protocol (MCP) server implementation for executing controlled command-line operations with
|
6
|
-
comprehensive security
|
7
|
-
features.
|
6
|
+
comprehensive security features.
|
8
7
|
|
9
8
|

|
10
9
|

|
11
10
|

|
12
11
|
[](https://smithery.ai/protocol/cli-mcp-server)
|
13
12
|
|
13
|
+
<a href="https://glama.ai/mcp/servers/q89277vzl1"><img width="380" height="200" src="https://glama.ai/mcp/servers/q89277vzl1/badge" /></a>
|
14
|
+
|
14
15
|
---
|
15
16
|
|
16
17
|
# Table of Contents
|
@@ -37,30 +38,32 @@ features.
|
|
37
38
|
## Overview
|
38
39
|
|
39
40
|
This MCP server enables secure command-line execution with robust security measures including command whitelisting, path
|
40
|
-
validation, and
|
41
|
-
execution controls. Perfect for providing controlled CLI access to LLM applications while maintaining security.
|
41
|
+
validation, and execution controls. Perfect for providing controlled CLI access to LLM applications while maintaining security.
|
42
42
|
|
43
43
|
## Features
|
44
44
|
|
45
45
|
- 🔒 Secure command execution with strict validation
|
46
|
-
- ⚙️ Configurable command and flag whitelisting
|
47
|
-
- 🛡️ Path traversal prevention
|
46
|
+
- ⚙️ Configurable command and flag whitelisting with 'all' option
|
47
|
+
- 🛡️ Path traversal prevention and validation
|
48
48
|
- 🚫 Shell operator injection protection
|
49
49
|
- ⏱️ Execution timeouts and length limits
|
50
50
|
- 📝 Detailed error reporting
|
51
51
|
- 🔄 Async operation support
|
52
|
+
- 🎯 Working directory restriction and validation
|
52
53
|
|
53
54
|
## Configuration
|
54
55
|
|
55
56
|
Configure the server using environment variables:
|
56
57
|
|
57
|
-
| Variable | Description
|
58
|
-
|
59
|
-
| `ALLOWED_DIR`
|
60
|
-
| `ALLOWED_COMMANDS`
|
61
|
-
| `ALLOWED_FLAGS`
|
62
|
-
| `MAX_COMMAND_LENGTH
|
63
|
-
| `COMMAND_TIMEOUT`
|
58
|
+
| Variable | Description | Default |
|
59
|
+
|---------------------|------------------------------------------------------|-------------------|
|
60
|
+
| `ALLOWED_DIR` | Base directory for command execution (Required) | None (Required) |
|
61
|
+
| `ALLOWED_COMMANDS` | Comma-separated list of allowed commands or 'all' | `ls,cat,pwd` |
|
62
|
+
| `ALLOWED_FLAGS` | Comma-separated list of allowed flags or 'all' | `-l,-a,--help` |
|
63
|
+
| `MAX_COMMAND_LENGTH`| Maximum command string length | `1024` |
|
64
|
+
| `COMMAND_TIMEOUT` | Command execution timeout (seconds) | `30` |
|
65
|
+
|
66
|
+
Note: Setting `ALLOWED_COMMANDS` or `ALLOWED_FLAGS` to 'all' will allow any command or flag respectively.
|
64
67
|
|
65
68
|
## Installation
|
66
69
|
|
@@ -77,19 +80,28 @@ npx @smithery/cli install cli-mcp-server --client claude
|
|
77
80
|
Executes whitelisted CLI commands within allowed directories.
|
78
81
|
|
79
82
|
**Input Schema:**
|
80
|
-
|
81
|
-
|
82
|
-
{
|
83
|
+
```json
|
84
|
+
{
|
83
85
|
"command": {
|
84
86
|
"type": "string",
|
85
|
-
"description": "
|
87
|
+
"description": "Single command to execute (e.g., 'ls -l' or 'cat file.txt')"
|
86
88
|
}
|
87
89
|
}
|
88
|
-
|
90
|
+
```
|
91
|
+
|
92
|
+
**Security Notes:**
|
93
|
+
- Shell operators (&&, |, >, >>) are not supported
|
94
|
+
- Commands must be whitelisted unless ALLOWED_COMMANDS='all'
|
95
|
+
- Flags must be whitelisted unless ALLOWED_FLAGS='all'
|
96
|
+
- All paths are validated to be within ALLOWED_DIR
|
89
97
|
|
90
98
|
### show_security_rules
|
91
99
|
|
92
|
-
Displays current security configuration and restrictions
|
100
|
+
Displays current security configuration and restrictions, including:
|
101
|
+
- Working directory
|
102
|
+
- Allowed commands
|
103
|
+
- Allowed flags
|
104
|
+
- Security limits (max command length and timeout)
|
93
105
|
|
94
106
|
## Usage with Claude Desktop
|
95
107
|
|
@@ -97,7 +109,7 @@ Add to your `~/Library/Application\ Support/Claude/claude_desktop_config.json`:
|
|
97
109
|
|
98
110
|
> Development/Unpublished Servers Configuration
|
99
111
|
|
100
|
-
|
112
|
+
```json
|
101
113
|
{
|
102
114
|
"mcpServers": {
|
103
115
|
"cli-mcp-server": {
|
@@ -118,7 +130,7 @@ Add to your `~/Library/Application\ Support/Claude/claude_desktop_config.json`:
|
|
118
130
|
}
|
119
131
|
}
|
120
132
|
}
|
121
|
-
|
133
|
+
```
|
122
134
|
|
123
135
|
> Published Servers Configuration
|
124
136
|
|
@@ -145,23 +157,25 @@ Add to your `~/Library/Application\ Support/Claude/claude_desktop_config.json`:
|
|
145
157
|
|
146
158
|
## Security Features
|
147
159
|
|
148
|
-
- ✅ Command whitelist enforcement
|
149
|
-
- ✅ Flag validation
|
150
|
-
- ✅ Path traversal prevention
|
160
|
+
- ✅ Command whitelist enforcement with 'all' option
|
161
|
+
- ✅ Flag validation with 'all' option
|
162
|
+
- ✅ Path traversal prevention and normalization
|
151
163
|
- ✅ Shell operator blocking
|
152
164
|
- ✅ Command length limits
|
153
165
|
- ✅ Execution timeouts
|
154
166
|
- ✅ Working directory restrictions
|
167
|
+
- ✅ Symlink resolution and validation
|
155
168
|
|
156
169
|
## Error Handling
|
157
170
|
|
158
171
|
The server provides detailed error messages for:
|
159
172
|
|
160
|
-
- Security violations
|
161
|
-
- Command timeouts
|
173
|
+
- Security violations (CommandSecurityError)
|
174
|
+
- Command timeouts (CommandTimeoutError)
|
162
175
|
- Invalid command formats
|
163
176
|
- Path security violations
|
164
|
-
- Execution failures
|
177
|
+
- Execution failures (CommandExecutionError)
|
178
|
+
- General command errors (CommandError)
|
165
179
|
|
166
180
|
## Development
|
167
181
|
|
@@ -170,8 +184,6 @@ The server provides detailed error messages for:
|
|
170
184
|
- Python 3.10+
|
171
185
|
- MCP protocol library
|
172
186
|
|
173
|
-
## Development
|
174
|
-
|
175
187
|
### Building and Publishing
|
176
188
|
|
177
189
|
To prepare the package for distribution:
|
@@ -211,6 +223,6 @@ Upon launching, the Inspector will display a URL that you can access in your bro
|
|
211
223
|
|
212
224
|
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
213
225
|
|
214
|
-
|
226
|
+
---
|
215
227
|
|
216
228
|
For more information or support, please open an issue on the project repository.
|
@@ -1,10 +1,10 @@
|
|
1
1
|
[project]
|
2
2
|
name = "cli-mcp-server"
|
3
|
-
version = "0.2.
|
3
|
+
version = "0.2.2"
|
4
4
|
description = "Command line interface for MCP clients with secure execution and customizable security policies"
|
5
5
|
readme = "README.md"
|
6
6
|
requires-python = ">=3.10"
|
7
|
-
dependencies = ["mcp>=1.
|
7
|
+
dependencies = ["mcp>=1.1.0"]
|
8
8
|
authors = [
|
9
9
|
{ name = "Mladen", email = "fangs-lever6n@icloud.com" },
|
10
10
|
]
|
@@ -47,6 +47,8 @@ class SecurityConfig:
|
|
47
47
|
allowed_flags: set[str]
|
48
48
|
max_command_length: int
|
49
49
|
command_timeout: int
|
50
|
+
allow_all_commands: bool = False
|
51
|
+
allow_all_flags: bool = False
|
50
52
|
|
51
53
|
|
52
54
|
class CommandExecutor:
|
@@ -60,7 +62,7 @@ class CommandExecutor:
|
|
60
62
|
"""
|
61
63
|
Normalizes a path and ensures it's within allowed directory.
|
62
64
|
"""
|
63
|
-
try:
|
65
|
+
try:
|
64
66
|
if os.path.isabs(path):
|
65
67
|
# If absolute path, check directly
|
66
68
|
real_path = os.path.abspath(os.path.realpath(path))
|
@@ -109,21 +111,26 @@ class CommandExecutor:
|
|
109
111
|
|
110
112
|
command, args = parts[0], parts[1:]
|
111
113
|
|
112
|
-
# Validate command
|
113
|
-
if command not in self.security_config.allowed_commands:
|
114
|
+
# Validate command if not in allow-all mode
|
115
|
+
if not self.security_config.allow_all_commands and command not in self.security_config.allowed_commands:
|
114
116
|
raise CommandSecurityError(f"Command '{command}' is not allowed")
|
115
117
|
|
116
118
|
# Process and validate arguments
|
117
119
|
validated_args = []
|
118
120
|
for arg in args:
|
119
121
|
if arg.startswith("-"):
|
120
|
-
if arg not in self.security_config.allowed_flags:
|
122
|
+
if not self.security_config.allow_all_flags and arg not in self.security_config.allowed_flags:
|
121
123
|
raise CommandSecurityError(f"Flag '{arg}' is not allowed")
|
122
124
|
validated_args.append(arg)
|
123
125
|
continue
|
124
126
|
|
125
127
|
# For any path-like argument, validate it
|
126
|
-
if "/" in arg or "\\" in arg or os.path.isabs(arg) or arg == ".":
|
128
|
+
if "/" in arg or "\\" in arg or os.path.isabs(arg) or arg == ".":
|
129
|
+
if self._is_url_path(arg):
|
130
|
+
# If it's a URL, we don't need to normalize it
|
131
|
+
validated_args.append(arg)
|
132
|
+
continue
|
133
|
+
|
127
134
|
normalized_path = self._normalize_path(arg)
|
128
135
|
validated_args.append(normalized_path)
|
129
136
|
else:
|
@@ -135,6 +142,20 @@ class CommandExecutor:
|
|
135
142
|
except ValueError as e:
|
136
143
|
raise CommandSecurityError(f"Invalid command format: {str(e)}")
|
137
144
|
|
145
|
+
def _is_url_path(self, path: str) -> bool:
|
146
|
+
"""
|
147
|
+
Checks if a given path is a URL of type http or https.
|
148
|
+
|
149
|
+
Args:
|
150
|
+
path (str): The path to check.
|
151
|
+
|
152
|
+
Returns:
|
153
|
+
bool: True if the path is a URL, False otherwise.
|
154
|
+
"""
|
155
|
+
url_pattern = re.compile(r"^(http|https)://")
|
156
|
+
return bool(url_pattern.match(path))
|
157
|
+
|
158
|
+
|
138
159
|
def _is_path_safe(self, path: str) -> bool:
|
139
160
|
"""
|
140
161
|
Checks if a given path is safe to access within allowed directory boundaries.
|
@@ -224,19 +245,28 @@ def load_security_config() -> SecurityConfig:
|
|
224
245
|
- allowed_flags: Set of permitted command flags/options
|
225
246
|
- max_command_length: Maximum length of command string
|
226
247
|
- command_timeout: Maximum execution time in seconds
|
248
|
+
- allow_all_commands: Whether all commands are allowed
|
249
|
+
- allow_all_flags: Whether all flags are allowed
|
227
250
|
|
228
251
|
Environment Variables:
|
229
|
-
ALLOWED_COMMANDS: Comma-separated list of allowed commands (default: "ls,cat,pwd")
|
230
|
-
ALLOWED_FLAGS: Comma-separated list of allowed flags (default: "-l,-a,--help")
|
231
|
-
ALLOWED_PATTERNS: Comma-separated list of patterns (default: "*.txt,*.log,*.md")
|
252
|
+
ALLOWED_COMMANDS: Comma-separated list of allowed commands or 'all' (default: "ls,cat,pwd")
|
253
|
+
ALLOWED_FLAGS: Comma-separated list of allowed flags or 'all' (default: "-l,-a,--help")
|
232
254
|
MAX_COMMAND_LENGTH: Maximum command string length (default: 1024)
|
233
255
|
COMMAND_TIMEOUT: Command timeout in seconds (default: 30)
|
234
256
|
"""
|
257
|
+
allowed_commands = os.getenv("ALLOWED_COMMANDS", "ls,cat,pwd")
|
258
|
+
allowed_flags = os.getenv("ALLOWED_FLAGS", "-l,-a,--help")
|
259
|
+
|
260
|
+
allow_all_commands = allowed_commands.lower() == 'all'
|
261
|
+
allow_all_flags = allowed_flags.lower() == 'all'
|
262
|
+
|
235
263
|
return SecurityConfig(
|
236
|
-
allowed_commands=set(
|
237
|
-
allowed_flags=set(
|
264
|
+
allowed_commands=set() if allow_all_commands else set(allowed_commands.split(",")),
|
265
|
+
allowed_flags=set() if allow_all_flags else set(allowed_flags.split(",")),
|
238
266
|
max_command_length=int(os.getenv("MAX_COMMAND_LENGTH", "1024")),
|
239
267
|
command_timeout=int(os.getenv("COMMAND_TIMEOUT", "30")),
|
268
|
+
allow_all_commands=allow_all_commands,
|
269
|
+
allow_all_flags=allow_all_flags,
|
240
270
|
)
|
241
271
|
|
242
272
|
|
@@ -245,13 +275,16 @@ executor = CommandExecutor(allowed_dir=os.getenv("ALLOWED_DIR", ""), security_co
|
|
245
275
|
|
246
276
|
@server.list_tools()
|
247
277
|
async def handle_list_tools() -> list[types.Tool]:
|
278
|
+
commands_desc = "all commands" if executor.security_config.allow_all_commands else ", ".join(executor.security_config.allowed_commands)
|
279
|
+
flags_desc = "all flags" if executor.security_config.allow_all_flags else ", ".join(executor.security_config.allowed_flags)
|
280
|
+
|
248
281
|
return [
|
249
282
|
types.Tool(
|
250
283
|
name="run_command",
|
251
284
|
description=(
|
252
285
|
f"Allows command (CLI) execution in the directory: {executor.allowed_dir}\n\n"
|
253
|
-
f"Available commands: {
|
254
|
-
f"Available flags: {
|
286
|
+
f"Available commands: {commands_desc}\n"
|
287
|
+
f"Available flags: {flags_desc}\n\n"
|
255
288
|
"Note: Shell operators (&&, |, >, >>) are not supported."
|
256
289
|
),
|
257
290
|
inputSchema={
|
@@ -314,16 +347,19 @@ async def handle_call_tool(name: str, arguments: Optional[Dict[str, Any]]) -> Li
|
|
314
347
|
return [types.TextContent(type="text", text=f"Error: {str(e)}", error=True)]
|
315
348
|
|
316
349
|
elif name == "show_security_rules":
|
350
|
+
commands_desc = "All commands allowed" if executor.security_config.allow_all_commands else ", ".join(sorted(executor.security_config.allowed_commands))
|
351
|
+
flags_desc = "All flags allowed" if executor.security_config.allow_all_flags else ", ".join(sorted(executor.security_config.allowed_flags))
|
352
|
+
|
317
353
|
security_info = (
|
318
354
|
"Security Configuration:\n"
|
319
355
|
f"==================\n"
|
320
356
|
f"Working Directory: {executor.allowed_dir}\n"
|
321
357
|
f"\nAllowed Commands:\n"
|
322
358
|
f"----------------\n"
|
323
|
-
f"{
|
359
|
+
f"{commands_desc}\n"
|
324
360
|
f"\nAllowed Flags:\n"
|
325
361
|
f"-------------\n"
|
326
|
-
f"{
|
362
|
+
f"{flags_desc}\n"
|
327
363
|
f"\nSecurity Limits:\n"
|
328
364
|
f"---------------\n"
|
329
365
|
f"Max Command Length: {executor.security_config.max_command_length} characters\n"
|
@@ -341,10 +377,10 @@ async def main():
|
|
341
377
|
write_stream,
|
342
378
|
InitializationOptions(
|
343
379
|
server_name="cli-mcp-server",
|
344
|
-
server_version="0.2.
|
380
|
+
server_version="0.2.1",
|
345
381
|
capabilities=server.get_capabilities(
|
346
382
|
notification_options=NotificationOptions(),
|
347
383
|
experimental_capabilities={},
|
348
384
|
),
|
349
385
|
),
|
350
|
-
)
|
386
|
+
)
|
@@ -36,14 +36,14 @@ wheels = [
|
|
36
36
|
|
37
37
|
[[package]]
|
38
38
|
name = "cli-mcp-server"
|
39
|
-
version = "0.2.
|
39
|
+
version = "0.2.2"
|
40
40
|
source = { editable = "." }
|
41
41
|
dependencies = [
|
42
42
|
{ name = "mcp" },
|
43
43
|
]
|
44
44
|
|
45
45
|
[package.metadata]
|
46
|
-
requires-dist = [{ name = "mcp", specifier = ">=1.
|
46
|
+
requires-dist = [{ name = "mcp", specifier = ">=1.1.0" }]
|
47
47
|
|
48
48
|
[[package]]
|
49
49
|
name = "click"
|
@@ -132,7 +132,7 @@ wheels = [
|
|
132
132
|
|
133
133
|
[[package]]
|
134
134
|
name = "mcp"
|
135
|
-
version = "1.
|
135
|
+
version = "1.1.2"
|
136
136
|
source = { registry = "https://pypi.org/simple" }
|
137
137
|
dependencies = [
|
138
138
|
{ name = "anyio" },
|
@@ -142,9 +142,9 @@ dependencies = [
|
|
142
142
|
{ name = "sse-starlette" },
|
143
143
|
{ name = "starlette" },
|
144
144
|
]
|
145
|
-
sdist = { url = "https://files.pythonhosted.org/packages/
|
145
|
+
sdist = { url = "https://files.pythonhosted.org/packages/9b/f3/5cf212e60681ea6da0dbb6e0d1bc0ab2dbf5eebc749b69663d46f114fea1/mcp-1.1.2.tar.gz", hash = "sha256:694aa9df7a8641b24953c935eb72c63136dc948981021525a0add199bdfee402", size = 57628 }
|
146
146
|
wheels = [
|
147
|
-
{ url = "https://files.pythonhosted.org/packages/
|
147
|
+
{ url = "https://files.pythonhosted.org/packages/df/40/9883eac3718b860d4006eba1920bfcb628f0a1fe37fac46a4f4e391edca6/mcp-1.1.2-py3-none-any.whl", hash = "sha256:a4d32d60fd80a1702440ba4751b847a8a88957a1f7b059880953143e9759965a", size = 36652 },
|
148
148
|
]
|
149
149
|
|
150
150
|
[[package]]
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|