Documentation
¶
Overview ¶
Package server provides HTTP and stdio transports for MCP.
Package server provides stdio transport for MCP.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPServer ¶
type HTTPServer struct {
// contains filtered or unexported fields
}
HTTPServer provides HTTP transport for MCP.
func NewHTTPServer ¶
func NewHTTPServer(registry *mcp.ToolRegistry, cache *mcp.HashCache, port int) *HTTPServer
NewHTTPServer creates a new HTTP MCP server.
func (*HTTPServer) Port ¶
func (s *HTTPServer) Port() int
Port returns the actual port (may differ from requested if 0).
type JSONRPCError ¶
type JSONRPCError struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}
JSONRPCError represents a JSON-RPC 2.0 error.
type JSONRPCRequest ¶
type JSONRPCRequest struct {
JSONRPC string `json:"jsonrpc"`
ID interface{} `json:"id"`
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
}
JSONRPCRequest represents a JSON-RPC 2.0 request.
type JSONRPCResponse ¶
type JSONRPCResponse struct {
JSONRPC string `json:"jsonrpc"`
ID interface{} `json:"id,omitempty"`
Result interface{} `json:"result,omitempty"`
Error *JSONRPCError `json:"error,omitempty"`
}
JSONRPCResponse represents a JSON-RPC 2.0 response.
type StdioServer ¶
type StdioServer struct {
// contains filtered or unexported fields
}
StdioServer provides stdio transport for MCP.
func NewStdioServer ¶
func NewStdioServer(registry *mcp.ToolRegistry, cache *mcp.HashCache) *StdioServer
NewStdioServer creates a new stdio MCP server.
func NewStdioServerWithStreams ¶
func NewStdioServerWithStreams(registry *mcp.ToolRegistry, cache *mcp.HashCache, in io.Reader, out, err io.Writer) *StdioServer
NewStdioServerWithStreams creates a server with custom I/O streams (for testing).
func (*StdioServer) IsRunning ¶
func (s *StdioServer) IsRunning() bool
IsRunning returns true if the server is running.
func (*StdioServer) LogError ¶
func (s *StdioServer) LogError(format string, args ...interface{})
LogError writes an error message to the error stream.
func (*StdioServer) LogInfo ¶
func (s *StdioServer) LogInfo(format string, args ...interface{})
LogInfo writes an info message to the error stream.
func (*StdioServer) Start ¶
func (s *StdioServer) Start() error
Start begins processing messages from stdin.
type ToolContent ¶
ToolContent represents content in a tool result.