M6: native MCP client, lazy index, mcp-serve (closes #42-#51)
This commit is contained in:
1 parent
6d35274f39
commit
99dc90fd3b
18 files changed
+1723
-22
No files matched your search
@@ -66,3 +66,41 @@ Existing Claude Code (`~/.claude/.credentials.json`) and Codex CLI (`~/.codex/au
|
||||
Credentials are stored in `~/.hx/auth.json` (mode 0600) and refreshed automatically.
|
||||
|
||||
On a headless box, open the printed URL elsewhere and paste the final redirect URL back into the terminal.
|
||||
|
||||
## MCP
|
||||
|
||||
Servers come from `~/.hx/mcp.json` and `.hx/mcp.json` (project entries replace global ones with the same
|
||||
name), in the Claude Code `mcpServers` shape. `${VAR}` and `${VAR:-default}` are expanded.
|
||||
|
||||
```json
|
||||
{"mcpServers": {
|
||||
"fs": {"command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "${HOME}/src"]},
|
||||
"web": {"type": "http", "url": "https://example.com/mcp", "headers": {"Authorization": "Bearer ${TOKEN}"},
|
||||
"allow": ["search"], "eager": true, "timeoutSecs": 30}
|
||||
}}
|
||||
```
|
||||
|
||||
Transports: stdio and streamable HTTP (static headers; no OAuth). hx extras: `allow` (tool allowlist),
|
||||
`eager`, `timeoutSecs` (per call, default 60), `disabled`. Output is capped at 30k chars; a crashed stdio
|
||||
server is restarted on the next call (at most 3 times).
|
||||
|
||||
Lazy by default: the system prompt carries one line per tool (`server.tool: description`); the model gets the
|
||||
schema with `mcp_describe` and calls through `mcp_call` (arguments are checked against the cached schema).
|
||||
Servers whose full schemas cost at most ~400 tokens are registered as native tools instead (`server__tool`);
|
||||
`eager: true|false` overrides. Resources are listed in the prompt and read with `mcp_read`; prompts become
|
||||
slash commands (`/server:prompt args`). `/mcp` in the TUI and `hx mcp` show tools and token costs.
|
||||
|
||||
Measured (`hx mcp`, bytes/4):
|
||||
|
||||
| server | tools | lazy index | eager schemas |
|
||||
|-------------|------:|-----------:|--------------:|
|
||||
| context7 | 2 | ~63 tok | ~1147 tok |
|
||||
| everything | 13 | ~319 tok | ~1235 tok |
|
||||
| filesystem | 14 | ~453 tok | ~1996 tok |
|
||||
| playwright | 25 | ~537 tok | ~4397 tok |
|
||||
|
||||
Lazy costs one extra round trip (`mcp_describe`) per tool on first use in a session. Since tool count is a
|
||||
poor proxy (context7: 2 tools, 1.1k tokens), the eager rule is schema size, not count.
|
||||
|
||||
`hx mcp-serve` runs hx as a stdio MCP server exposing the `lsp` tool (diagnostics, definition, references,
|
||||
hover, symbols) to other clients.
|
||||
Reference in new issue
Block a user