From cfd02d2874992f7e293d5098bd328a495825a8d4 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 12 Feb 2026 09:32:26 +0200 Subject: feat: add automatic MCP prompt to slash command syncing Adds optional syncing of MCP prompts to Markdown slash command files for AI agents that don't yet support MCP prompts (e.g., Cursor IDE). Features: - Syncs prompts on create/update/delete operations - Configurable via TOML config, environment vars, or CLI flags - Backfill support with --sync-all flag - Thread-safe atomic file writes - Non-fatal sync failures (logged but don't break operations) - Comprehensive test coverage (81.1% total) Configuration: - Config: [mcp] slashcommand_sync = true, slashcommand_dir = "~/.cursor/commands" - Env: HEXAI_MCP_SLASHCOMMAND_SYNC, HEXAI_MCP_SLASHCOMMAND_DIR - CLI: --slashcommand-sync, --slashcommand-dir, --sync-all Fixes config merging bug where project config would reset global MCP settings. Co-Authored-By: Claude Sonnet 4.5 --- cmd/hexai-mcp-server/main.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'cmd/hexai-mcp-server') diff --git a/cmd/hexai-mcp-server/main.go b/cmd/hexai-mcp-server/main.go index 65335f7..acdb1d0 100644 --- a/cmd/hexai-mcp-server/main.go +++ b/cmd/hexai-mcp-server/main.go @@ -17,6 +17,9 @@ func main() { logPath := flag.String("log", defaultLog, "path to log file (optional)") configPath := flag.String("config", "", "path to config file (optional)") promptsDir := flag.String("prompts-dir", "", "path to prompts directory (optional)") + slashCommandSync := flag.Bool("slashcommand-sync", false, "enable slash command sync") + slashCommandDir := flag.String("slashcommand-dir", "", "directory for slash command files") + syncAll := flag.Bool("sync-all", false, "backfill all existing prompts and exit") showVersion := flag.Bool("version", false, "print version and exit") flag.Parse() @@ -29,6 +32,20 @@ func main() { if *promptsDir != "" { os.Setenv("HEXAI_MCP_PROMPTS_DIR", *promptsDir) } + if *slashCommandSync { + os.Setenv("HEXAI_MCP_SLASHCOMMAND_SYNC", "true") + } + if *slashCommandDir != "" { + os.Setenv("HEXAI_MCP_SLASHCOMMAND_DIR", *slashCommandDir) + } + + // Handle backfill operation + if *syncAll { + if err := hexaimcp.RunBackfill(*logPath, *configPath); err != nil { + log.Fatalf("backfill error: %v", err) + } + return + } if err := hexaimcp.Run(*logPath, *configPath, os.Stdin, os.Stdout, os.Stderr); err != nil { log.Fatalf("server error: %v", err) -- cgit v1.2.3