mcpconv

package
v0.411.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AntigravityProjectMCPConfigPath is the project-local output used by --all mode.
	AntigravityProjectMCPConfigPath = ".gemini/antigravity/mcp_config.json"
	// ZedProjectSettingsPath is the project-local output used by --all mode.
	ZedProjectSettingsPath = ".zed/settings.json"

	FormatMesnada     = "mesnada"
	FormatVSCode      = "vscode"
	FormatClaude      = "claude"
	FormatGemini      = "gemini"
	FormatOpenCode    = "opencode"
	FormatVibe        = "vibe"
	FormatZed         = "zed"
	FormatAntigravity = "antigravity"

	Version = "0.1.0"
)

Variables

View Source
var AllFormats = []AllFormatEntry{
	{Format: FormatMesnada, Path: ".github/mcp-config.json"},
	{Format: FormatVSCode, Path: ".vscode/mcp.json"},
	{Format: FormatClaude, Path: ".mcp.json"},
	{Format: FormatGemini, Path: ".gemini/settings.json"},
	{Format: FormatOpenCode, Path: "opencode.json"},
	{Format: FormatVibe, Path: ".vibe/config.toml"},
	{Format: FormatZed, Path: ".zed/settings.json"},
	{Format: FormatAntigravity, Path: ".gemini/antigravity/mcp_config.json"},
}

AllFormats is the ordered list of output formats and project-relative paths for --all mode.

Functions

func ConvertFileFormat

func ConvertFileFormat(inputPath, outputPath, fromFormat, toFormat string) error

ConvertFileFormat converts a file between supported MCP formats.

func ConvertFileFormatForPath

func ConvertFileFormatForPath(inputPath, outputPath, workDir, fromFormat, toFormat string) error

ConvertFileFormatForPath resolves source path relative to workDir before conversion.

func RenderByFormat

func RenderByFormat(cfg CanonicalConfig, toFormat, workDir string) (any, error)

RenderByFormat renders canonical config to a supported output format payload. workDir is used for formats that resolve relative paths (claude, gemini). For the vibe/mistral format, a string is returned instead of a JSON-serialisable value.

func RenderMistralVibeTOML

func RenderMistralVibeTOML(cfg CanonicalConfig, model string) string

RenderMistralVibeTOML converts canonical config to Vibe config.toml content.

func WriteAllFormats

func WriteAllFormats(cfg CanonicalConfig, projectDir, workDir string) ([]string, error)

WriteAllFormats writes every supported MCP format into its project-conventional path under projectDir. Returns the list of paths written.

func WriteAllFormatsSkippingSource

func WriteAllFormatsSkippingSource(cfg CanonicalConfig, projectDir, workDir, sourcePath string) ([]string, error)

WriteAllFormatsSkippingSource writes every supported format like WriteAllFormats, but never overwrites sourcePath when it points to one of the target files.

func WriteJSONFile

func WriteJSONFile(tempDir, fileName string, payload any) (string, error)

WriteJSONFile marshals data as pretty JSON into a file under tempDir.

Types

type AllFormatEntry

type AllFormatEntry struct {
	Format string
	Path   string
}

AllFormatEntry describes a single output format and where it should be written in --all mode.

type AntigravityConfig

type AntigravityConfig struct {
	MCPServers map[string]AntigravityServer `json:"mcpServers"`
}

AntigravityConfig is the Antigravity mcp_config.json format.

func RenderAntigravity

func RenderAntigravity(cfg CanonicalConfig) AntigravityConfig

RenderAntigravity converts canonical config to Antigravity mcp_config.json format.

type AntigravityServer

type AntigravityServer struct {
	Type      string            `json:"type,omitempty"`
	Command   string            `json:"command,omitempty"`
	Args      []string          `json:"args,omitempty"`
	Env       map[string]string `json:"env,omitempty"`
	ServerURL string            `json:"serverUrl,omitempty"`
	URL       string            `json:"url,omitempty"`
	Headers   map[string]string `json:"headers,omitempty"`
	Enabled   *bool             `json:"enabled,omitempty"`
	Timeout   int               `json:"timeout,omitempty"`
}

AntigravityServer is an Antigravity MCP server entry.

type CanonicalConfig

type CanonicalConfig struct {
	MCPServers map[string]CanonicalServer `json:"mcpServers"`
}

CanonicalConfig is the normalized MCP model used across render targets.

func ParseCanonicalBytesWithFormat

func ParseCanonicalBytesWithFormat(data []byte, fromFormat string) (CanonicalConfig, error)

ParseCanonicalBytesWithFormat parses raw JSON bytes into canonical format.

func ParseCanonicalFile

func ParseCanonicalFile(sourcePath string) (CanonicalConfig, error)

ParseCanonicalFile parses a JSON MCP file into canonical format, auto-detecting supported inputs.

func ParseCanonicalFileWithFormat

func ParseCanonicalFileWithFormat(sourcePath, fromFormat string) (CanonicalConfig, error)

ParseCanonicalFileWithFormat parses a JSON MCP file into canonical format using explicit format when provided.

func ParseMesnadaFile

func ParseMesnadaFile(mcpConfigPath, workDir string) (CanonicalConfig, error)

ParseMesnadaFile parses Mesnada/Copilot MCP config into canonical model. When format is omitted, VS Code format can be auto-detected.

func ParseZedFile

func ParseZedFile(settingsPath, workDir string) (CanonicalConfig, error)

ParseZedFile parses Zed settings from a file path into canonical config.

func ParseZedSettings

func ParseZedSettings(data []byte) (CanonicalConfig, error)

ParseZedSettings parses Zed settings JSON and maps context_servers to canonical config.

type CanonicalServer

type CanonicalServer struct {
	Type      string            `json:"type,omitempty"`
	Command   string            `json:"command,omitempty"`
	Args      []string          `json:"args,omitempty"`
	Env       map[string]string `json:"env,omitempty"`
	Cwd       string            `json:"cwd,omitempty"`
	URL       string            `json:"url,omitempty"`
	ServerURL string            `json:"serverUrl,omitempty"`
	Headers   map[string]string `json:"headers,omitempty"`
	Enabled   *bool             `json:"enabled,omitempty"`
	Timeout   int               `json:"timeout,omitempty"`
	Tools     []string          `json:"tools,omitempty"`
}

CanonicalServer is the normalized server definition.

type ClaudeConfig

type ClaudeConfig struct {
	MCPServers map[string]ClaudeServer `json:"mcpServers"`
}

ClaudeConfig is the format accepted by claude --mcp-config.

func RenderClaude

func RenderClaude(cfg CanonicalConfig, workDir string) ClaudeConfig

RenderClaude converts canonical config to Claude format.

type ClaudeServer

type ClaudeServer struct {
	Command string            `json:"command,omitempty"`
	Args    []string          `json:"args,omitempty"`
	Cwd     string            `json:"cwd,omitempty"`
	Env     map[string]string `json:"env,omitempty"`
	Type    string            `json:"type,omitempty"`
	URL     string            `json:"url,omitempty"`
}

ClaudeServer is a Claude MCP server entry.

type GeminiServer

type GeminiServer struct {
	Command string            `json:"command,omitempty"`
	Args    []string          `json:"args,omitempty"`
	Env     map[string]string `json:"env,omitempty"`
	Cwd     string            `json:"cwd,omitempty"`
	URL     string            `json:"url,omitempty"`
	HttpURL string            `json:"httpUrl,omitempty"`
	Trust   bool              `json:"trust,omitempty"`
}

GeminiServer is a Gemini MCP server entry.

type GeminiSettings

type GeminiSettings struct {
	MCPServers map[string]GeminiServer `json:"mcpServers,omitempty"`
}

GeminiSettings is the format passed to GEMINI_CLI_SYSTEM_SETTINGS_PATH.

func RenderGemini

func RenderGemini(cfg CanonicalConfig, workDir string) GeminiSettings

RenderGemini converts canonical config to Gemini settings format.

type OpenCodeConfig

type OpenCodeConfig struct {
	MCP map[string]OpenCodeServer `json:"mcp"`
}

OpenCodeConfig is the OpenCode MCP config format.

func RenderOpenCode

func RenderOpenCode(cfg CanonicalConfig) OpenCodeConfig

RenderOpenCode converts canonical config to OpenCode format.

type OpenCodeServer

type OpenCodeServer struct {
	Type        string            `json:"type"`
	Command     []string          `json:"command,omitempty"`
	Environment map[string]string `json:"environment,omitempty"`
	URL         string            `json:"url,omitempty"`
	Enabled     bool              `json:"enabled,omitempty"`
	Timeout     int               `json:"timeout,omitempty"`
}

OpenCodeServer is an OpenCode MCP server entry.

type VSCodeConfig

type VSCodeConfig struct {
	Servers map[string]VSCodeServer `json:"servers"`
	Inputs  json.RawMessage         `json:"inputs,omitempty"`
}

VSCodeConfig is the VS Code MCP format (.vscode/mcp.json). The "inputs" section is intentionally ignored.

func RenderVSCode

func RenderVSCode(cfg CanonicalConfig) VSCodeConfig

RenderVSCode converts canonical config to VS Code mcp.json format.

type VSCodeServer

type VSCodeServer struct {
	Type    string            `json:"type,omitempty"`
	Command string            `json:"command,omitempty"`
	Args    []string          `json:"args,omitempty"`
	Env     map[string]string `json:"env,omitempty"`
	Cwd     string            `json:"cwd,omitempty"`
	URL     string            `json:"url,omitempty"`
	Headers map[string]string `json:"headers,omitempty"`
}

VSCodeServer is a VS Code MCP server entry.

type ZedServer

type ZedServer struct {
	Command string            `json:"command,omitempty"`
	Args    []string          `json:"args,omitempty"`
	Env     map[string]string `json:"env,omitempty"`
	URL     string            `json:"url,omitempty"`
	Headers map[string]string `json:"headers,omitempty"`
	Enabled *bool             `json:"enabled,omitempty"`
	Timeout int               `json:"timeout,omitempty"`
}

ZedServer is a Zed context_servers entry.

type ZedSettings

type ZedSettings struct {
	ContextServers map[string]ZedServer `json:"context_servers,omitempty"`
}

ZedSettings is the settings.json format used by Zed.

func RenderZed

func RenderZed(cfg CanonicalConfig) ZedSettings

RenderZed converts canonical config to Zed settings format.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL