Documentation
¶
Overview ¶
Package mcpserver exposes TUICast terminal automation as MCP tools.
Index ¶
- func NewMCPServer(service *Service, version string) (*mcp.Server, error)
- type CloseInfo
- type ConnectionInfo
- type CursorInfo
- type EventInfo
- type EventsInfo
- type FailureDumpInfo
- type FlightRecordInfo
- type Profile
- type ProfileInfo
- type ScreenInfo
- type Service
- func (s *Service) Close() error
- func (s *Service) CloseConnection(connectionID uint64) (CloseInfo, error)
- func (s *Service) CloseSession(sessionID uint64) (CloseInfo, error)
- func (s *Service) Connect(ctx context.Context, profileName string) (ConnectionInfo, error)
- func (s *Service) Events(sessionID, afterSequence uint64) (EventsInfo, error)
- func (s *Service) FailureDump(sessionID uint64, format string) (FailureDumpInfo, error)
- func (s *Service) OpenSession(ctx context.Context, connectionID uint64) (SessionInfo, error)
- func (s *Service) Press(sessionID uint64, key tuicast.Key, modifiers ...tuicast.KeyModifier) error
- func (s *Service) Profiles() []ProfileInfo
- func (s *Service) Screen(sessionID uint64) (ScreenInfo, error)
- func (s *Service) StartRecording(sessionID uint64) (workbench.Recording, error)
- func (s *Service) StopRecording(sessionID uint64) (workbench.Recording, error)
- func (s *Service) Type(sessionID uint64, text, parameter string) error
- func (s *Service) Wait(ctx context.Context, sessionID uint64, matcher tuicast.MatcherSpec, ...) (ScreenInfo, error)
- func (s *Service) WaitForEnd(ctx context.Context, sessionID uint64, timeout time.Duration) (ScreenInfo, error)
- func (s *Service) WaitForIdle(ctx context.Context, sessionID uint64, quiet, timeout time.Duration) (ScreenInfo, error)
- func (s *Service) WaitForText(ctx context.Context, sessionID uint64, text string, timeout time.Duration) (ScreenInfo, error)
- type SessionInfo
- type TerminalFactory
- type UnsupportedSequence
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 EventInfo ¶ added in v0.2.0
type EventInfo struct {
Sequence uint64 `json:"sequence"`
Type string `json:"type"`
Data string `json:"data,omitempty"`
}
EventInfo is one terminal event. Type is "bell", "enquiry", or "unsupported"; Data is the answerback for an enquiry and the ignored sequence for an unsupported event.
type EventsInfo ¶ added in v0.2.0
type EventsInfo struct {
SessionID uint64 `json:"sessionId"`
Events []EventInfo `json:"events"`
Missed uint64 `json:"missed,omitempty"`
}
EventsInfo lists a session's terminal events after a sequence number. Missed counts events in that range that are no longer retained.
type FailureDumpInfo ¶ added in v0.2.0
type FailureDumpInfo struct {
SessionID uint64 `json:"sessionId"`
Expected string `json:"expected"`
Cause string `json:"cause"`
LastScreenRevision uint64 `json:"lastScreenRevision"`
Terminal string `json:"terminal,omitempty"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
DroppedBytes uint64 `json:"droppedBytes,omitempty"`
Records []FlightRecordInfo `json:"records,omitempty"`
Unsupported []UnsupportedSequence `json:"unsupported,omitempty"`
Dump string `json:"dump,omitempty"`
}
FailureDumpInfo is the flight-recorder dump of a session's most recent failed wait. The readable format lists the recorded host output with Go escapes, such as \x1b for ESC; the jsonl format returns Dump, the same JSON-lines trace the driver SDKs receive, for saving or replay.
type FlightRecordInfo ¶ added in v0.2.0
type FlightRecordInfo struct {
Type string `json:"type"`
OffsetMilliseconds float64 `json:"offsetMilliseconds"`
Text string `json:"text,omitempty"`
Revision uint64 `json:"revision,omitempty"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
}
FlightRecordInfo is one recorded read of host output or one resize. Revision is the screen revision after the output was applied.
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"`
Title string `json:"title,omitempty"`
SessionState string `json:"sessionState"`
SessionError string `json:"sessionError,omitempty"`
}
ScreenInfo is a detached text representation of a terminal screen. Title is the window title set by the host, if any. SessionState is "active" or "ended"; SessionError is set only when a transport or terminal failure ended the session.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service owns terminal connections and sessions used by one MCP server.
func (*Service) CloseConnection ¶
CloseConnection closes a connection and its sessions. Repeated cleanup succeeds with Closed false.
func (*Service) CloseSession ¶
CloseSession closes a session. Repeated cleanup succeeds with Closed false.
func (*Service) Events ¶ added in v0.2.0
func (s *Service) Events(sessionID, afterSequence uint64) (EventsInfo, error)
Events returns a session's retained terminal events with sequence numbers greater than afterSequence. Events remain readable after the session ends, until it is closed.
func (*Service) FailureDump ¶ added in v0.2.0
func (s *Service) FailureDump(sessionID uint64, format string) (FailureDumpInfo, error)
FailureDump returns the flight-recorder dump of the session's most recent failed wait. Format "readable" (the default) lists the recorded output; format "jsonl" returns the JSON-lines trace in Dump.
func (*Service) OpenSession ¶
OpenSession opens a terminal using the selected profile's fixed terminal and dimensions.
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
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
StopRecording ends a session's recording and returns its trace.
func (*Service) Type ¶
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) WaitForEnd ¶ added in v0.2.0
func (s *Service) WaitForEnd(ctx context.Context, sessionID uint64, timeout time.Duration) (ScreenInfo, error)
WaitForEnd waits until the host ends a session, such as after a sign-out, and returns its final screen. A timeout error includes the last screen.
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.
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 ¶
TerminalFactory creates the terminal configured for a connection profile.
type UnsupportedSequence ¶ added in v0.2.0
UnsupportedSequence counts one sequence the terminal ignored.