From ed2526ce413b890ddf9958fcd4045db2e5505a0f Mon Sep 17 00:00:00 2001 From: dave Date: Mon, 13 Apr 2026 13:50:37 +0000 Subject: [PATCH] feat: add get_version MCP tool returning version and build hash Agents can now call get_version to see what server version and commit they're running against. Co-Authored-By: Claude Opus 4.6 (1M context) --- server/src/http/mcp/diagnostics.rs | 11 +++++++++++ server/src/http/mcp/mod.rs | 12 +++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/server/src/http/mcp/diagnostics.rs b/server/src/http/mcp/diagnostics.rs index 6c545056..1e7def20 100644 --- a/server/src/http/mcp/diagnostics.rs +++ b/server/src/http/mcp/diagnostics.rs @@ -319,6 +319,17 @@ pub(super) fn tool_dump_crdt(args: &Value) -> Result { .map_err(|e| format!("Serialization error: {e}")) } +/// MCP tool: return the server version and build hash. +pub(super) fn tool_get_version() -> Result { + let build_hash = std::fs::read_to_string(".huskies/build_hash") + .unwrap_or_else(|_| "unknown".to_string()); + serde_json::to_string_pretty(&json!({ + "version": env!("CARGO_PKG_VERSION"), + "build_hash": build_hash.trim(), + })) + .map_err(|e| format!("Serialization error: {e}")) +} + /// MCP tool: count lines in a specific file relative to the project root. pub(super) fn tool_loc_file(args: &Value, ctx: &AppContext) -> Result { let file_path = args diff --git a/server/src/http/mcp/mod.rs b/server/src/http/mcp/mod.rs index 8c161744..59b65a47 100644 --- a/server/src/http/mcp/mod.rs +++ b/server/src/http/mcp/mod.rs @@ -837,6 +837,14 @@ fn handle_tools_list(id: Option) -> JsonRpcResponse { } } }, + { + "name": "get_version", + "description": "Return the server version and build hash.", + "inputSchema": { + "type": "object", + "properties": {} + } + }, { "name": "rebuild_and_restart", "description": "Rebuild the server binary from source and re-exec with the new binary. Gracefully stops all running agents before restart. If the build fails, the server stays up and returns the build error.", @@ -1266,6 +1274,7 @@ async fn handle_tools_call( "get_pipeline_status" => story_tools::tool_get_pipeline_status(ctx), // Diagnostics "get_server_logs" => diagnostics::tool_get_server_logs(&args), + "get_version" => diagnostics::tool_get_version(), // Server lifecycle "rebuild_and_restart" => diagnostics::tool_rebuild_and_restart(ctx).await, // Permission bridge (Claude Code → frontend dialog) @@ -1423,7 +1432,8 @@ mod tests { assert!(names.contains(&"status")); assert!(names.contains(&"loc_file")); assert!(names.contains(&"dump_crdt")); - assert_eq!(tools.len(), 62); + assert!(names.contains(&"get_version")); + assert_eq!(tools.len(), 63); } #[test]