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 --- internal/appconfig/config.go | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'internal/appconfig/config.go') diff --git a/internal/appconfig/config.go b/internal/appconfig/config.go index 8ae9597..490ed4e 100644 --- a/internal/appconfig/config.go +++ b/internal/appconfig/config.go @@ -126,7 +126,9 @@ type App struct { TmuxEditAgents []TmuxEditAgentCfg `json:"-" toml:"-"` // MCP: Model Context Protocol server settings - MCPPromptsDir string `json:"-" toml:"-"` // Directory for prompt storage + MCPPromptsDir string `json:"-" toml:"-"` // Directory for prompt storage + MCPSlashCommandSync bool `json:"-" toml:"-"` // Enable slash command sync + MCPSlashCommandDir string `json:"-" toml:"-"` // Directory for slash command files } // CustomAction describes a user-defined code action. @@ -383,7 +385,9 @@ type sectionTmuxEditAgent struct { // sectionMCP configures the MCP server settings. type sectionMCP struct { - PromptsDir string `toml:"prompts_dir"` + PromptsDir string `toml:"prompts_dir"` + SlashCommandSync bool `toml:"slashcommand_sync"` + SlashCommandDir string `toml:"slashcommand_dir"` } type sectionOpenAI struct { @@ -719,6 +723,12 @@ func (fc *fileConfig) toApp() App { if strings.TrimSpace(fc.MCP.PromptsDir) != "" { out.MCPPromptsDir = strings.TrimSpace(fc.MCP.PromptsDir) } + if fc.MCP.SlashCommandSync { + out.MCPSlashCommandSync = fc.MCP.SlashCommandSync + } + if strings.TrimSpace(fc.MCP.SlashCommandDir) != "" { + out.MCPSlashCommandDir = strings.TrimSpace(fc.MCP.SlashCommandDir) + } return out } @@ -1058,6 +1068,16 @@ func (a *App) mergeBasics(other *App) { if other.IgnoreLSPNotify != nil { a.IgnoreLSPNotify = other.IgnoreLSPNotify } + // MCP settings + if s := strings.TrimSpace(other.MCPPromptsDir); s != "" { + a.MCPPromptsDir = s + } + if other.MCPSlashCommandSync { + a.MCPSlashCommandSync = other.MCPSlashCommandSync + } + if s := strings.TrimSpace(other.MCPSlashCommandDir); s != "" { + a.MCPSlashCommandDir = s + } } // mergeSurfaceModels copies per-surface model and temperature overrides. @@ -1599,6 +1619,15 @@ func loadFromEnv(logger *log.Logger) *App { out.MCPPromptsDir = s any = true } + if s := getenv("HEXAI_MCP_SLASHCOMMAND_SYNC"); s != "" { + b := s == "true" || s == "1" + out.MCPSlashCommandSync = b + any = true + } + if s := getenv("HEXAI_MCP_SLASHCOMMAND_DIR"); s != "" { + out.MCPSlashCommandDir = s + any = true + } if !any { return nil -- cgit v1.2.3