mcp

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ServerVersion = "dev"

ServerVersion can be set by the caller to match the binary version.

Functions

func CollapseSuccessful added in v0.1.6

func CollapseSuccessful(messages []store.LogMessage) []store.LogMessage

CollapseSuccessful replaces the output of successful build runs (exit code 0) with a single-line summary to reduce context token consumption.

A "run" is a sequence of messages sharing the same tag, bounded by an exit code message. When the same tag appears in multiple runs within a single drain window (e.g. a failed build followed by a successful rebuild), each run is evaluated independently — only runs with exit code 0 are collapsed. Runs with non-zero exit code or no exit code are returned unchanged.

func DedupMessages added in v0.1.4

func DedupMessages(messages []store.LogMessage) []store.LogMessage

DedupMessages removes duplicate messages across sources. Dedup key: sha256(timestamp_micros + tag + stream + content)[:16]. Earlier messages (local) take priority over later ones (configured).

func FormatMessages

func FormatMessages(messages []store.LogMessage) string

FormatMessages converts log messages into a human-readable string.

func FormatMessagesRaw added in v0.1.5

func FormatMessagesRaw(messages []store.LogMessage) string

FormatMessagesRaw outputs raw lines without [devtap: tag] headers. Messages are separated by blank lines.

func TruncateMessages

func TruncateMessages(messages []store.LogMessage, maxLines int) []store.LogMessage

TruncateMessages applies line-level truncation across messages. It allocates the maxLines budget proportionally to each message, using filter.Truncate for tail-biased truncation per message.

Types

type CallToolParams

type CallToolParams struct {
	Name      string         `json:"name"`
	Arguments map[string]any `json:"arguments,omitempty"`
}

CallToolParams holds parameters for tools/call.

type CallToolResult

type CallToolResult struct {
	Content []ContentBlock `json:"content"`
	IsError bool           `json:"isError,omitempty"`
}

CallToolResult is returned for tools/call.

type Capabilities

type Capabilities struct {
	Tools *ToolsCapability `json:"tools,omitempty"`
}

Capabilities declares what the server supports.

type ContentBlock

type ContentBlock struct {
	Type string `json:"type"` // "text"
	Text string `json:"text"`
}

ContentBlock holds tool output.

type DrainSource added in v0.1.4

type DrainSource struct {
	Store     store.Store
	SessionID string
	Label     string // e.g. "local" or the explicit session name
}

DrainSource represents a single source from which the MCP server drains messages.

type Error

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

Error represents a JSON-RPC 2.0 error.

type InitializeResult

type InitializeResult struct {
	ProtocolVersion string       `json:"protocolVersion"`
	Capabilities    Capabilities `json:"capabilities"`
	ServerInfo      ServerInfo   `json:"serverInfo"`
}

InitializeResult is returned for initialize requests.

type InputSchema

type InputSchema struct {
	Type       string              `json:"type"`
	Properties map[string]Property `json:"properties,omitempty"`
}

InputSchema is a JSON Schema for tool inputs.

type Property

type Property struct {
	Type        string `json:"type"`
	Description string `json:"description"`
}

Property is a JSON Schema property.

type Request

type Request struct {
	JSONRPC string          `json:"jsonrpc"`
	ID      any             `json:"id,omitempty"` // may be absent for notifications
	Method  string          `json:"method"`
	Params  json.RawMessage `json:"params,omitempty"`
}

Request represents a JSON-RPC 2.0 request.

type Response

type Response struct {
	JSONRPC string `json:"jsonrpc"`
	ID      any    `json:"id"`
	Result  any    `json:"result,omitempty"`
	Error   *Error `json:"error,omitempty"`
}

Response represents a JSON-RPC 2.0 response.

type Server

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

Server implements an MCP stdio server that exposes devtap tools.

func NewMultiSourceServer added in v0.1.4

func NewMultiSourceServer(sources []DrainSource, maxLines int) *Server

NewMultiSourceServer creates a new MCP server with multiple drain sources.

func NewServer

func NewServer(s store.Store, sessionID string, maxLines int) *Server

NewServer creates a new MCP server with a single drain source (backward compatible).

func (*Server) Run

func (s *Server) Run() error

Run starts the server loop, reading JSON-RPC messages from stdin and writing responses to stdout.

func (*Server) SetIO

func (s *Server) SetIO(in io.Reader, out io.Writer)

SetIO overrides input/output streams (for testing).

type ServerInfo

type ServerInfo struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

ServerInfo provides server metadata.

type Tool

type Tool struct {
	Name        string      `json:"name"`
	Description string      `json:"description"`
	InputSchema InputSchema `json:"inputSchema"`
}

Tool describes a callable tool.

type ToolsCapability

type ToolsCapability struct {
	ListChanged bool `json:"listChanged,omitempty"`
}

ToolsCapability indicates tool support.

type ToolsListResult

type ToolsListResult struct {
	Tools []Tool `json:"tools"`
}

ToolsListResult is returned for tools/list.

Jump to

Keyboard shortcuts

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