mcp

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: MIT Imports: 8 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 FormatMessages

func FormatMessages(messages []store.LogMessage) string

FormatMessages converts log messages into a human-readable string.

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 smart head/tail 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 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 NewServer

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

NewServer creates a new MCP server.

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