cli-mcp-server 0.2.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cli-mcp-server
3
- Version: 0.2.1
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
@@ -17,8 +17,7 @@ Description-Content-Type: text/markdown
17
17
  ---
18
18
 
19
19
  A secure Model Context Protocol (MCP) server implementation for executing controlled command-line operations with
20
- comprehensive security
21
- features.
20
+ comprehensive security features.
22
21
 
23
22
  ![License](https://img.shields.io/badge/license-MIT-blue.svg)
24
23
  ![Python Version](https://img.shields.io/badge/python-3.10%2B-blue)
@@ -53,30 +52,32 @@ features.
53
52
  ## Overview
54
53
 
55
54
  This MCP server enables secure command-line execution with robust security measures including command whitelisting, path
56
- validation, and
57
- 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.
58
56
 
59
57
  ## Features
60
58
 
61
59
  - 🔒 Secure command execution with strict validation
62
- - ⚙️ Configurable command and flag whitelisting
63
- - 🛡️ Path traversal prevention
60
+ - ⚙️ Configurable command and flag whitelisting with 'all' option
61
+ - 🛡️ Path traversal prevention and validation
64
62
  - 🚫 Shell operator injection protection
65
63
  - ⏱️ Execution timeouts and length limits
66
64
  - 📝 Detailed error reporting
67
65
  - 🔄 Async operation support
66
+ - 🎯 Working directory restriction and validation
68
67
 
69
68
  ## Configuration
70
69
 
71
70
  Configure the server using environment variables:
72
71
 
73
- | Variable | Description | Default |
74
- |----------------------|------------------------------------------|--------------------|
75
- | `ALLOWED_DIR` | Base directory for command execution | Required |
76
- | `ALLOWED_COMMANDS` | Comma-separated list of allowed commands | `ls,cat,pwd` |
77
- | `ALLOWED_FLAGS` | Comma-separated list of allowed flags | `-l,-a,--help` |
78
- | `MAX_COMMAND_LENGTH` | Maximum command string length | `1024` |
79
- | `COMMAND_TIMEOUT` | Command execution timeout (seconds) | `30` |
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.
80
81
 
81
82
  ## Installation
82
83
 
@@ -93,19 +94,28 @@ npx @smithery/cli install cli-mcp-server --client claude
93
94
  Executes whitelisted CLI commands within allowed directories.
94
95
 
95
96
  **Input Schema:**
96
-
97
- ```json
98
- {
97
+ ```json
98
+ {
99
99
  "command": {
100
100
  "type": "string",
101
- "description": "Command to execute (e.g., 'ls -l' or 'cat file.txt')"
101
+ "description": "Single command to execute (e.g., 'ls -l' or 'cat file.txt')"
102
102
  }
103
103
  }
104
- ```
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
105
111
 
106
112
  ### show_security_rules
107
113
 
108
- 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)
109
119
 
110
120
  ## Usage with Claude Desktop
111
121
 
@@ -113,7 +123,7 @@ Add to your `~/Library/Application\ Support/Claude/claude_desktop_config.json`:
113
123
 
114
124
  > Development/Unpublished Servers Configuration
115
125
 
116
- ```json
126
+ ```json
117
127
  {
118
128
  "mcpServers": {
119
129
  "cli-mcp-server": {
@@ -134,7 +144,7 @@ Add to your `~/Library/Application\ Support/Claude/claude_desktop_config.json`:
134
144
  }
135
145
  }
136
146
  }
137
- ```
147
+ ```
138
148
 
139
149
  > Published Servers Configuration
140
150
 
@@ -161,23 +171,25 @@ Add to your `~/Library/Application\ Support/Claude/claude_desktop_config.json`:
161
171
 
162
172
  ## Security Features
163
173
 
164
- - ✅ Command whitelist enforcement
165
- - ✅ Flag validation
166
- - ✅ Path traversal prevention
174
+ - ✅ Command whitelist enforcement with 'all' option
175
+ - ✅ Flag validation with 'all' option
176
+ - ✅ Path traversal prevention and normalization
167
177
  - ✅ Shell operator blocking
168
178
  - ✅ Command length limits
169
179
  - ✅ Execution timeouts
170
180
  - ✅ Working directory restrictions
181
+ - ✅ Symlink resolution and validation
171
182
 
172
183
  ## Error Handling
173
184
 
174
185
  The server provides detailed error messages for:
175
186
 
176
- - Security violations
177
- - Command timeouts
187
+ - Security violations (CommandSecurityError)
188
+ - Command timeouts (CommandTimeoutError)
178
189
  - Invalid command formats
179
190
  - Path security violations
180
- - Execution failures
191
+ - Execution failures (CommandExecutionError)
192
+ - General command errors (CommandError)
181
193
 
182
194
  ## Development
183
195
 
@@ -186,8 +198,6 @@ The server provides detailed error messages for:
186
198
  - Python 3.10+
187
199
  - MCP protocol library
188
200
 
189
- ## Development
190
-
191
201
  ### Building and Publishing
192
202
 
193
203
  To prepare the package for distribution:
@@ -227,6 +237,6 @@ Upon launching, the Inspector will display a URL that you can access in your bro
227
237
 
228
238
  This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
229
239
 
230
- ---
240
+ ---
231
241
 
232
- For more information or support, please open an issue on the project repository.
242
+ For more information or support, please open an issue on the project repository.
@@ -3,8 +3,7 @@
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
  ![License](https://img.shields.io/badge/license-MIT-blue.svg)
10
9
  ![Python Version](https://img.shields.io/badge/python-3.10%2B-blue)
@@ -39,30 +38,32 @@ features.
39
38
  ## Overview
40
39
 
41
40
  This MCP server enables secure command-line execution with robust security measures including command whitelisting, path
42
- validation, and
43
- 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.
44
42
 
45
43
  ## Features
46
44
 
47
45
  - 🔒 Secure command execution with strict validation
48
- - ⚙️ Configurable command and flag whitelisting
49
- - 🛡️ Path traversal prevention
46
+ - ⚙️ Configurable command and flag whitelisting with 'all' option
47
+ - 🛡️ Path traversal prevention and validation
50
48
  - 🚫 Shell operator injection protection
51
49
  - ⏱️ Execution timeouts and length limits
52
50
  - 📝 Detailed error reporting
53
51
  - 🔄 Async operation support
52
+ - 🎯 Working directory restriction and validation
54
53
 
55
54
  ## Configuration
56
55
 
57
56
  Configure the server using environment variables:
58
57
 
59
- | Variable | Description | Default |
60
- |----------------------|------------------------------------------|--------------------|
61
- | `ALLOWED_DIR` | Base directory for command execution | Required |
62
- | `ALLOWED_COMMANDS` | Comma-separated list of allowed commands | `ls,cat,pwd` |
63
- | `ALLOWED_FLAGS` | Comma-separated list of allowed flags | `-l,-a,--help` |
64
- | `MAX_COMMAND_LENGTH` | Maximum command string length | `1024` |
65
- | `COMMAND_TIMEOUT` | Command execution timeout (seconds) | `30` |
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.
66
67
 
67
68
  ## Installation
68
69
 
@@ -79,19 +80,28 @@ npx @smithery/cli install cli-mcp-server --client claude
79
80
  Executes whitelisted CLI commands within allowed directories.
80
81
 
81
82
  **Input Schema:**
82
-
83
- ```json
84
- {
83
+ ```json
84
+ {
85
85
  "command": {
86
86
  "type": "string",
87
- "description": "Command to execute (e.g., 'ls -l' or 'cat file.txt')"
87
+ "description": "Single command to execute (e.g., 'ls -l' or 'cat file.txt')"
88
88
  }
89
89
  }
90
- ```
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
91
97
 
92
98
  ### show_security_rules
93
99
 
94
- 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)
95
105
 
96
106
  ## Usage with Claude Desktop
97
107
 
@@ -99,7 +109,7 @@ Add to your `~/Library/Application\ Support/Claude/claude_desktop_config.json`:
99
109
 
100
110
  > Development/Unpublished Servers Configuration
101
111
 
102
- ```json
112
+ ```json
103
113
  {
104
114
  "mcpServers": {
105
115
  "cli-mcp-server": {
@@ -120,7 +130,7 @@ Add to your `~/Library/Application\ Support/Claude/claude_desktop_config.json`:
120
130
  }
121
131
  }
122
132
  }
123
- ```
133
+ ```
124
134
 
125
135
  > Published Servers Configuration
126
136
 
@@ -147,23 +157,25 @@ Add to your `~/Library/Application\ Support/Claude/claude_desktop_config.json`:
147
157
 
148
158
  ## Security Features
149
159
 
150
- - ✅ Command whitelist enforcement
151
- - ✅ Flag validation
152
- - ✅ Path traversal prevention
160
+ - ✅ Command whitelist enforcement with 'all' option
161
+ - ✅ Flag validation with 'all' option
162
+ - ✅ Path traversal prevention and normalization
153
163
  - ✅ Shell operator blocking
154
164
  - ✅ Command length limits
155
165
  - ✅ Execution timeouts
156
166
  - ✅ Working directory restrictions
167
+ - ✅ Symlink resolution and validation
157
168
 
158
169
  ## Error Handling
159
170
 
160
171
  The server provides detailed error messages for:
161
172
 
162
- - Security violations
163
- - Command timeouts
173
+ - Security violations (CommandSecurityError)
174
+ - Command timeouts (CommandTimeoutError)
164
175
  - Invalid command formats
165
176
  - Path security violations
166
- - Execution failures
177
+ - Execution failures (CommandExecutionError)
178
+ - General command errors (CommandError)
167
179
 
168
180
  ## Development
169
181
 
@@ -172,8 +184,6 @@ The server provides detailed error messages for:
172
184
  - Python 3.10+
173
185
  - MCP protocol library
174
186
 
175
- ## Development
176
-
177
187
  ### Building and Publishing
178
188
 
179
189
  To prepare the package for distribution:
@@ -213,6 +223,6 @@ Upon launching, the Inspector will display a URL that you can access in your bro
213
223
 
214
224
  This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
215
225
 
216
- ---
226
+ ---
217
227
 
218
- For more information or support, please open an issue on the project repository.
228
+ For more information or support, please open an issue on the project repository.
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "https://glama.ai/mcp/schemas/server.json",
3
+ "maintainers": [
4
+ "MladenSU"
5
+ ]
6
+ }
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "cli-mcp-server"
3
- version = "0.2.1"
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"
@@ -62,7 +62,7 @@ class CommandExecutor:
62
62
  """
63
63
  Normalizes a path and ensures it's within allowed directory.
64
64
  """
65
- try:
65
+ try:
66
66
  if os.path.isabs(path):
67
67
  # If absolute path, check directly
68
68
  real_path = os.path.abspath(os.path.realpath(path))
@@ -125,7 +125,12 @@ class CommandExecutor:
125
125
  continue
126
126
 
127
127
  # For any path-like argument, validate it
128
- 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
+
129
134
  normalized_path = self._normalize_path(arg)
130
135
  validated_args.append(normalized_path)
131
136
  else:
@@ -137,6 +142,20 @@ class CommandExecutor:
137
142
  except ValueError as e:
138
143
  raise CommandSecurityError(f"Invalid command format: {str(e)}")
139
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
+
140
159
  def _is_path_safe(self, path: str) -> bool:
141
160
  """
142
161
  Checks if a given path is safe to access within allowed directory boundaries.
@@ -36,7 +36,7 @@ wheels = [
36
36
 
37
37
  [[package]]
38
38
  name = "cli-mcp-server"
39
- version = "0.2.1"
39
+ version = "0.2.2"
40
40
  source = { editable = "." }
41
41
  dependencies = [
42
42
  { name = "mcp" },
File without changes