stdio

package
v0.0.0-...-b198e9d Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultMaxMessageSize = 1024 * 1024

DefaultMaxMessageSize is the default maximum size of a single JSON message (1MB).

Variables

This section is empty.

Functions

This section is empty.

Types

type MessageHandler

type MessageHandler = transport.MessageHandler

MessageHandler is an alias for the transport.MessageHandler type.

type Reader

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

Reader handles reading newline-delimited JSON messages from stdin.

func NewReader

func NewReader(in io.Reader) *Reader

NewReader creates a new Reader for the given input stream.

func NewReaderWithMaxSize

func NewReaderWithMaxSize(in io.Reader, maxSize int) *Reader

NewReaderWithMaxSize creates a new Reader with a custom max message size.

func (*Reader) ReadMessage

func (r *Reader) ReadMessage() ([]byte, error)

ReadMessage reads the next JSON message from the input. Returns io.EOF when there are no more messages.

type Server

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

Server implements the stdio transport for MCP. It reads JSON-RPC messages from stdin and writes responses to stdout.

func NewServer

func NewServer(agentCfg config.AgentConfig, sessionMgr *session.Manager) *Server

NewServer creates a new stdio transport server.

func NewServerWithIO

func NewServerWithIO(agentCfg config.AgentConfig, sessionMgr *session.Manager, stdin io.Reader, stdout io.Writer) *Server

NewServerWithIO creates a new stdio transport server with custom I/O streams. This is primarily useful for testing.

func (*Server) Name

func (s *Server) Name() string

Name returns the transport name.

func (*Server) SetMessageHandler

func (s *Server) SetMessageHandler(h MessageHandler)

SetMessageHandler sets the callback for processing incoming messages.

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start begins reading from stdin and processing messages.

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

Stop gracefully shuts down the server.

type Writer

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

Writer handles thread-safe writes to stdout with newline framing.

func NewWriter

func NewWriter(out io.Writer) *Writer

NewWriter creates a new Writer for the given output stream.

func (*Writer) Write

func (w *Writer) Write(data []byte) error

Write writes a JSON message followed by a newline. It is safe for concurrent use.

Jump to

Keyboard shortcuts

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