drydock-cli 3.0.54__tar.gz → 3.0.55__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.
- {drydock_cli-3.0.54/drydock_cli.egg-info → drydock_cli-3.0.55}/PKG-INFO +1 -1
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/drydock/cli.py +32 -0
- drydock_cli-3.0.55/drydock/mcp.py +213 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/drydock/tui/app.py +24 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/drydock/tui/widgets.py +1 -1
- {drydock_cli-3.0.54 → drydock_cli-3.0.55/drydock_cli.egg-info}/PKG-INFO +1 -1
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/drydock_cli.egg-info/SOURCES.txt +2 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/pyproject.toml +1 -1
- drydock_cli-3.0.55/tests/test_mcp.py +57 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/LICENSE +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/NOTICE +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/README.md +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/drydock/__init__.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/drydock/__main__.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/drydock/agent.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/drydock/bash_safety.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/drydock/compaction.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/drydock/config.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/drydock/detect.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/drydock/gittools.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/drydock/graphrag.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/drydock/guards.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/drydock/loop_detect.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/drydock/providers.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/drydock/skills.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/drydock/tool_registry.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/drydock/tools/__init__.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/drydock/tui/__init__.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/drydock/tui/approval.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/drydock/tui/messages.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/drydock/tuning.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/drydock/web.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/drydock_cli.egg-info/dependency_links.txt +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/drydock_cli.egg-info/entry_points.txt +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/drydock_cli.egg-info/requires.txt +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/drydock_cli.egg-info/top_level.txt +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/setup.cfg +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_approval.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_back_command.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_bash_process_group.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_bash_safety.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_bash_timeout_network.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_cli_agents.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_compact_command.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_compaction.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_config.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_config_migration.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_context_limit_config.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_detect.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_dispatch.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_empty_response.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_failure_loop.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_first_run_setup.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_gittools.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_graphrag.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_guards_and_tools.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_hallucinated_tools.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_leaked_tool_call.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_loop_detect.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_oneshot_unreachable.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_plan_autocontinue.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_providers_unreachable.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_runaway_repetition.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_skills.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_stop.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_streaming_newlines.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_subagent.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_todo.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_tool_arg_parsing.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_tools_undo.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_tui.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_tuning.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_vision_input.py +0 -0
- {drydock_cli-3.0.54 → drydock_cli-3.0.55}/tests/test_web_tools.py +0 -0
|
@@ -268,6 +268,33 @@ def _first_run_setup(cfg: dict, cfg_path, cfgmod) -> tuple[dict, str]:
|
|
|
268
268
|
return cfg, f"⚓ Using {model} at {url}"
|
|
269
269
|
|
|
270
270
|
|
|
271
|
+
def _connect_mcp(config: dict) -> None:
|
|
272
|
+
"""Start configured MCP servers and register their tools into the registry.
|
|
273
|
+
Quiet + crash-proof: any failure is logged to config['mcp_log'], never
|
|
274
|
+
raised. No-op when no mcp.json exists."""
|
|
275
|
+
import atexit
|
|
276
|
+
|
|
277
|
+
from drydock import mcp
|
|
278
|
+
from drydock.tool_registry import ToolDef, register
|
|
279
|
+
|
|
280
|
+
log: list[str] = []
|
|
281
|
+
try:
|
|
282
|
+
schemas = mcp.connect_all(config.get("cwd") or os.getcwd(), log=log.append)
|
|
283
|
+
except Exception as e: # noqa: BLE001 — never block startup on MCP
|
|
284
|
+
config["mcp_log"] = [f"MCP init error: {e}"]
|
|
285
|
+
return
|
|
286
|
+
for sch in schemas:
|
|
287
|
+
_, server, tool = sch["name"].split("__", 2)
|
|
288
|
+
register(ToolDef(
|
|
289
|
+
name=sch["name"], schema=sch,
|
|
290
|
+
func=(lambda params, cfg, s=server, t=tool: mcp.call(s, t, params)),
|
|
291
|
+
read_only=False,
|
|
292
|
+
))
|
|
293
|
+
config["mcp_log"] = log
|
|
294
|
+
if mcp.connected():
|
|
295
|
+
atexit.register(mcp.shutdown)
|
|
296
|
+
|
|
297
|
+
|
|
271
298
|
def main():
|
|
272
299
|
parser = argparse.ArgumentParser(description="DryDock — local coding agent")
|
|
273
300
|
parser.add_argument(
|
|
@@ -349,6 +376,11 @@ def main():
|
|
|
349
376
|
# call load_project_instructions directly (see run_interactive/run_oneshot).
|
|
350
377
|
config["project_instructions"] = load_project_instructions()
|
|
351
378
|
|
|
379
|
+
# Connect any configured MCP servers and register their tools so the model
|
|
380
|
+
# can call them like native tools. Failures are skipped (never block start);
|
|
381
|
+
# status is stashed for /mcp. Servers are torn down at exit.
|
|
382
|
+
_connect_mcp(config)
|
|
383
|
+
|
|
352
384
|
if args.prompt:
|
|
353
385
|
run_oneshot(args.prompt, config)
|
|
354
386
|
elif args.cli:
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
"""MCP (Model Context Protocol) client — connect to MCP servers, expose their
|
|
2
|
+
tools to the agent.
|
|
3
|
+
|
|
4
|
+
Clean-room, stdlib only (no `mcp` SDK dependency): a minimal JSON-RPC 2.0 client
|
|
5
|
+
over the stdio transport (newline-delimited JSON), which is what local MCP
|
|
6
|
+
servers use. We do the initialize handshake, list the server's tools, and call
|
|
7
|
+
them on demand; results come back as text the model reads like any tool output.
|
|
8
|
+
|
|
9
|
+
Config (standard mcpServers shape, like Claude Desktop):
|
|
10
|
+
~/.drydock/mcp.json and/or <cwd>/.drydock/mcp.json
|
|
11
|
+
{
|
|
12
|
+
"mcpServers": {
|
|
13
|
+
"files": {"command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "/data"]},
|
|
14
|
+
"weather": {"command": "python", "args": ["weather_server.py"], "env": {"KEY": "..."}}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
Tools are registered as ``mcp__<server>__<tool>``. Everything degrades cleanly:
|
|
19
|
+
a server that fails to start or times out is skipped with a logged note, never
|
|
20
|
+
crashing drydock.
|
|
21
|
+
|
|
22
|
+
All logic original to Drydock.
|
|
23
|
+
"""
|
|
24
|
+
from __future__ import annotations
|
|
25
|
+
|
|
26
|
+
import json
|
|
27
|
+
import os
|
|
28
|
+
import subprocess
|
|
29
|
+
import threading
|
|
30
|
+
from pathlib import Path
|
|
31
|
+
|
|
32
|
+
_PROTOCOL_VERSION = "2024-11-05"
|
|
33
|
+
# Live servers for this process, by name. The tool funcs look servers up here.
|
|
34
|
+
_SERVERS: dict[str, "MCPServer"] = {}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class MCPError(RuntimeError):
|
|
38
|
+
pass
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class MCPServer:
|
|
42
|
+
"""One stdio MCP server subprocess + a synchronous JSON-RPC channel."""
|
|
43
|
+
|
|
44
|
+
def __init__(self, name: str, command: str, args: list[str], env: dict | None = None):
|
|
45
|
+
self.name = name
|
|
46
|
+
self.command = command
|
|
47
|
+
self.args = args or []
|
|
48
|
+
self.env = env or {}
|
|
49
|
+
self.proc: subprocess.Popen | None = None
|
|
50
|
+
self.tools: list[dict] = []
|
|
51
|
+
self._id = 0
|
|
52
|
+
self._lock = threading.Lock()
|
|
53
|
+
|
|
54
|
+
# ── transport ──────────────────────────────────────────────────────────
|
|
55
|
+
def _send(self, msg: dict) -> None:
|
|
56
|
+
assert self.proc and self.proc.stdin
|
|
57
|
+
self.proc.stdin.write(json.dumps(msg) + "\n")
|
|
58
|
+
self.proc.stdin.flush()
|
|
59
|
+
|
|
60
|
+
def _read_result(self, want_id: int, timeout: float = 20.0) -> dict:
|
|
61
|
+
"""Read newline-delimited JSON until the response with want_id arrives.
|
|
62
|
+
Notifications / other-id messages are skipped. (Requests are serialized
|
|
63
|
+
under _lock, so responses effectively arrive in order.)"""
|
|
64
|
+
assert self.proc and self.proc.stdout
|
|
65
|
+
import time
|
|
66
|
+
deadline = time.monotonic() + timeout
|
|
67
|
+
while True:
|
|
68
|
+
if time.monotonic() > deadline:
|
|
69
|
+
raise MCPError(f"{self.name}: timed out waiting for response {want_id}")
|
|
70
|
+
line = self.proc.stdout.readline()
|
|
71
|
+
if line == "":
|
|
72
|
+
raise MCPError(f"{self.name}: server closed the connection")
|
|
73
|
+
line = line.strip()
|
|
74
|
+
if not line:
|
|
75
|
+
continue
|
|
76
|
+
try:
|
|
77
|
+
msg = json.loads(line)
|
|
78
|
+
except ValueError:
|
|
79
|
+
continue # stray non-JSON (some servers log to stdout — ignore)
|
|
80
|
+
if msg.get("id") == want_id:
|
|
81
|
+
if "error" in msg:
|
|
82
|
+
raise MCPError(f"{self.name}: {msg['error'].get('message', msg['error'])}")
|
|
83
|
+
return msg.get("result", {})
|
|
84
|
+
|
|
85
|
+
def _request(self, method: str, params: dict | None = None, timeout: float = 20.0) -> dict:
|
|
86
|
+
with self._lock:
|
|
87
|
+
self._id += 1
|
|
88
|
+
rid = self._id
|
|
89
|
+
self._send({"jsonrpc": "2.0", "id": rid, "method": method, "params": params or {}})
|
|
90
|
+
return self._read_result(rid, timeout=timeout)
|
|
91
|
+
|
|
92
|
+
def _notify(self, method: str, params: dict | None = None) -> None:
|
|
93
|
+
with self._lock:
|
|
94
|
+
self._send({"jsonrpc": "2.0", "method": method, "params": params or {}})
|
|
95
|
+
|
|
96
|
+
# ── lifecycle ──────────────────────────────────────────────────────────
|
|
97
|
+
def start(self, timeout: float = 20.0) -> None:
|
|
98
|
+
env = {**os.environ, **self.env}
|
|
99
|
+
self.proc = subprocess.Popen(
|
|
100
|
+
[self.command, *self.args],
|
|
101
|
+
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL,
|
|
102
|
+
text=True, env=env, bufsize=1,
|
|
103
|
+
)
|
|
104
|
+
self._request("initialize", {
|
|
105
|
+
"protocolVersion": _PROTOCOL_VERSION,
|
|
106
|
+
"capabilities": {},
|
|
107
|
+
"clientInfo": {"name": "drydock", "version": "1"},
|
|
108
|
+
}, timeout=timeout)
|
|
109
|
+
self._notify("notifications/initialized")
|
|
110
|
+
result = self._request("tools/list", {}, timeout=timeout)
|
|
111
|
+
self.tools = result.get("tools", []) or []
|
|
112
|
+
|
|
113
|
+
def call(self, tool: str, arguments: dict, timeout: float = 60.0) -> str:
|
|
114
|
+
result = self._request("tools/call", {"name": tool, "arguments": arguments or {}},
|
|
115
|
+
timeout=timeout)
|
|
116
|
+
return _content_to_text(result)
|
|
117
|
+
|
|
118
|
+
def stop(self) -> None:
|
|
119
|
+
if self.proc:
|
|
120
|
+
try:
|
|
121
|
+
self.proc.terminate()
|
|
122
|
+
except Exception: # noqa: BLE001
|
|
123
|
+
pass
|
|
124
|
+
self.proc = None
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def _content_to_text(result: dict) -> str:
|
|
128
|
+
"""Flatten an MCP tools/call result (content blocks) to text."""
|
|
129
|
+
if not isinstance(result, dict):
|
|
130
|
+
return str(result)
|
|
131
|
+
blocks = result.get("content")
|
|
132
|
+
if isinstance(blocks, list):
|
|
133
|
+
parts = []
|
|
134
|
+
for b in blocks:
|
|
135
|
+
if isinstance(b, dict):
|
|
136
|
+
if b.get("type") == "text":
|
|
137
|
+
parts.append(b.get("text", ""))
|
|
138
|
+
else:
|
|
139
|
+
parts.append(json.dumps(b))
|
|
140
|
+
text = "\n".join(p for p in parts if p)
|
|
141
|
+
else:
|
|
142
|
+
text = json.dumps(result)
|
|
143
|
+
if result.get("isError"):
|
|
144
|
+
text = f"[tool reported an error]\n{text}"
|
|
145
|
+
return text or "(empty result)"
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
# ── config + connection ────────────────────────────────────────────────────
|
|
149
|
+
|
|
150
|
+
def config_paths(cwd: str) -> list[Path]:
|
|
151
|
+
return [Path.home() / ".drydock" / "mcp.json", Path(cwd) / ".drydock" / "mcp.json"]
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def load_config(cwd: str) -> dict:
|
|
155
|
+
"""Merge mcpServers from user + project config (project overrides by name)."""
|
|
156
|
+
servers: dict[str, dict] = {}
|
|
157
|
+
for p in config_paths(cwd):
|
|
158
|
+
if not p.is_file():
|
|
159
|
+
continue
|
|
160
|
+
try:
|
|
161
|
+
data = json.loads(p.read_text("utf-8"))
|
|
162
|
+
except (OSError, ValueError):
|
|
163
|
+
continue
|
|
164
|
+
for name, spec in (data.get("mcpServers") or {}).items():
|
|
165
|
+
if isinstance(spec, dict) and spec.get("command"):
|
|
166
|
+
servers[name] = spec
|
|
167
|
+
return servers
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def connect_all(cwd: str, *, log=None) -> list[dict]:
|
|
171
|
+
"""Start every configured MCP server and return drydock tool schemas for
|
|
172
|
+
their tools (namespaced mcp__<server>__<tool>). Failures are skipped."""
|
|
173
|
+
_say = log or (lambda *_: None)
|
|
174
|
+
schemas: list[dict] = []
|
|
175
|
+
for name, spec in load_config(cwd).items():
|
|
176
|
+
if name in _SERVERS:
|
|
177
|
+
continue
|
|
178
|
+
srv = MCPServer(name, spec["command"], spec.get("args") or [], spec.get("env") or {})
|
|
179
|
+
try:
|
|
180
|
+
srv.start()
|
|
181
|
+
except (MCPError, OSError, Exception) as e: # noqa: BLE001 — never crash startup
|
|
182
|
+
_say(f"MCP server '{name}' failed to start: {e}")
|
|
183
|
+
srv.stop()
|
|
184
|
+
continue
|
|
185
|
+
_SERVERS[name] = srv
|
|
186
|
+
for t in srv.tools:
|
|
187
|
+
schemas.append({
|
|
188
|
+
"name": f"mcp__{name}__{t['name']}",
|
|
189
|
+
"description": (t.get("description") or f"{name} tool {t['name']}")[:1024],
|
|
190
|
+
"input_schema": t.get("inputSchema") or {"type": "object", "properties": {}},
|
|
191
|
+
})
|
|
192
|
+
_say(f"MCP server '{name}': {len(srv.tools)} tool(s)")
|
|
193
|
+
return schemas
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
def call(server: str, tool: str, arguments: dict) -> str:
|
|
197
|
+
srv = _SERVERS.get(server)
|
|
198
|
+
if srv is None:
|
|
199
|
+
return f"MCP server '{server}' is not connected."
|
|
200
|
+
try:
|
|
201
|
+
return srv.call(tool, arguments)
|
|
202
|
+
except MCPError as e:
|
|
203
|
+
return f"MCP call failed: {e}"
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def connected() -> dict[str, "MCPServer"]:
|
|
207
|
+
return dict(_SERVERS)
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
def shutdown() -> None:
|
|
211
|
+
for srv in _SERVERS.values():
|
|
212
|
+
srv.stop()
|
|
213
|
+
_SERVERS.clear()
|
|
@@ -494,10 +494,13 @@ class DrydockApp(App):
|
|
|
494
494
|
" /graphrag build <path> · /graphrag status · /graphrag clear\n"
|
|
495
495
|
" /skills list your reusable /<name> skills\n"
|
|
496
496
|
" /loop /loop <count> <prompt> — repeat a prompt (Esc stops)\n"
|
|
497
|
+
" /mcp list connected MCP servers and their tools\n"
|
|
497
498
|
" /clear reset the conversation\n"
|
|
498
499
|
" /quit exit\n"
|
|
499
500
|
"Type a task and press Enter. ↑/↓ recall history · Esc stops · Ctrl+O expands tools."
|
|
500
501
|
)
|
|
502
|
+
elif cmd == "/mcp":
|
|
503
|
+
self._cmd_mcp()
|
|
501
504
|
elif cmd == "/loop":
|
|
502
505
|
self._cmd_loop(arg)
|
|
503
506
|
elif cmd == "/skills":
|
|
@@ -507,6 +510,27 @@ class DrydockApp(App):
|
|
|
507
510
|
else:
|
|
508
511
|
self._mount(ErrorMessage(f"unknown command: {cmd} (try /help)"))
|
|
509
512
|
|
|
513
|
+
def _cmd_mcp(self) -> None:
|
|
514
|
+
"""List connected MCP servers and the tools they expose."""
|
|
515
|
+
from drydock import mcp
|
|
516
|
+
|
|
517
|
+
servers = mcp.connected()
|
|
518
|
+
lines: list[str] = []
|
|
519
|
+
if not servers:
|
|
520
|
+
lines.append(
|
|
521
|
+
"No MCP servers connected. Configure them in ~/.drydock/mcp.json "
|
|
522
|
+
"(or <project>/.drydock/mcp.json) under \"mcpServers\", then restart."
|
|
523
|
+
)
|
|
524
|
+
else:
|
|
525
|
+
lines.append(f"MCP servers ({len(servers)} connected):")
|
|
526
|
+
for name, srv in servers.items():
|
|
527
|
+
tools = ", ".join(t["name"] for t in srv.tools) or "(no tools)"
|
|
528
|
+
lines.append(f" • {name}: {tools}")
|
|
529
|
+
lines.append("Call them as mcp__<server>__<tool> (the model does this automatically).")
|
|
530
|
+
for msg in self.config.get("mcp_log") or []:
|
|
531
|
+
lines.append(f" · {msg}")
|
|
532
|
+
self._info("\n".join(lines))
|
|
533
|
+
|
|
510
534
|
def _cmd_loop(self, arg: str) -> None:
|
|
511
535
|
"""/loop <count> <prompt> — run <prompt> up to <count> times (1–50),
|
|
512
536
|
re-submitting after each turn finishes. Esc (or /stop) ends the loop."""
|
|
@@ -153,7 +153,7 @@ class PromptHistory:
|
|
|
153
153
|
# completes the prefix.
|
|
154
154
|
SLASH_COMMANDS = [
|
|
155
155
|
"/help", "/model", "/cwd", "/undo", "/back", "/stop", "/status",
|
|
156
|
-
"/compact", "/graphrag", "/skills", "/loop", "/clear", "/quit",
|
|
156
|
+
"/compact", "/graphrag", "/skills", "/loop", "/mcp", "/clear", "/quit",
|
|
157
157
|
]
|
|
158
158
|
|
|
159
159
|
|
|
@@ -14,6 +14,7 @@ drydock/gittools.py
|
|
|
14
14
|
drydock/graphrag.py
|
|
15
15
|
drydock/guards.py
|
|
16
16
|
drydock/loop_detect.py
|
|
17
|
+
drydock/mcp.py
|
|
17
18
|
drydock/providers.py
|
|
18
19
|
drydock/skills.py
|
|
19
20
|
drydock/tool_registry.py
|
|
@@ -53,6 +54,7 @@ tests/test_guards_and_tools.py
|
|
|
53
54
|
tests/test_hallucinated_tools.py
|
|
54
55
|
tests/test_leaked_tool_call.py
|
|
55
56
|
tests/test_loop_detect.py
|
|
57
|
+
tests/test_mcp.py
|
|
56
58
|
tests/test_oneshot_unreachable.py
|
|
57
59
|
tests/test_plan_autocontinue.py
|
|
58
60
|
tests/test_providers_unreachable.py
|
|
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
|
|
|
7
7
|
# PyPI distribution name is drydock-cli (the established install name, continued
|
|
8
8
|
# from the retired v2 fork); the import package + CLI command stay `drydock`.
|
|
9
9
|
name = "drydock-cli"
|
|
10
|
-
version = "3.0.
|
|
10
|
+
version = "3.0.55"
|
|
11
11
|
description = "Drydock — a local, provider-agnostic terminal coding agent for local LLMs"
|
|
12
12
|
readme = "README.md"
|
|
13
13
|
requires-python = ">=3.11"
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"""MCP client: connect to a stdio MCP server, list + call its tools. Uses a real
|
|
2
|
+
(mock) server subprocess so the JSON-RPC handshake is exercised end to end."""
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import sys
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
from drydock import mcp
|
|
10
|
+
|
|
11
|
+
_SERVER = str(Path(__file__).parent / "fixtures" / "mock_mcp_server.py")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _write_cfg(cwd: Path):
|
|
15
|
+
d = cwd / ".drydock"
|
|
16
|
+
d.mkdir(parents=True, exist_ok=True)
|
|
17
|
+
(d / "mcp.json").write_text(json.dumps({
|
|
18
|
+
"mcpServers": {"mock": {"command": sys.executable, "args": [_SERVER]}}
|
|
19
|
+
}))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def teardown_function(_):
|
|
23
|
+
mcp.shutdown()
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def test_connect_lists_tools(tmp_path):
|
|
27
|
+
_write_cfg(tmp_path)
|
|
28
|
+
schemas = mcp.connect_all(str(tmp_path))
|
|
29
|
+
names = [s["name"] for s in schemas]
|
|
30
|
+
assert "mcp__mock__echo" in names
|
|
31
|
+
assert mcp.connected()["mock"].tools[0]["name"] == "echo"
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def test_call_tool_round_trips(tmp_path):
|
|
35
|
+
_write_cfg(tmp_path)
|
|
36
|
+
mcp.connect_all(str(tmp_path))
|
|
37
|
+
out = mcp.call("mock", "echo", {"text": "hello mcp"})
|
|
38
|
+
assert out == "echo: hello mcp"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def test_call_unknown_server_is_graceful(tmp_path):
|
|
42
|
+
assert "not connected" in mcp.call("nope", "echo", {"text": "x"})
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def test_missing_config_is_noop(tmp_path):
|
|
46
|
+
assert mcp.connect_all(str(tmp_path)) == []
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def test_bad_server_is_skipped(tmp_path):
|
|
50
|
+
d = tmp_path / ".drydock"; d.mkdir(parents=True)
|
|
51
|
+
(d / "mcp.json").write_text(json.dumps({
|
|
52
|
+
"mcpServers": {"broken": {"command": "this_command_does_not_exist_xyz", "args": []}}
|
|
53
|
+
}))
|
|
54
|
+
logs = []
|
|
55
|
+
schemas = mcp.connect_all(str(tmp_path), log=logs.append)
|
|
56
|
+
assert schemas == []
|
|
57
|
+
assert any("failed to start" in m for m in logs)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|