plugin

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 24 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 plugin serves the HTTP loopback plugin protocol (spec §19.4) and the stdio MCP companion (spec §19.3, mode 5). Both sit on internal/session and internal/store. Writes go through session and store only; search and session discovery use a read-only handle on the same database file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewToken

func NewToken() (string, error)

NewToken returns a random 256-bit bearer token, hex encoded.

func WriteTokenFile

func WriteTokenFile(path, token string) error

WriteTokenFile writes token to path readable only by the owner (0600).

Types

type Config

type Config struct {
	Store   *store.Store     // required; the caller owns it and closes it
	Project project.Resolved // required; every session of this instance belongs to it
	// Token is the bearer token for every /__acd-ctx/plugin/ endpoint. Required,
	// at least 32 characters. Generate it with NewToken.
	Token      string
	ListenHost string // host of the listen address, accepted in the Host header
	// AllowedHosts, when non-empty, is the exact Host name set (already normalized
	// by the caller, see proxy.NormalizeHosts); it replaces the defaults.
	AllowedHosts []string
	Version      string
	// ContextLimit is used when runtime-info names no window. Default 200000.
	ContextLimit int
	// ExportDir receives the files of decompress mode file. Default: the
	// project's exports directory (see exportsDir).
	ExportDir string
	Logger    *slog.Logger // default: discard
}

Config wires the plugin handler. Store and DBPath name the same database.

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler is the http.Handler of the plugin protocol. It is safe for concurrent use.

func New

func New(cfg Config) (*Handler, error)

New validates cfg, ensures the project row and builds the handler.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP enforces the loopback guards, authenticates and routes the endpoints.

type MCP

type MCP struct {
	// contains filtered or unexported fields
}

MCP is a stdio MCP server bound to the project of its working directory.

func NewMCP

func NewMCP(cfg MCPConfig) (*MCP, error)

NewMCP resolves the project (read-only) and opens the read-only handle.

func (*MCP) Close

func (m *MCP) Close() error

Close releases the read-only database handle. The store is not closed.

func (*MCP) ProjectID

func (m *MCP) ProjectID() string

ProjectID is the project the server is bound to.

func (*MCP) Serve

func (m *MCP) Serve(ctx context.Context, in io.Reader, out io.Writer) error

Serve runs the protocol on in/out until in ends or ctx is done.

type MCPConfig

type MCPConfig struct {
	Store   *store.Store // required; the caller owns it
	DBPath  string       // required; the same database, opened read-only to find the latest session
	Cwd     string       // project directory; default: the working directory
	Markers []string     // project root markers; default: go.mod, package.json, ...
	Version string
	Logger  *slog.Logger // default: discard. Never stdout: stdout carries the protocol.
}

MCPConfig wires the stdio MCP companion.

Jump to

Keyboard shortcuts

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