Repository navigation
feat: add --dry-run to print a tool call's JSON-RPC request - #113
Merged
Merged
Conversation
Signed-off-by: Agent G <326687097+readyagentsdev@users.noreply.github.com>
Owner
|
Thanks a lot for this, and sorry it sat here for so long. Really clean change: it exits before touching the db or spawning anything, rejects the non tool call cases, and the tests cover exactly what matters. This is going to help a lot when debugging servers. Merging. Hope to see more PRs from you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1
What
This adds
--dry-runfor tool calls.mcp <server> <tool> [json] --dry-runprints the JSON-RPCtools/callrequest as pretty JSON and exits 0. It does not connect to the server.Why and how
The approach follows your review of the earlier attempt (#44):
main.rsright after the config loads, before the db pool, the audit logger, and any connection. It works when the backend is unreachable, and it never spawns a stdio server.--dry-runwith--list,--info,--health, a missing tool name, or a built-in subcommand (search,logs,serve, ...) now fails with--dry-run only applies to tool calls: mcp <server> <tool> [json] --dry-run. Before, the flag was silently ignored in those cases.ToolCallParams/JsonRpcRequesttypes thatMcpClient::call_tooluses.Limitations:
idis always1. In a live session the client assigns ids after the handshake.MCP_PROXY_URLis set, the proxy route would send the namespaced{server}__{tool}name instead.I also added one line to
mcp --helpand one row to the README commands table.Tests
src/cli/server.rs:test_dry_run_request_is_tools_call: checks the full request for a tool with arguments.test_dry_run_request_keeps_empty_arguments: checks the request with empty arguments.test_dry_run_target_accepts_tool_call: accepts<server> <tool>with or without JSON.test_dry_run_target_rejects_non_tool_calls: rejects--list,--info,--health, a server with no tool, top-level--list, andsearch/logs/serve.cargo fmt --checkpasses,cargo clippy -- -D warningspasses with no warnings, andcargo testgives 877 passed, 0 failed.MCP_CONFIG_DIR. The config has a stdio server whose command issh -c "touch /tmp/spawned; sleep 5", and an HTTP server athttp://127.0.0.1:9/mcp, where nothing listens:/tmp/spawnedis not created. The same call without--dry-rundoes create it.fake --list --dry-run,down --health --dry-run, andsearch foo --dry-runexit 1 with the message above.server "nope" not found in config.tool arguments are not valid JSON: ....The commit is signed off (DCO).