mcpclient

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMCPClientImplementation

func GetMCPClientImplementation() *mcp.Implementation

Types

type CodeIssue added in v0.6.0

type CodeIssue struct {
	Description string `json:"description"`
	Line        int    `json:"line"`
	StartColumn int    `json:"start_column"`
	EndColumn   int    `json:"end_column"`
	Severity    string `json:"severity"`
	Fixable     bool   `json:"fixable"`
}

CodeIssue represents a structured code issue returned by check_matlab_code.

type CreateSessionOption added in v0.7.0

type CreateSessionOption func(*MCPClient)

CreateSessionOption configures the client before connecting to the server.

func WithRoots added in v0.7.0

func WithRoots(roots ...*mcp.Root) CreateSessionOption

WithRoots returns a CreateSessionOption that adds roots to the client before the MCP handshake. This ensures the server receives roots during initialization.

type FileSystemProvider added in v0.8.0

type FileSystemProvider interface {
	DirFS(path string) fs.FS
}

type LogReader added in v0.8.0

type LogReader interface {
	ReadCombined(logFS fs.FS, globPattern string) (string, error)
	ReadEntries(logFS fs.FS, dumpPatterns []logs.DumpPattern) ([]logs.DumpEntry, error)
}

type LoggedSession added in v0.8.0

type LoggedSession struct {
	*MCPClientSession
	// contains filtered or unexported fields
}

func NewLoggedSession added in v0.8.0

func NewLoggedSession(
	session *MCPClientSession,
	logDir string,
	logFS fs.FS,
	stderrHeader string,
	dumpPatterns []logs.DumpPattern,
	logReader LogReader,
	stderrProvider StderrProvider,
) (*LoggedSession, error)

func (*LoggedSession) CollectDumpData added in v0.8.0

func (s *LoggedSession) CollectDumpData() (string, []logs.DumpEntry, error)

func (*LoggedSession) DumpLogsOnFailure added in v0.8.0

func (s *LoggedSession) DumpLogsOnFailure(t *testing.T)

func (*LoggedSession) LogDir added in v0.8.0

func (s *LoggedSession) LogDir() string

func (*LoggedSession) LogFS added in v0.8.0

func (s *LoggedSession) LogFS() fs.FS

func (*LoggedSession) ReadAllServerLogs added in v0.8.0

func (s *LoggedSession) ReadAllServerLogs() (string, error)

func (*LoggedSession) ReadLogs added in v0.8.0

func (s *LoggedSession) ReadLogs(globPattern string) (string, error)

func (*LoggedSession) ReadServerLogs added in v0.8.0

func (s *LoggedSession) ReadServerLogs() (string, error)

func (*LoggedSession) ReadWatchdogLogs added in v0.8.0

func (s *LoggedSession) ReadWatchdogLogs() (string, error)

type LoggedSessionFactory added in v0.8.0

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

func NewLoggedSessionFactory added in v0.8.0

func NewLoggedSessionFactory(logReader LogReader, fileSystemProvider FileSystemProvider) (*LoggedSessionFactory, error)

func (*LoggedSessionFactory) New added in v0.8.0

func (f *LoggedSessionFactory) New(
	session *MCPClientSession,
	logDir string,
	stderrHeader string,
	dumpPatterns []logs.DumpPattern,
) (*LoggedSession, error)

type MATLABInfo

type MATLABInfo struct {
	Path    string `json:"matlab_root"`
	Version string `json:"version"`
}

MATLABInfo represents information about a MATLAB installation

type MCPClient

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

MCPClient wraps MCP session with helper methods Lifecycle: NewClient -> CreateSession -> [operations] -> Close

func NewClient

func NewClient(ctx context.Context, serverPath string, env []string, args ...string) *MCPClient

NewClient creates a new MCP client with roots capability enabled.

func NewClientWithoutRootsCapability added in v0.7.0

func NewClientWithoutRootsCapability(ctx context.Context, serverPath string, env []string, args ...string) *MCPClient

NewClientWithoutRootsCapability creates a new MCP client that does not advertise roots capability. The server will not request roots from this client.

func (*MCPClient) AddRoots added in v0.7.0

func (c *MCPClient) AddRoots(roots ...*mcp.Root)

AddRoots adds roots to the MCP client. Roots can be added before or after creating a session. If a session is already connected, the server is notified.

func (*MCPClient) CreateSession

func (c *MCPClient) CreateSession(ctx context.Context, opts ...CreateSessionOption) (*MCPClientSession, error)

type MCPClientSession

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

MCPClientSession represents an active MCP session

func (*MCPClientSession) CallTool

func (s *MCPClientSession) CallTool(ctx context.Context, name string, args map[string]any) (*mcp.CallToolResult, error)

CallTool calls an MCP tool and asserts it doesn't error

func (*MCPClientSession) CheckCode

func (s *MCPClientSession) CheckCode(ctx context.Context, scriptPath string) ([]CodeIssue, error)

CheckCode checks MATLAB code

func (*MCPClientSession) ClientName added in v0.8.0

func (s *MCPClientSession) ClientName() string

func (*MCPClientSession) ClientTitle added in v0.8.0

func (s *MCPClientSession) ClientTitle() string

func (*MCPClientSession) ClientVersion added in v0.8.0

func (s *MCPClientSession) ClientVersion() string

func (*MCPClientSession) ClientWebsiteURL added in v0.8.0

func (s *MCPClientSession) ClientWebsiteURL() string

func (*MCPClientSession) Close

func (s *MCPClientSession) Close() error

func (*MCPClientSession) DetectToolboxes

func (s *MCPClientSession) DetectToolboxes(ctx context.Context) (string, error)

DetectToolboxes detects installed MATLAB toolboxes

func (*MCPClientSession) EvaluateCode

func (s *MCPClientSession) EvaluateCode(ctx context.Context, code string, projectPath ...string) (string, error)

EvaluateCode evaluates MATLAB code

func (*MCPClientSession) GetTextContent

func (*MCPClientSession) GetTextContent(result *mcp.CallToolResult) (string, error)

GetTextContent extracts text content from a tool result

func (*MCPClientSession) InitializeResult added in v0.5.0

func (s *MCPClientSession) InitializeResult() *mcp.InitializeResult

InitializeResult returns the result of the Initialize call.

func (*MCPClientSession) ListResources added in v0.5.1

func (*MCPClientSession) ListTools added in v0.5.1

func (*MCPClientSession) NewSessionManager

func (s *MCPClientSession) NewSessionManager() *SessionManager

NewSessionManager creates a new session manager for multi-session workflows

func (*MCPClientSession) ReadResource

func (s *MCPClientSession) ReadResource(ctx context.Context, uri string) (string, error)

ReadResource reads an MCP resource by URI and returns its text content

func (*MCPClientSession) RunFile

func (s *MCPClientSession) RunFile(ctx context.Context, scriptPath string) (string, error)

RunFile runs a MATLAB file

func (*MCPClientSession) RunTestFile

func (s *MCPClientSession) RunTestFile(ctx context.Context, scriptPath string) (string, error)

RunTestFile runs a MATLAB test file

func (*MCPClientSession) Stderr

func (s *MCPClientSession) Stderr() string

Stderr returns the captured stderr output from the MCP server process. This is useful for debugging test failures.

func (*MCPClientSession) UnmarshalStructuredContent

func (*MCPClientSession) UnmarshalStructuredContent(result *mcp.CallToolResult, target interface{}) error

UnmarshalStructuredContent unmarshals structured content into a target

type SessionManager

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

SessionManager helps manage MATLAB sessions

func (*SessionManager) CleanupSession

func (sm *SessionManager) CleanupSession(ctx context.Context, sessionID int)

CleanupSession stops a MATLAB session for cleanup, ignoring errors if the session is already gone

func (*SessionManager) EvaluateInSession

func (sm *SessionManager) EvaluateInSession(ctx context.Context, sessionID int, code string, projectPath ...string) (string, error)

EvaluateInSession evaluates code in a specific session

func (*SessionManager) ListAvailableMATLABs

func (sm *SessionManager) ListAvailableMATLABs(ctx context.Context) ([]MATLABInfo, error)

ListAvailableMATLABs lists available MATLAB installations

func (*SessionManager) StartSession

func (sm *SessionManager) StartSession(ctx context.Context, matlabRoot ...string) (int, error)

StartSession starts a new MATLAB session

func (*SessionManager) StopSession

func (sm *SessionManager) StopSession(ctx context.Context, sessionID int) error

StopSession stops a MATLAB session

type StderrProvider added in v0.8.0

type StderrProvider interface {
	Stderr() string
}

Jump to

Keyboard shortcuts

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