Documentation
¶
Overview ¶
Package server is an MCP server of a toolkit namespace's tools, which follows the namespace's tools as they change, and is connected to with a transport, such as one which is in memory, for a client in the same process.
Index ¶
Constants ¶
const MaxChunk = 8 * 1024 * 1024
MaxChunk is the most bytes of a resource's content which are read at once, as a chunk, as its JSON-RPC frame, in base64, is at most the SDK's DefaultMaxLineLength
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Opt ¶ added in v1.7.0
type Opt func(*opt) error
Opt is an option of a server
func WithKeepAlive ¶
WithKeepAlive pings each client at the interval, and closes its session, when it doesn't reply
func WithLogger ¶
WithLogger is where the server logs, such as a tool which can't be served, and what its tools log, as they run, rather than nowhere
func WithTracer ¶
WithTracer traces the calls of the server's tools
func WithVersion ¶ added in v1.7.0
WithVersion is the version of the server, which its clients are told, as they connect, rather than schema.DefaultVersion
func WithWorkspace ¶ added in v1.7.0
WithWorkspace serves the workspace's resources, as well as the namespace's tools: resources/list lists its folders and resources, by the folder in the request's _meta, and resources/read reads them, when it's a workspace.Reader, and the server says it's a workspace, with the experimental capability schema.Capability
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is an MCP server of a namespace's tools, whose name, title and instructions are the namespace's name, description and system prompt
func New ¶
New returns a server of the namespace's tools, as they are, with the options, such as its version, with WithVersion. Run follows its tools, as they change. Returns ErrBadParameter when there's no namespace.
func (*Server) Connect ¶ added in v1.7.0
func (s *Server) Connect(ctx context.Context, transport sdkmcp.Transport) (*sdkmcp.ServerSession, error)
Connect serves a session with the transport, such as stdio, until its client closes it, or it's closed
func (*Server) InMemoryTransport ¶ added in v1.7.0
InMemoryTransport returns the client's end of a new transport in memory, whose server end is connected, so a client in the same process, such as one with client.WithTransport, is connected with it. Each is connected once, so it's called for each connection.
func (*Server) Run ¶ added in v1.7.0
Run follows the namespace's tools, as they change, so its clients are told, until the context is cancelled, when it returns nil, or the namespace's watch fails, when it returns its error. Its tools are also the namespace's as they're listed, or called, whether it runs or not.