mcpinstall

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 30, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

SPDX-License-Identifier: MIT

SPDX-License-Identifier: MIT

SPDX-License-Identifier: MIT

SPDX-License-Identifier: MIT

SPDX-License-Identifier: MIT

SPDX-License-Identifier: MIT Package mcpinstall registers and removes sting's MCP server entry in the config files of agent runtimes (Claude Code, Codex, OpenCode, Grok). Each runtime has an adapter translating the runtime-agnostic Entry into that runtime's native config shape, with atomic, format-preserving writes.

SPDX-License-Identifier: MIT

Index

Constants

This section is empty.

Variables

View Source
var ErrScopeUnsupported = errors.New("scope not supported by this runtime")

ErrScopeUnsupported is returned by adapters that do not support a given Scope (e.g. Codex has no project scope).

Functions

func ClaudePermissionToolName

func ClaudePermissionToolName(tool string) string

ClaudePermissionToolName returns the identifier Claude Code matches in permissions.allow for a sting MCP tool: mcp__<server>__<tool>.

func ClaudePermissionsSnippet

func ClaudePermissionsSnippet(toolNames []string) (string, error)

ClaudePermissionsSnippet renders a ~/.claude/settings.json fragment that allow-lists the given tools under permissions.allow. sting's tools are all read-only, so auto-approving them is safe.

func Snippet

func Snippet(runtime string, e Entry) (string, error)

Snippet returns a self-contained config fragment that registers sting under the named runtime, matching what the adapter would write. Intended for `sting install --manual`, so a user can paste it verbatim.

func WriteAtomic

func WriteAtomic(path string, data []byte, mode fs.FileMode) error

WriteAtomic writes data to path via a temp-file-plus-rename so readers never observe a truncated file. If path already exists as a regular file (or a symlink to one), its mode is preserved; otherwise mode is used. Symlinks are resolved and the write lands on the target, leaving the link in place. The parent directory must already exist.

Types

type Entry

type Entry struct {
	Command string
	Args    []string
	Enabled bool
}

Entry is the runtime-agnostic MCP server entry written into each agent's config. Adapters translate it to their native shape (JSON object vs TOML table, command+args vs argv array). Enabled is honored by runtimes that have the concept (OpenCode, Grok); others always write it as true.

type Runtime

type Runtime interface {
	Name() string
	Detect() (bool, error)
	ConfigPath(scope Scope) (string, error)
	ReadEntry(path string) (entry Entry, present bool, err error)
	WriteEntry(path string, entry Entry) error
	RemoveEntry(path string) (removed bool, err error)
}

Runtime is the adapter contract; implementations live in the per-runtime files in this package.

func All

func All() []Runtime

All returns the registered adapters sorted by name for deterministic output.

func ByName

func ByName(name string) (Runtime, bool)

ByName looks up a single adapter by canonical name.

type Scope

type Scope int

Scope selects user-scoped or project-scoped config files.

const (
	ScopeUser Scope = iota
	ScopeProject
)

func (Scope) String

func (s Scope) String() string

type Selection

type Selection struct {
	Explicit []string
}

Selection expresses which runtimes a CLI invocation targets. An empty Explicit list means auto-detect; otherwise only the named runtimes apply.

func SelectionFromFlags

func SelectionFromFlags(claude, codex, opencode, grok bool) Selection

SelectionFromFlags builds a Selection from per-runtime bool flags, in a deterministic order.

func (Selection) Resolve

func (s Selection) Resolve() ([]Runtime, error)

Resolve returns the adapters this Selection targets. An empty Selection filters registered adapters by Detect(); an explicit list is honored even for runtimes Detect() would skip.

Jump to

Keyboard shortcuts

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