Skip to content

Commit 683c476

Browse files
lklimekclaude
andcommitted
refactor: consolidate MCP features and embed stdio server in det-cli
Simplify from 3 features (mcp-stdio, mcp-http, cli) to 2: - `mcp`: HTTP server embedded in GUI app - `cli`: det-cli binary with in-process MCP and `serve` subcommand Remove standalone `dash-evo-tool-mcp` binary — `det-cli serve` replaces it as the MCP stdio server for Claude Desktop and AI agents. Update docs (MCP.md, CLI.md, CONTRIBUTING.md) to reflect new layout. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 253cbda commit 683c476

12 files changed

Lines changed: 142 additions & 192 deletions

File tree

CONTRIBUTING.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,21 @@ Run the application:
6060
cargo run
6161
```
6262

63+
## Feature flags
64+
65+
| Feature | Description |
66+
|---|---|
67+
| `mcp` | MCP HTTP server embedded in the GUI app (see [docs/MCP.md](docs/MCP.md)) |
68+
| `cli` | `det-cli` command-line client with in-process MCP service (see [docs/CLI.md](docs/CLI.md)) |
69+
| `testing` | Test-only utilities |
70+
71+
Build with a specific feature:
72+
73+
```shell
74+
cargo build --features mcp # GUI app + HTTP MCP server
75+
cargo build --features cli # det-cli binary
76+
```
77+
6378
## Code quality
6479

6580
Before submitting changes, run the formatter and linter:

Cargo.lock

Lines changed: 4 additions & 83 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,13 @@ raw-cpuid = "11.5.0"
9494

9595
[features]
9696
testing = []
97-
mcp-stdio = ["dep:rmcp", "rmcp/server", "rmcp/macros", "rmcp/transport-io"]
98-
mcp-http = ["dep:rmcp", "rmcp/server", "rmcp/macros", "rmcp/transport-streamable-http-server", "dep:axum", "dep:subtle"]
99-
cli = ["dep:rmcp", "rmcp/client", "rmcp/transport-child-process", "rmcp/transport-streamable-http-client-reqwest", "dep:clap", "dep:clap_complete"]
97+
mcp = ["dep:rmcp", "rmcp/server", "rmcp/macros", "rmcp/transport-streamable-http-server", "dep:axum", "dep:subtle"]
98+
cli = ["dep:rmcp", "rmcp/server", "rmcp/macros", "rmcp/client", "rmcp/transport-io", "rmcp/transport-streamable-http-client-reqwest", "dep:clap", "dep:clap_complete"]
10099

101100
[dev-dependencies]
102101
egui_kittest = { version = "0.33.3", features = ["eframe"] }
103102
tokio-shared-rt = "=0.1.0"
104103

105-
[[bin]]
106-
name = "dash-evo-tool-mcp"
107-
path = "src/bin/mcp_server.rs"
108-
required-features = ["mcp-stdio"]
109-
110104
[[bin]]
111105
name = "det-cli"
112106
path = "src/bin/det_cli.rs"
@@ -123,7 +117,7 @@ debug = "line-tables-only"
123117

124118
[lints.rust.unexpected_cfgs]
125119
level = "warn"
126-
check-cfg = ["cfg(tokio_unstable)", "cfg(feature, values(\"testing\", \"mcp-stdio\", \"mcp-http\", \"cli\"))"]
120+
check-cfg = ["cfg(tokio_unstable)", "cfg(feature, values(\"testing\", \"mcp\", \"cli\"))"]
127121

128122
[lints.clippy]
129123
uninlined_format_args = "allow"

docs/CLI.md

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
# det-cli
22

3-
`det-cli` is the command-line client for Dash Evo Tool's MCP server. Use it to call wallet and core operations from scripts and terminals without opening the GUI.
3+
`det-cli` is the command-line interface for Dash Evo Tool. It provides both a CLI client for calling MCP tools and a built-in MCP stdio server.
44

55
## Build
66

77
```bash
88
cargo build --features cli
99
```
1010

11-
The binary is `det-cli` in the Cargo output directory.
12-
1311
## Configuration
1412

1513
`det-cli` reads the app's `.env` file automatically on startup — the same file used by the GUI. No separate configuration is needed.
@@ -22,6 +20,14 @@ Config precedence (highest to lowest):
2220

2321
## Connection modes
2422

23+
### In-process (default)
24+
25+
When no `MCP_API_KEY` is configured, `det-cli` runs the MCP service in-process. No running GUI app or separate server required.
26+
27+
```bash
28+
det-cli tools
29+
```
30+
2531
### HTTP
2632

2733
Used automatically when `MCP_API_KEY` is available (from `.env` or shell). Connects to the running GUI app's MCP HTTP server.
@@ -36,21 +42,11 @@ The server address defaults to `http://{MCP_LISTEN}/mcp`, or `http://127.0.0.1:9
3642
det-cli --addr http://127.0.0.1:9000/mcp tools
3743
```
3844

39-
### Stdio (default when no API key)
40-
41-
When no `MCP_API_KEY` is configured, `det-cli` spawns `dash-evo-tool-mcp` as a child process and communicates via stdin/stdout. No running GUI app required.
42-
43-
`dash-evo-tool-mcp` must be built (`cargo build --features mcp-stdio`) and on `PATH`.
44-
45-
Force stdio mode explicitly with `--standalone`:
46-
47-
```bash
48-
det-cli --standalone tools
49-
```
45+
Force in-process mode with `--standalone` even when an API key is present.
5046

5147
## Usage
5248

53-
Running `det-cli` with no subcommand lists available tools (same as `det-cli tools`).
49+
Running `det-cli` with no subcommand lists available tools.
5450

5551
### `tools` — list available tools
5652

@@ -69,21 +65,22 @@ det-cli call <tool-name> [key=value ...]
6965
Parameter values are parsed as JSON first, falling back to plain strings.
7066

7167
```bash
72-
# No parameters
7368
det-cli call list_wallets
74-
75-
# String parameter
7669
det-cli call generate_receive_address wallet_id=my-wallet
77-
78-
# JSON parameter (boolean)
7970
det-cli call some_tool enabled=true
8071
```
8172

8273
Exit code is non-zero when the tool returns an error.
8374

84-
### `completion <shell>`generate shell completion
75+
### `serve`run as MCP stdio server
8576

86-
Generates a completion script for the given shell. Supported: `bash`, `zsh`, `fish`, `powershell`.
77+
```bash
78+
det-cli serve
79+
```
80+
81+
Runs an MCP server over stdin/stdout for use with Claude Desktop, AI agents, or other MCP clients. See [MCP.md](MCP.md) for Claude Desktop configuration.
82+
83+
### `completion <shell>` — generate shell completion
8784

8885
```bash
8986
det-cli completion bash
@@ -94,21 +91,20 @@ det-cli completion zsh
9491

9592
The tool list is cached automatically when you run `det-cli` or `det-cli tools`. The cache includes the server version and is invalidated when the version changes.
9693

97-
`det-cli --help` appends the cached tool list to the standard help output. If the cache is empty or stale, run `det-cli` once to populate it.
94+
`det-cli --help` appends the cached tool list to the standard help output.
9895

9996
## Shell completion setup
10097

10198
### Bash
10299

103100
```bash
104-
# Add completion to your shell session
105101
source <(det-cli completion bash)
106102

107103
# Or add permanently to ~/.bashrc
108104
echo 'source <(det-cli completion bash)' >> ~/.bashrc
109105
```
110106

111-
The bash completion script includes a dynamic completer for tool names in `det-cli call`. It reads from the local cache. Requires `jq` for dynamic tool name completion.
107+
The bash completion includes dynamic tool name completion for `det-cli call`. Requires `jq`.
112108

113109
### Zsh
114110

@@ -119,16 +115,18 @@ det-cli completion zsh > "${fpath[1]}/_det-cli"
119115
## Examples
120116

121117
```bash
122-
# List wallets loaded in the app (reads MCP_API_KEY from .env)
118+
# List wallets (in-process, no server needed)
123119
det-cli call list_wallets
124120

125-
# Generate a receive address (use alias or hex seed hash)
121+
# Generate a receive address
126122
det-cli call generate_receive_address wallet_id=savings
127123

128124
# List wallets in Dash Core
129125
det-cli call list_core_wallets
130126

131-
# Stdio mode (no GUI required)
132-
det-cli --standalone call list_wallets
133-
MCP_NETWORK=testnet det-cli --standalone call list_wallets
127+
# Use testnet
128+
MCP_NETWORK=testnet det-cli call list_wallets
129+
130+
# Run as stdio MCP server for Claude Desktop
131+
det-cli serve
134132
```

docs/MCP.md

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# MCP Server
22

3-
Dash Evo Tool exposes wallet and core operations via the [Model Context Protocol](https://modelcontextprotocol.io/). Two transport modes are available, each behind its own Cargo feature flag.
3+
Dash Evo Tool exposes wallet and core operations via the [Model Context Protocol](https://modelcontextprotocol.io/). Two modes are available:
44

5-
## Transport modes
6-
7-
### HTTP (`mcp-http`)
5+
## HTTP mode (`mcp` feature)
86

97
Embedded in the GUI app. Shares the running app's `AppContext` and follows network switches in real time.
108

@@ -14,22 +12,21 @@ Routes:
1412
- `GET /health` — unauthenticated liveness check, returns `OK`
1513
- `POST /mcp` — MCP protocol endpoint, requires `Authorization: Bearer <key>`
1614

17-
### Stdio (`mcp-stdio`)
15+
Build: `cargo build --features mcp`
1816

19-
Standalone binary `dash-evo-tool-mcp`. No GUI. Communicates via stdin/stdout using the MCP protocol. `AppContext` is initialized lazily on the first tool call, reading the same `.env` and database as the GUI app.
17+
## Stdio mode (via `det-cli serve`)
2018

21-
## Building
19+
The `det-cli` binary includes a built-in MCP stdio server. No separate binary needed.
2220

2321
```bash
24-
# HTTP transport (GUI app)
25-
cargo build --features mcp-http
22+
det-cli serve
23+
```
2624

27-
# Stdio transport (standalone binary)
28-
cargo build --features mcp-stdio
25+
Communicates via stdin/stdout using the MCP protocol. `AppContext` is initialized lazily on the first tool call, reading the same `.env` and database as the GUI app. Configure the network via `MCP_NETWORK` env var.
2926

30-
# CLI client (see docs/CLI.md)
31-
cargo build --features cli
32-
```
27+
Build: `cargo build --features cli`
28+
29+
See [CLI.md](CLI.md) for full `det-cli` documentation.
3330

3431
## Environment variables
3532

@@ -59,7 +56,8 @@ Add to `claude_desktop_config.json`:
5956
{
6057
"mcpServers": {
6158
"dash-evo-tool": {
62-
"command": "dash-evo-tool-mcp",
59+
"command": "det-cli",
60+
"args": ["serve"],
6361
"env": {
6462
"MCP_NETWORK": "mainnet"
6563
}
@@ -68,7 +66,7 @@ Add to `claude_desktop_config.json`:
6866
}
6967
```
7068

71-
`dash-evo-tool-mcp` must be on `PATH` (or use the full path to the binary).
69+
`det-cli` must be on `PATH` (or use the full path to the binary).
7270

7371
### HTTP with curl
7472

0 commit comments

Comments
 (0)