Documentation
¶
Overview ¶
Package server provides the MCP server implementation for the ProjectMemory service.
Package server provides the MCP server implementation for the ProjectMemory service.
Index ¶
- Constants
- Variables
- func HandleBadGateway(w http.ResponseWriter, message string, err error)
- func HandleBadRequest(w http.ResponseWriter, message string, err error)
- func HandleError(w http.ResponseWriter, err error)
- func HandleInternalError(w http.ResponseWriter, message string, err error)
- func HandleNotFound(w http.ResponseWriter, message string, err error)
- func HandleUnauthorized(w http.ResponseWriter, message string, err error)
- type ContextToolServer
- type ErrorResponse
- type ErrorWithStatus
- type MCPContextToolServer
Constants ¶
const ( // ErrorCodeInvalidRequest indicates the client sent an invalid request ErrorCodeInvalidRequest = "INVALID_REQUEST" // ErrorCodeInternalError indicates an internal server error ErrorCodeInternalError = "INTERNAL_ERROR" // ErrorCodeAuthenticationError indicates an authentication failure ErrorCodeAuthenticationError = "AUTHENTICATION_ERROR" // ErrorCodeResourceNotFound indicates a requested resource was not found ErrorCodeResourceNotFound = "RESOURCE_NOT_FOUND" // ErrorCodeBadGateway indicates a failure in an upstream service ErrorCodeBadGateway = "BAD_GATEWAY" )
Common error codes
Variables ¶
var ( ErrServerNotInitialized = errors.New("server not initialized") ErrMissingDependencies = errors.New("one or more required dependencies are nil") )
Common server error types
Functions ¶
func HandleBadGateway ¶
func HandleBadGateway(w http.ResponseWriter, message string, err error)
HandleBadGateway handles 502 Bad Gateway errors
func HandleBadRequest ¶
func HandleBadRequest(w http.ResponseWriter, message string, err error)
HandleBadRequest handles 400 Bad Request errors
func HandleError ¶
func HandleError(w http.ResponseWriter, err error)
HandleError handles any error, inspecting its type to determine the appropriate HTTP response
func HandleInternalError ¶
func HandleInternalError(w http.ResponseWriter, message string, err error)
HandleInternalError handles 500 Internal Server Error errors
func HandleNotFound ¶
func HandleNotFound(w http.ResponseWriter, message string, err error)
HandleNotFound handles 404 Not Found errors
func HandleUnauthorized ¶
func HandleUnauthorized(w http.ResponseWriter, message string, err error)
HandleUnauthorized handles 401 Unauthorized errors
Types ¶
type ContextToolServer ¶
type ContextToolServer interface {
// Initialize initializes the server with dependencies and configurations.
Initialize() error
// Start starts the MCP server on the specified transport.
Start() error
// Stop gracefully shuts down the MCP server.
Stop() error
}
ContextToolServer defines the interface for the MCP server that handles context-related tool calls from MCP clients.
type ErrorResponse ¶
type ErrorResponse struct {
Status int `json:"status"`
Message string `json:"message"`
Code string `json:"code,omitempty"`
Details string `json:"details,omitempty"`
}
ErrorResponse represents the structure of error responses sent by the API
type ErrorWithStatus ¶
type ErrorWithStatus struct {
// contains filtered or unexported fields
}
ErrorWithStatus creates an error with an HTTP status code
func NewErrorWithStatus ¶
func NewErrorWithStatus(err error, status int, code, message string) *ErrorWithStatus
NewErrorWithStatus creates a new error with HTTP status code
func (*ErrorWithStatus) Error ¶
func (e *ErrorWithStatus) Error() string
Error returns the error message
func (*ErrorWithStatus) ErrorCode ¶
func (e *ErrorWithStatus) ErrorCode() string
ErrorCode returns the application error code
func (*ErrorWithStatus) Message ¶
func (e *ErrorWithStatus) Message() string
Message returns the client-friendly message
func (*ErrorWithStatus) StatusCode ¶
func (e *ErrorWithStatus) StatusCode() int
StatusCode returns the HTTP status code
func (*ErrorWithStatus) Unwrap ¶
func (e *ErrorWithStatus) Unwrap() error
Unwrap returns the underlying error
type MCPContextToolServer ¶
type MCPContextToolServer struct {
// contains filtered or unexported fields
}
MCPContextToolServer implements the ContextToolServer interface for handling MCP tool calls related to context storage and retrieval.
func NewContextToolServer ¶
func NewContextToolServer(store contextstore.ContextStore, summarizer summarizer.Summarizer, embedder vector.Embedder) *MCPContextToolServer
NewContextToolServer creates a new MCPContextToolServer instance.
func (*MCPContextToolServer) Initialize ¶
func (s *MCPContextToolServer) Initialize() error
Initialize initializes the server with dependencies and configurations.
func (*MCPContextToolServer) Start ¶
func (s *MCPContextToolServer) Start() error
Start starts the MCP server on the specified transport.
func (*MCPContextToolServer) Stop ¶
func (s *MCPContextToolServer) Stop() error
Stop gracefully shuts down the MCP server.
func (*MCPContextToolServer) WithLogger ¶ added in v0.1.3
func (s *MCPContextToolServer) WithLogger(customLogger logx.Logger)
WithLogger sets a custom logger for the server and passes it to the underlying gomcp server.