mcp-cli-skill 0.4.7__tar.gz → 0.4.9__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: mcp-cli-skill
3
- Version: 0.4.7
3
+ Version: 0.4.9
4
4
  Summary: Call any MCP server tool from the command line with shell composition support
5
5
  Project-URL: Homepage, https://github.com/wise-toddler/mcp-cli-skill
6
6
  Project-URL: Repository, https://github.com/wise-toddler/mcp-cli-skill
@@ -54,6 +54,20 @@ mcp-call --remove myserver
54
54
  mcp-call --sync # re-sync from Claude configs
55
55
  ```
56
56
 
57
+ ### Environment variables
58
+
59
+ `${VAR}` patterns in URLs, headers, command args, and env values are expanded at runtime:
60
+
61
+ ```json
62
+ {
63
+ "myapi": {
64
+ "type": "http",
65
+ "url": "https://${API_HOST}/mcp",
66
+ "headers": { "X-API-Key": "${MY_API_KEY}" }
67
+ }
68
+ }
69
+ ```
70
+
57
71
  ## Why?
58
72
 
59
73
  MCP tool calls can't use shell composition. This CLI lets agents (or you) use:
@@ -38,6 +38,20 @@ mcp-call --remove myserver
38
38
  mcp-call --sync # re-sync from Claude configs
39
39
  ```
40
40
 
41
+ ### Environment variables
42
+
43
+ `${VAR}` patterns in URLs, headers, command args, and env values are expanded at runtime:
44
+
45
+ ```json
46
+ {
47
+ "myapi": {
48
+ "type": "http",
49
+ "url": "https://${API_HOST}/mcp",
50
+ "headers": { "X-API-Key": "${MY_API_KEY}" }
51
+ }
52
+ }
53
+ ```
54
+
41
55
  ## Why?
42
56
 
43
57
  MCP tool calls can't use shell composition. This CLI lets agents (or you) use:
@@ -6,6 +6,7 @@ import os
6
6
  import subprocess
7
7
  import sys
8
8
  import tempfile
9
+ import re
9
10
  import urllib.request
10
11
  import urllib.error
11
12
 
@@ -193,15 +194,20 @@ def _print_content(items):
193
194
  print(path)
194
195
 
195
196
 
197
+ def _expand_env(val):
198
+ """Expand ${VAR} patterns in a string using env variables."""
199
+ return re.sub(r'\$\{(\w+)\}', lambda m: os.environ.get(m.group(1), m.group(0)), val)
200
+
201
+
196
202
  # --- HTTP transport ---
197
203
 
198
204
  class HttpSession:
199
205
  """Manages HTTP MCP session with session ID tracking."""
200
206
 
201
207
  def __init__(self, url, extra_headers=None):
202
- self.url = url
208
+ self.url = _expand_env(url)
203
209
  self.session_id = None
204
- self.extra_headers = extra_headers or {}
210
+ self.extra_headers = {k: _expand_env(v) for k, v in (extra_headers or {}).items()}
205
211
 
206
212
  def rpc(self, method, params=None, msg_id=1):
207
213
  """Send JSON-RPC over HTTP and return response."""
@@ -212,6 +218,7 @@ class HttpSession:
212
218
  headers = {
213
219
  "Content-Type": "application/json",
214
220
  "Accept": "application/json, text/event-stream",
221
+ "User-Agent": "mcp-cli/1.0",
215
222
  }
216
223
  headers.update(self.extra_headers)
217
224
  if self.session_id:
@@ -332,8 +339,8 @@ def recv(proc, expected_id=None):
332
339
 
333
340
  def spawn_server(config):
334
341
  """Spawn MCP server subprocess."""
335
- cmd = [config["command"]] + config.get("args", [])
336
- env = {**os.environ, **config.get("env", {})}
342
+ cmd = [_expand_env(config["command"])] + [_expand_env(a) for a in config.get("args", [])]
343
+ env = {**os.environ, **{k: _expand_env(v) for k, v in config.get("env", {}).items()}}
337
344
  return subprocess.Popen(
338
345
  cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
339
346
  stderr=subprocess.PIPE, text=True, env=env
@@ -1,2 +1,2 @@
1
1
  """MCP CLI - Call any MCP server tool from the command line."""
2
- __version__ = "0.4.7"
2
+ __version__ = "0.4.9"
@@ -6,6 +6,7 @@ import os
6
6
  import subprocess
7
7
  import sys
8
8
  import tempfile
9
+ import re
9
10
  import urllib.request
10
11
  import urllib.error
11
12
 
@@ -193,15 +194,20 @@ def _print_content(items):
193
194
  print(path)
194
195
 
195
196
 
197
+ def _expand_env(val):
198
+ """Expand ${VAR} patterns in a string using env variables."""
199
+ return re.sub(r'\$\{(\w+)\}', lambda m: os.environ.get(m.group(1), m.group(0)), val)
200
+
201
+
196
202
  # --- HTTP transport ---
197
203
 
198
204
  class HttpSession:
199
205
  """Manages HTTP MCP session with session ID tracking."""
200
206
 
201
207
  def __init__(self, url, extra_headers=None):
202
- self.url = url
208
+ self.url = _expand_env(url)
203
209
  self.session_id = None
204
- self.extra_headers = extra_headers or {}
210
+ self.extra_headers = {k: _expand_env(v) for k, v in (extra_headers or {}).items()}
205
211
 
206
212
  def rpc(self, method, params=None, msg_id=1):
207
213
  """Send JSON-RPC over HTTP and return response."""
@@ -212,6 +218,7 @@ class HttpSession:
212
218
  headers = {
213
219
  "Content-Type": "application/json",
214
220
  "Accept": "application/json, text/event-stream",
221
+ "User-Agent": "mcp-cli/1.0",
215
222
  }
216
223
  headers.update(self.extra_headers)
217
224
  if self.session_id:
@@ -332,8 +339,8 @@ def recv(proc, expected_id=None):
332
339
 
333
340
  def spawn_server(config):
334
341
  """Spawn MCP server subprocess."""
335
- cmd = [config["command"]] + config.get("args", [])
336
- env = {**os.environ, **config.get("env", {})}
342
+ cmd = [_expand_env(config["command"])] + [_expand_env(a) for a in config.get("args", [])]
343
+ env = {**os.environ, **{k: _expand_env(v) for k, v in config.get("env", {}).items()}}
337
344
  return subprocess.Popen(
338
345
  cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
339
346
  stderr=subprocess.PIPE, text=True, env=env
File without changes