Documentation
¶
Overview ¶
Package middleware provides HTTP middleware for the application.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthMiddleware ¶
func AuthMiddleware(authManager *auth.Manager) mcp.Middleware
AuthMiddleware creates an MCP middleware for handling authentication. It is intended to inspect incoming requests and use the provided `AuthManager` to verify credentials before passing the request to the next handler.
NOTE: This middleware is currently a placeholder and does not yet perform any authentication. It passes all requests through to the next handler without modification.
Parameters:
- authManager: The authentication manager to be used for authenticating requests.
Returns an `mcp.Middleware` function.
func CORSMiddleware ¶
func CORSMiddleware() mcp.Middleware
CORSMiddleware creates an MCP middleware for handling Cross-Origin Resource Sharing (CORS). It is intended to add the necessary CORS headers to outgoing responses, allowing web browsers to securely make cross-origin requests to the MCP server.
NOTE: This middleware is currently a placeholder and does not yet add any CORS headers. It passes all requests and responses through without modification.
Returns an `mcp.Middleware` function.
func DebugMiddleware ¶
func DebugMiddleware() mcp.Middleware
DebugMiddleware returns a middleware function that logs the full request and response of each MCP method call. This is useful for debugging and understanding the flow of data through the server.
func LoggingMiddleware ¶
func LoggingMiddleware(log *slog.Logger) mcp.Middleware
LoggingMiddleware creates an MCP middleware that logs information about each incoming request. It records the start and completion of each request, including the duration of the handling.
This is useful for debugging and monitoring the flow of requests through the server.
Parameters:
- log: The logger to be used. If `nil`, the default global logger will be used.
Returns an `mcp.Middleware` function.
Types ¶
type CachingMiddleware ¶
type CachingMiddleware struct {
// contains filtered or unexported fields
}
CachingMiddleware is a tool execution middleware that provides caching functionality.
func NewCachingMiddleware ¶
func NewCachingMiddleware(toolManager tool.ManagerInterface) *CachingMiddleware
NewCachingMiddleware creates a new CachingMiddleware.
func (*CachingMiddleware) Execute ¶
func (m *CachingMiddleware) Execute(ctx context.Context, req *tool.ExecutionRequest, next tool.ExecutionFunc) (any, error)
Execute executes the caching middleware.
type IPAllowlistMiddleware ¶
type IPAllowlistMiddleware struct {
// contains filtered or unexported fields
}
IPAllowlistMiddleware restricts access to allowed IP addresses.
func NewIPAllowlistMiddleware ¶
func NewIPAllowlistMiddleware(allowedCIDRs []string) (*IPAllowlistMiddleware, error)
NewIPAllowlistMiddleware creates a new IPAllowlistMiddleware.
func (*IPAllowlistMiddleware) Allow ¶
func (m *IPAllowlistMiddleware) Allow(remoteAddr string) bool
Allow checks if the given remote address is allowed. remoteAddr should be in the form "IP" or "IP:Port".
type RateLimitMiddleware ¶
type RateLimitMiddleware struct {
// contains filtered or unexported fields
}
RateLimitMiddleware is a tool execution middleware that provides rate limiting functionality for upstream services.
func NewRateLimitMiddleware ¶
func NewRateLimitMiddleware(toolManager tool.ManagerInterface) *RateLimitMiddleware
NewRateLimitMiddleware creates a new RateLimitMiddleware.
func (*RateLimitMiddleware) Execute ¶
func (m *RateLimitMiddleware) Execute(ctx context.Context, req *tool.ExecutionRequest, next tool.ExecutionFunc) (any, error)
Execute executes the rate limiting middleware.