vscode

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package vscode provides an adapter for VS Code / GitHub Copilot MCP configuration.

VS Code uses a different format than Claude:

  • Root key is "servers" (not "mcpServers")
  • Has "inputs" section for secret management
  • Requires explicit "type" field
  • Supports "envFile" for loading env files

File locations:

  • Workspace: .vscode/mcp.json
  • User: depends on OS and profile

Index

Constants

View Source
const (
	// AdapterName is the identifier for this adapter.
	AdapterName = "vscode"

	// WorkspaceConfigDir is the workspace config directory.
	WorkspaceConfigDir = ".vscode"

	// ConfigFileName is the config file name.
	ConfigFileName = "mcp.json"
)

Variables

This section is empty.

Functions

func ReadWorkspaceConfig

func ReadWorkspaceConfig() (*core.Config, error)

ReadWorkspaceConfig reads the workspace .vscode/mcp.json file.

func WorkspaceConfigPath

func WorkspaceConfigPath() string

WorkspaceConfigPath returns the workspace config path.

func WriteWorkspaceConfig

func WriteWorkspaceConfig(cfg *core.Config) error

WriteWorkspaceConfig writes to the workspace .vscode/mcp.json file.

Types

type Adapter

type Adapter struct{}

Adapter implements core.Adapter for VS Code.

func NewAdapter

func NewAdapter() *Adapter

NewAdapter creates a new VS Code adapter.

func (*Adapter) DefaultPaths

func (a *Adapter) DefaultPaths() []string

DefaultPaths returns the default config file paths for VS Code.

func (*Adapter) FromCore

func (a *Adapter) FromCore(cfg *core.Config) *Config

FromCore converts canonical config to VS Code format.

func (*Adapter) Marshal

func (a *Adapter) Marshal(cfg *core.Config) ([]byte, error)

Marshal converts canonical config to VS Code format.

func (*Adapter) Name

func (a *Adapter) Name() string

Name returns the adapter name.

func (*Adapter) Parse

func (a *Adapter) Parse(data []byte) (*core.Config, error)

Parse parses VS Code config data into the canonical format.

func (*Adapter) ReadFile

func (a *Adapter) ReadFile(path string) (*core.Config, error)

ReadFile reads a VS Code config file.

func (*Adapter) ToCore

func (a *Adapter) ToCore(vscodeCfg *Config) *core.Config

ToCore converts VS Code config to canonical format.

func (*Adapter) WriteFile

func (a *Adapter) WriteFile(cfg *core.Config, path string) error

WriteFile writes canonical config to a VS Code format file.

type Config

type Config struct {
	// Inputs defines input variables for sensitive data.
	Inputs []InputVariable `json:"inputs,omitempty"`

	// Servers maps server names to their configurations.
	Servers map[string]ServerConfig `json:"servers"`
}

Config represents the VS Code MCP configuration. Note: VS Code uses "servers" not "mcpServers".

func NewConfig

func NewConfig() *Config

NewConfig creates a new VS Code config.

type InputVariable

type InputVariable struct {
	// Type is the input type, typically "promptString".
	Type string `json:"type"`

	// ID is the unique identifier referenced as ${input:id}.
	ID string `json:"id"`

	// Description is the user-friendly prompt text.
	Description string `json:"description"`

	// Password hides input when true.
	Password bool `json:"password,omitempty"`
}

InputVariable represents a placeholder for sensitive values.

type ServerConfig

type ServerConfig struct {
	// Type is required: "stdio", "http", or "sse".
	Type string `json:"type"`

	// --- STDIO Server Fields ---
	Command string            `json:"command,omitempty"`
	Args    []string          `json:"args,omitempty"`
	Env     map[string]string `json:"env,omitempty"`
	EnvFile string            `json:"envFile,omitempty"`

	// --- HTTP/SSE Server Fields ---
	URL     string            `json:"url,omitempty"`
	Headers map[string]string `json:"headers,omitempty"`
}

ServerConfig represents a VS Code MCP server configuration.

Jump to

Keyboard shortcuts

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