mcpserver

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 12 Imported by: ? 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 mcpserver exposes TUICast terminal automation as MCP tools.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMCPServer

func NewMCPServer(service *Service, version string) (*mcp.Server, error)

NewMCPServer creates a protocol server backed by service.

Types

type CloseInfo

type CloseInfo struct {
	Closed bool `json:"closed"`
}

CloseInfo reports whether a live object was closed. Closing an already absent object is successful and returns false.

type ConnectionInfo

type ConnectionInfo struct {
	ConnectionID uint64 `json:"connectionId"`
	Profile      string `json:"profile"`
}

ConnectionInfo identifies an opened TUICast connection.

type CursorInfo

type CursorInfo struct {
	Column  int  `json:"column"`
	Row     int  `json:"row"`
	Visible bool `json:"visible"`
}

CursorInfo is the zero-based cursor location and visibility state.

type Profile

type Profile struct {
	Name        string
	Description string
	Protocol    string
	Terminal    tuicast.TerminalProfile
	Width       int
	Height      int
	Connector   tuicast.Connector
}

Profile is one operator-approved terminal endpoint available to MCP clients. Connector may contain resolved credentials; those values are never exposed by the service or its MCP tools.

type ProfileInfo

type ProfileInfo struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Protocol    string `json:"protocol"`
	Terminal    string `json:"terminal"`
	Width       int    `json:"width"`
	Height      int    `json:"height"`
}

ProfileInfo is the non-sensitive profile metadata returned to MCP clients.

type ScreenInfo

type ScreenInfo struct {
	SessionID uint64     `json:"sessionId"`
	Text      string     `json:"text"`
	Width     int        `json:"width"`
	Height    int        `json:"height"`
	Cursor    CursorInfo `json:"cursor"`
	Revision  uint64     `json:"revision"`
}

ScreenInfo is a detached text representation of a terminal screen.

type Service

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

Service owns terminal connections and sessions used by one MCP server.

func New

func New(logger *slog.Logger, profiles []Profile, terminal TerminalFactory) (*Service, error)

New creates an MCP terminal automation service.

func (*Service) Close

func (s *Service) Close() error

Close closes all service-owned sessions and connections. It is idempotent.

func (*Service) CloseConnection

func (s *Service) CloseConnection(connectionID uint64) (CloseInfo, error)

CloseConnection closes a connection and its sessions. Repeated cleanup succeeds with Closed false.

func (*Service) CloseSession

func (s *Service) CloseSession(sessionID uint64) (CloseInfo, error)

CloseSession closes a session. Repeated cleanup succeeds with Closed false.

func (*Service) Connect

func (s *Service) Connect(ctx context.Context, profileName string) (ConnectionInfo, error)

Connect opens an operator-approved named profile.

func (*Service) OpenSession

func (s *Service) OpenSession(ctx context.Context, connectionID uint64) (SessionInfo, error)

OpenSession opens a terminal using the selected profile's fixed terminal and dimensions.

func (*Service) Press

func (s *Service) Press(sessionID uint64, key tuicast.Key, modifiers ...tuicast.KeyModifier) error

Press sends one key with optional modifiers to a terminal session.

func (*Service) Profiles

func (s *Service) Profiles() []ProfileInfo

Profiles returns sorted, non-sensitive metadata for approved endpoints.

func (*Service) Screen

func (s *Service) Screen(sessionID uint64) (ScreenInfo, error)

Screen returns the current detached screen for a session.

func (*Service) StartRecording added in v0.1.0

func (s *Service) StartRecording(sessionID uint64) (workbench.Recording, error)

StartRecording begins recording successful input and wait operations on a session. A session may have only one active recording.

func (*Service) StopRecording added in v0.1.0

func (s *Service) StopRecording(sessionID uint64) (workbench.Recording, error)

StopRecording ends a session's recording and returns its trace.

func (*Service) Type

func (s *Service) Type(sessionID uint64, text, parameter string) error

Type sends literal text to a terminal session. When the session is recording, a non-empty parameter is recorded in place of text.

func (*Service) Wait added in v0.1.0

func (s *Service) Wait(ctx context.Context, sessionID uint64, matcher tuicast.MatcherSpec, timeout, stable time.Duration) (ScreenInfo, error)

Wait waits until matcher succeeds on a session screen. A positive stable period also requires that no host output arrives for that period.

func (*Service) WaitForIdle added in v0.1.0

func (s *Service) WaitForIdle(ctx context.Context, sessionID uint64, quiet, timeout time.Duration) (ScreenInfo, error)

WaitForIdle waits until no host output arrives for quiet.

func (*Service) WaitForText

func (s *Service) WaitForText(ctx context.Context, sessionID uint64, text string, timeout time.Duration) (ScreenInfo, error)

WaitForText waits until exact text appears on a session screen.

type SessionInfo

type SessionInfo struct {
	SessionID    uint64 `json:"sessionId"`
	ConnectionID uint64 `json:"connectionId"`
	Terminal     string `json:"terminal"`
	Width        int    `json:"width"`
	Height       int    `json:"height"`
}

SessionInfo identifies an opened TUICast terminal session.

type TerminalFactory

type TerminalFactory func(tuicast.TerminalProfile, int, int) (tuicast.Terminal, error)

TerminalFactory creates the terminal configured for a connection profile.

Jump to

Keyboard shortcuts

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