mcpserver

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 51 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mcpserver aggregates a set's downstream servers into one MCP server exposing lazy-mcp's meta-tools. Sessions are opened on first use and shared by every later call.

Policy answers for invoke_command: lazy-mcp's `permissions` block and, after it, the calling key's profile. The gate itself lives in internal/config so the panel's browse path can apply the same permission rules.

Resources and prompts of downstream servers, reachable by the MCP client. A server contributes them only when its config names them in `expose`: without that the client sees tools alone, as before the field existed.

Downstream skills: servers that declare the skills extension contribute entries under skill://mcprig/<server>/<name>/..., and their bytes are served by a resources/read pass-through. Admission is the operator's expose:["skills"] plus the usual usable/rate-limit/permission gates. A match under an explicitly secret name refuses the read; otherwise a text resource is masked against the server's configured values and a binary blob is served byte-for-byte. The manifest's digest and size always describe the owner's raw bytes, not the masked answer, and the quarantine hashes the manifest, not the bytes served.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetupTracing added in v0.5.0

func SetupTracing(ctx context.Context) (func(context.Context) error, error)

SetupTracing включает OTLP/HTTP-экспорт. Без OTEL_EXPORTER_OTLP_ENDPOINT провайдер не ставится: спаны не пишутся и никуда не идут, а проброс traceparent работает на вручную выданных id.

Types

type Manager

type Manager struct {

	// Stats, when set, counts every downstream invocation per client and
	// tool. The panel reads the recorder; the proxy works without it.
	Stats *stats.Recorder

	// LockPath names the set's approved-descriptor record. Empty disables the
	// quarantine: a manager without a data dir has nowhere to keep approvals.
	LockPath string
	// SetDir — каталог набора (<dataDir>/sets/<id>): под ним живёт data-dir
	// скиллов. Пусто — только встроенные.
	SetDir string

	// ToolOutURL, when set, names a truncated answer by its /tool-out URL
	// instead of a path: the caller reached this process over HTTP with a key
	// and fetches the file under the same guard as /mcp. stdio leaves it false.
	ToolOutURL bool

	// StatusFile — куда писать свой статус (прогрев, векторы, простой).
	// Пусто — некуда: набор без каталога данных работает как раньше.
	StatusFile string
	// PrewarmOnContact включает прогрев по первому запросу клиента. Ставит
	// main у набора, который действительно кого-то обслуживает: вызов
	// noteContact в обход флага остаётся делом тестов.
	PrewarmOnContact bool
	// contains filtered or unexported fields
}

Manager owns the downstream sessions of one set.

func New

func New(cfg *config.Config, version string, conn *downstream.Connector) *Manager

New builds a manager. Nothing is connected until a tool needs a server. A connector carries the version and, when present, OAuth settings.

func (*Manager) Close

func (m *Manager) Close() error

Close cancels in-flight connects and shuts every open downstream session.

func (*Manager) Reload added in v0.5.0

func (m *Manager) Reload(next *config.Config) ReloadResult

Reload applies a freshly loaded config to the running process: new servers join lazily, removed ones lose their session and tool cache, a server whose process or address changed gets a new session on its next call. The previous config stays in force only when the caller could not load one at all.

func (*Manager) ReloadFailed added in v0.5.0

func (m *Manager) ReloadFailed(err error) ReloadResult

ReloadFailed records an attempt whose file did not even load. The running config is untouched; the generation still grows so the supervisor's answer names the try that failed.

func (*Manager) Server

func (m *Manager) Server() *mcp.Server

func (*Manager) StartStatus added in v0.8.0

func (m *Manager) StartStatus()

StartStatus заводит репер простоя и обновление файла статуса; сразу пишет первый снимок, чтобы панель не ждала минуту. Одна горутина на процесс, живёт до Close. Без StatusFile файла нет, а репер всё равно нужен.

type PrewarmStatus added in v0.8.0

type PrewarmStatus struct {
	Running bool     `json:"running"`
	Done    int      `json:"done"`
	Failed  []string `json:"failed"`
	Ms      int64    `json:"ms"`
}

PrewarmStatus — ход прогрева: идёт ли он, сколько серверов поднято, какие не вышло и сколько это заняло. failed — имена, а не тексты ошибок: текст уже в логе, а панели хватает «кто именно».

type ReloadResult added in v0.5.0

type ReloadResult struct {
	// Generation counts attempts, starting at 1, including a rejected config:
	// the supervisor sees that its SIGHUP landed even when nothing was applied.
	Generation int
	// Applied names what the live process now uses: "added:<server>" (lazy — no
	// connection until a call), "removed:<server>", "reset:<server>" (session
	// closed: a field that decides the process or address changed),
	// "updated:<server>" (applied in place, session kept), and the set-wide
	// "rateLimit", "permissions", "profiles", "requestTimeout", "healthMonitor".
	Applied []string
	// RestartNeeded names the transport fields this process cannot adopt: the
	// listener was built at startup, so only a restart applies them.
	RestartNeeded []string
	// Err is the load error. Applied stays empty and the previous config is
	// still in force: fail-closed, the process keeps serving.
	Err string
}

ReloadResult reports what one attempt to re-read the config applied, and what it could not. It is the whole answer the supervisor gets: the set's process writes it to reload.status, there is no HTTP route for it.

type RuntimeStatus added in v0.8.0

type RuntimeStatus struct {
	Prewarm *PrewarmStatus `json:"prewarm,omitempty"`
	Search  *SearchStatus  `json:"search,omitempty"`
	Servers []ServerStatus `json:"servers,omitempty"`
}

RuntimeStatus — что процесс набора рассказывает о себе: прогрев, плотный слой поиска и жив ли каждый сервер. Пишется файлом в каталоге набора, панель пересказывает его как есть (manager.RuntimeStatus).

type SearchStatus added in v0.8.0

type SearchStatus struct {
	Vectors string `json:"vectors"`
}

SearchStatus — состояние плотного слоя поиска: "off" — стартового прогрева нет (не настроен, отключён или не удался), "warming" — векторы считаются, "ready" — кэш каталога прочитан.

type ServerStatus added in v0.8.0

type ServerStatus struct {
	Name    string `json:"name"`
	Running bool   `json:"running"`
	IdleMs  int64  `json:"idle_ms"`
}

ServerStatus — жив ли дочерний сервер и сколько он простоял без вызовов. running=false при живом наборе значит «выгружен по простою, поднимется на следующем вызове».

type SkillSummary added in v0.8.0

type SkillSummary struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	URI         string `json:"uri"`
	Error       string `json:"error"`
	Resources   int    `json:"resources"`
	Size        int64  `json:"size"`
}

SkillSummary is one skill as the panel sees it: valid when Error is empty.

func EmbeddedSkills added in v0.9.0

func EmbeddedSkills() []SkillSummary

EmbeddedSkills returns the built-in skills as panel summaries: metadata and sizes only, never file bytes. The panel shows them read-only beside a set's own directory.

func LoadSkillsDir added in v0.8.0

func LoadSkillsDir(dir string) ([]SkillSummary, []error)

LoadSkillsDir reads a skill directory from disk (a set's data dir). A missing directory means no data-dir skills — the same as an empty one; the runtime already treats it so. Real failures (permission, a broken path) stay errors. An invalid skill stays in the list with Error set, so a typo is visible.

Jump to

Keyboard shortcuts

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