mcp

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Log

func Log(format string, args ...any)

Log writes a formatted message to the MCP log file. No-op if logger is nil.

func SetLogger

func SetLogger(l *log.Logger)

SetLogger sets the file logger for the MCP server package.

Types

type BrainClient

type BrainClient interface {
	GetBrain(repoPath, instanceID string) (*brain.BrainState, error)
	UpdateStatus(repoPath, instanceID, feature string, files []string) (*brain.UpdateStatusResult, error)
	SendMessage(repoPath, from, to, content string) error
	RemoveAgent(repoPath, instanceID string) error

	// Tier 3: actions relayed to TUI.
	CreateInstance(repoPath, instanceID string, params brain.CreateInstanceParams) (*brain.CreateInstanceResult, error)
	InjectMessage(repoPath, instanceID string, params brain.InjectMessageParams) error
	PauseInstance(repoPath, instanceID, target string) error
	ResumeInstance(repoPath, instanceID, target string) error
	KillInstance(repoPath, instanceID, target string) error

	// Tier 3: workflow DAG.
	DefineWorkflow(repoPath, instanceID string, tasks []*brain.WorkflowTask) (*brain.WorkflowResult, error)
	CompleteTask(repoPath, instanceID, taskID, status, errMsg string) (*brain.WorkflowResult, error)
	GetWorkflow(repoPath, instanceID string) (*brain.Workflow, error)

	// Event subscription.
	Subscribe(repoPath string, filter brain.EventFilter) (string, error)
	PollEvents(subscriberID string, timeoutSec int) ([]brain.Event, error)
	Unsubscribe(subscriberID string) error
}

BrainClient abstracts brain state access for MCP tool handlers. Implemented by brain.Client (socket) and fileBrainClient (file fallback).

func NewFileBrainClient

func NewFileBrainClient(hivemindDir string) BrainClient

NewFileBrainClient creates a file-based BrainClient.

type DiffStatsInfo

type DiffStatsInfo struct {
	Added   int    `json:"added"`
	Removed int    `json:"removed"`
	Content string `json:"content,omitempty"`
}

DiffStatsInfo represents the diff stats for an instance.

type HivemindMCPServer

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

HivemindMCPServer wraps an MCP server with Hivemind-specific state.

func NewHivemindMCPServer

func NewHivemindMCPServer(brainClient BrainClient, hivemindDir, instanceID, repoPath string, tier int, memMgr *memory.Manager, repoMemMgr *memory.Manager, legacyRepoMemMgr *memory.Manager) *HivemindMCPServer

NewHivemindMCPServer creates a new MCP server for a Hivemind agent.

func (*HivemindMCPServer) Serve

func (h *HivemindMCPServer) Serve() error

Serve starts the MCP server using stdio transport.

type InstanceInfo

type InstanceInfo struct {
	Title     string         `json:"title"`
	Path      string         `json:"path"`
	Branch    string         `json:"branch"`
	Status    InstanceStatus `json:"status"`
	Program   string         `json:"program"`
	TopicName string         `json:"topic_name,omitempty"`
	Worktree  WorktreeInfo   `json:"worktree"`
	DiffStats DiffStatsInfo  `json:"diff_stats"`
}

InstanceInfo represents a single Hivemind instance as stored in state.json.

type InstanceStatus

type InstanceStatus int

InstanceStatus represents the status of a Hivemind instance as stored in state.json. Values match the iota order in session/instance.go.

const (
	StatusRunning InstanceStatus = iota
	StatusReady
	StatusLoading
	StatusPaused
)

func (InstanceStatus) String

func (s InstanceStatus) String() string

String returns a human-readable status string.

type StateReader

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

StateReader reads instance data from the Hivemind state file.

func NewStateReader

func NewStateReader(hivemindDir string) *StateReader

NewStateReader creates a StateReader that reads from the given Hivemind directory.

func (*StateReader) ReadInstances

func (r *StateReader) ReadInstances() ([]InstanceInfo, error)

ReadInstances reads and parses all instances from state.json.

type WorktreeInfo

type WorktreeInfo struct {
	RepoPath      string `json:"repo_path"`
	WorktreePath  string `json:"worktree_path"`
	SessionName   string `json:"session_name"`
	BranchName    string `json:"branch_name"`
	BaseCommitSHA string `json:"base_commit_sha"`
}

WorktreeInfo represents the git worktree data for an instance.

Jump to

Keyboard shortcuts

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