mcp

package
v2.4.2 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: GPL-3.0 Imports: 33 Imported by: 0

Documentation

Overview

Package mcp — logging middleware.

The MCP stdio transport reserves stdout for JSON-RPC frames; anything written there corrupts the protocol stream. pkg/logger writes to stderr by default, so it is safe to use from server middleware.

loggingMiddleware logs every inbound (server-receiving) and outbound (server-sending) MCP method call with method name, duration, and error status. Tool arguments and results are intentionally not logged — they may contain large blobs or sensitive paths.

Package mcp wires the yap functionality onto a Model Context Protocol server. The package is transport-agnostic; cmd/yap-mcp picks the transport (stdio by default).

Public surface:

NewServer() *mcp.Server  // returns a configured MCP server with all
                         // yap tools and resources registered.

The handlers are intentionally thin: they call into existing yap packages (pkg/constants, pkg/buildinfo, pkg/parser, pkg/graph, pkg/project, ...) and translate results into MCP tool/resource payloads.

Index

Constants

View Source
const ServerName = "yap-mcp"

ServerName is reported to MCP clients via the Implementation handshake.

Variables

This section is empty.

Functions

func NewServer

func NewServer() *mcpsdk.Server

NewServer constructs an MCP server with the yap tool surface registered. The returned server has no transport bound; the caller runs it via server.Run(ctx, transport).

Types

type BuildSession

type BuildSession struct {
	ID        string
	StartedAt time.Time
	EndedAt   time.Time
	State     BuildState
	Distro    string
	Release   string
	Path      string

	// OutputDir is the resolved artifact output directory for this build,
	// cached when the build is registered so list_artifacts/build_summary
	// don't have to re-load the project on every call.
	OutputDir string

	// InContainer is true when the build was dispatched into a yap
	// container image instead of running natively in-process. Exposed in
	// build_status so clients can tell where the work is happening.
	InContainer bool
	// ContainerRuntime is the container backend ("cli" or "rootless") used
	// when InContainer is true; empty otherwise.
	ContainerRuntime string
	// ContainerImage is the resolved image tag (e.g. "ubuntu-jammy") used
	// for the dispatch; empty for native builds.
	ContainerImage string

	// Err holds the build error string when State == failed.
	Err string

	// Log captures stdout+stderr from container dispatches. Bounded by
	// maxSessionLogBytes; accessed via Log.String() in snapshots.
	Log *sessionLog
	// contains filtered or unexported fields
}

BuildSession is one in-flight or finished yap build invocation tracked by the MCP server. Clients can poll its status via build_status.

func (*BuildSession) Done

func (s *BuildSession) Done() <-chan struct{}

Done returns a channel closed when the build reaches a terminal state. Useful for build_wait. Safe to call repeatedly.

type BuildState

type BuildState string

BuildState represents the lifecycle phase of an async yap build.

const (
	// BuildStateRunning is the initial state set when Register inserts a new
	// session into the registry.
	BuildStateRunning BuildState = "running"
	// BuildStateSucceeded is the terminal state for builds that finished
	// without error.
	BuildStateSucceeded BuildState = "succeeded"
	// BuildStateFailed is the terminal state for builds that returned a
	// non-context error from the project pipeline.
	BuildStateFailed BuildState = "failed"
	// BuildStateCanceled is the terminal state for builds whose context was
	// canceled (either by build_cancel or by server shutdown).
	BuildStateCanceled BuildState = "canceled"
)

Build lifecycle states surfaced via the build_status MCP tool.

Jump to

Keyboard shortcuts

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