Skip to content

refactor: consolidate MCP install config snippet generation #1379

@simplesagar

Description

@simplesagar

Summary

Consolidate the MCP install config/snippet generation logic into a single shared function to eliminate duplication and ensure consistency.

Current State

The snippet generation logic is duplicated in 2 places:

Location What it generates
config_snippet.json.tmpl JSON config for Claude Desktop/Cursor (via Go template)
impl.go:buildInstallConfigs() Export endpoint configs (via Go structs)

Both produce identical output:

{
  "command": "npx",
  "args": ["mcp-remote@0.1.25", "<url>", "--header", "Header:${ENV_VAR}"],
  "env": { "ENV_VAR": "<your-value-here>" }
}

This means:

  • mcp-remote@0.1.25 version is hardcoded in multiple places
  • Command format can drift between surfaces
  • Updates require changes in multiple files

Proposed Solution

Create a single shared buildStdioConfig() function and eliminate the template.

Files to Modify

File Change
server/internal/mcpmetadata/impl.go Add buildStdioConfig(), update buildInstallConfigs() and ServeInstallPage()
server/internal/mcpmetadata/config_snippet.json.tmpl Delete

Implementation Steps

  1. Create shared buildStdioConfig function - Returns *types.McpExportStdioConfig with command, args, and env
  2. Update buildInstallConfigs - Use buildStdioConfig() for ClaudeDesktop and Cursor configs
  3. Update ServeInstallPage - Replace template execution with JSON serialization of buildStdioConfig() result
  4. Remove template - Delete config_snippet.json.tmpl and its embed directive

Benefits

  • Single source of truth for versions and command formats
  • Consistent output across install page, export endpoint, and UI
  • Easier maintenance when mcp-remote version updates
  • Less code overall (remove template + template parsing)

Related

Acceptance Criteria

  • Create buildStdioConfig() function that builds stdio config for MCP clients
  • Update buildInstallConfigs() to use buildStdioConfig()
  • Update ServeInstallPage() to use buildStdioConfig() + JSON marshal instead of template
  • Delete config_snippet.json.tmpl and remove embed directive
  • Verify install page JSON snippet renders correctly
  • Verify export endpoint configs match install page format
  • Add/update tests for the shared builder
  • Run linter: mise lint:server

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions