Skip to main content

Crate rtk_mcp_agy

Crate rtk_mcp_agy 

Source
Expand description

Shared logic for the rtk-mcp-agy plugin.

Everything here is pure: JSON-RPC dispatch, response shaping, and the PreInvocation payload. The two binaries in src/bin/ only move bytes and spawn processes.

The split exists because the interesting behaviour is otherwise unreachable by a test. handle_line takes the rewriter and the executor as closures, so the tools/call path — which in production shells out to rtk and then to a shell — can be exercised on a machine that has neither installed, and its failure modes can be forced rather than waited for.

The seam earned itself immediately: it is what made the hardcoded pwsh visible as a portability bug (see resolve_shell) rather than something only a Linux user would ever discover.

Macros§

plugin_name 🔒
The plugin ID in plugin.json, and the plugin’s directory name in Antigravity.
server_name 🔒
The server key registered in mcp_config.json.

Structs§

PreInvocationOutput
The payload the PreInvocation hook writes to stdout.

Enums§

Execution
The outcome of trying to run a command.

Constants§

AGY_SERVER_NAME
The namespaced server name Antigravity assigns to this plugin’s MCP server.
DEFAULT_RTK_BIN
The rtk executable, when RTK_BIN says nothing.
DEFAULT_UNIX_SHELL
The shell used to run commands everywhere else.
DEFAULT_WINDOWS_SHELL
The shell used to run commands on Windows.
METHOD_NOT_FOUND
JSON-RPC’s “method not found”.
PLUGIN_NAME
The plugin directory / ID in Antigravity.
PROTOCOL_VERSION
The MCP protocol revision spoken by this server.
SERVER_NAME
The server name an MCP client sees, and the key mcp_config.json registers.
TOOL_CHECK
Show how rtk would rewrite a shell command without running it.
TOOL_DISCOVER
Analyze past session history for missed token savings.
TOOL_GAIN
Report rtk token savings.
TOOL_NAME
Run an rtk-optimized command.

Functions§

build_check_command
Build the command line for rtk hook check.
build_discover_command
Build the command line for rtk discover.
build_gain_command
Build the command line for rtk gain.
call_arguments
Pull CommandLine and Cwd out of a tools/call request.
dispatch_request
Dispatch a parsed JSON-RPC request to the appropriate method handler.
envelope 🔒
Wrap a result body in its JSON-RPC envelope.
extract_cwd
Extract the Cwd argument or fall back to ".".
format_execution
Render an execution as the tools/call result body.
handle_line
Handle one line of input, returning the response to write — or None when the server must stay silent.
handle_request
Handle a parsed JSON-RPC request using default fallback closures.
method_not_found
The body used for an unrecognised method.
non_blank 🔒
Trim a value, discarding it if nothing is left.
parse_rewrite
Interpret the stdout of rtk rewrite.
preinvocation_payload
Build the injected instruction that steers the model onto the MCP tool.
resolve_rtk_bin
Decide which rtk executable to invoke.
resolve_shell
Decide which shell runs the rewritten command.
server_info
The initialize result.
shell_quote
Quote a string safely for inclusion in a shell command line.
tools_list
The tools/list result advertising all 4 tools.
validate_format 🔒
version
The crate version, and the single source for every place one is reported.