Documentation
¶
Index ¶
- func APIKeyAuthMiddleware(validAPIKey string, next http.Handler, logger *slog.Logger) http.Handler
- func LoggingMiddleware(logger *slog.Logger, next http.Handler) http.Handler
- func SecurityHeadersMiddleware(next http.Handler) http.Handler
- func SetupLogger(level string) *slog.Logger
- type Config
- type RESTHandler
- type SearchResult
- type SearchSummary
- type WebFetchParams
- type WebFetchResponse
- type WebSearchParams
- type WebSearchResponse
- type WebServer
- func (s *WebServer) AvailableEngines() []string
- func (s *WebServer) CreateMcpServer() *server.MCPServer
- func (s *WebServer) HandleWebFetch(ctx context.Context, params WebFetchParams) (*WebFetchResponse, error)
- func (s *WebServer) HandleWebSearch(ctx context.Context, params WebSearchParams) (*WebSearchResponse, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func APIKeyAuthMiddleware ¶ added in v0.2.0
func LoggingMiddleware ¶ added in v0.2.0
func SecurityHeadersMiddleware ¶ added in v0.2.0
func SetupLogger ¶ added in v0.2.0
Types ¶
type Config ¶
type Config struct {
SearchXNGURL string `mapstructure:"searchxng_url" envconfig:"SEARCHXNG_URL"` // SearXNG base URL (e.g., https://searchx.ng)
GoogleAPIKey string `mapstructure:"google_api_key" envconfig:"GOOGLE_API_KEY"` // Google Custom Search API key
GoogleCX string `mapstructure:"google_cx" envconfig:"GOOGLE_CX"` // Google Search Engine ID
BingAPIKey string `mapstructure:"bing_api_key" envconfig:"BING_API_KEY"` // Bing Search API key
BraveAPIKey string `mapstructure:"brave_api_key" envconfig:"BRAVE_API_KEY"` // Brave Search API key
MaxResults int `mapstructure:"max_results" envconfig:"MAX_RESULTS"` // Default max results (default: 10)
DefaultEngine string `mapstructure:"default_engine" envconfig:"DEFAULT_ENGINE"` // Default search engine
ListenAddr string `mapstructure:"listen_addr" envconfig:"LISTEN_ADDR"` // HTTP listen address
URIPrefix string `mapstructure:"uri_prefix" envconfig:"URI_PREFIX"` // URI prefix for HTTP endpoints
LogLevel string `mapstructure:"log_level" envconfig:"LOG_LEVEL"` // Log level: debug, info, warn, error (default: info)
APIKey string `mapstructure:"api_key" envconfig:"API_KEY"` // API Key for HTTP endpoint authentication
DisableSSE bool `mapstructure:"disable_sse" envconfig:"DISABLE_SSE"` // Disable SSE endpoint (default: false)
}
Config for the web search server. Can be loaded from environment variables using ProcessConfig. Supports configuration from file (~/.webpawm/config.json) and environment variables.
type RESTHandler ¶ added in v0.3.2
type RESTHandler struct {
// contains filtered or unexported fields
}
RESTHandler provides plain JSON HTTP endpoints for web search and fetch.
func NewRESTHandler ¶ added in v0.3.2
func NewRESTHandler(srv *WebServer) *RESTHandler
NewRESTHandler creates a new REST handler wrapping the given WebServer.
func (*RESTHandler) HandleEngines ¶ added in v0.3.2
func (h *RESTHandler) HandleEngines(w http.ResponseWriter, r *http.Request)
HandleEngines handles GET /api/engines
func (*RESTHandler) HandleFetch ¶ added in v0.3.2
func (h *RESTHandler) HandleFetch(w http.ResponseWriter, r *http.Request)
HandleFetch handles POST /api/fetch
func (*RESTHandler) HandleHealth ¶ added in v0.3.2
func (h *RESTHandler) HandleHealth(w http.ResponseWriter, r *http.Request)
HandleHealth handles GET /api/health
func (*RESTHandler) HandleSearch ¶ added in v0.3.2
func (h *RESTHandler) HandleSearch(w http.ResponseWriter, r *http.Request)
HandleSearch handles POST /api/search
type SearchResult ¶ added in v0.2.0
type SearchSummary ¶ added in v0.2.0
type SearchSummary struct {
TotalRawResults int `json:"total_raw_results"`
TotalUniqueResults int `json:"total_unique_results"`
OriginalQuery string `json:"original_query"`
SearchQueries []string `json:"search_queries"`
EnginesUsed []string `json:"engines_used"`
SearchDepth string `json:"search_depth"`
}
type WebFetchParams ¶ added in v0.2.0
type WebFetchParams struct {
URL string `json:"url" jsonschema:"URL of the website to fetch"`
MaxLength int `json:"max_length,omitempty" jsonschema:"Maximum number of characters to return (default: 5000)"`
StartIndex int `json:"start_index,omitempty" jsonschema:"Start content from this character index (default: 0)"`
Raw bool `json:"raw,omitempty" jsonschema:"If true, returns the raw HTML including <script> and <style> blocks (default: false)"`
}
WebFetchParams represents the parameters for web_fetch tool
type WebFetchResponse ¶ added in v0.2.0
type WebSearchParams ¶
type WebSearchParams struct {
Query string `json:"query" jsonschema:"The search query"`
Engine string `json:"engine,omitempty" jsonschema:"Single search engine to use (mutually exclusive with engines)"`
Engines []string `json:"engines,omitempty" jsonschema:"List of search engines to use (mutually exclusive with engine)"`
MaxResults int `json:"max_results,omitempty" jsonschema:"Maximum number of results to return (default: 10)"`
Language string `json:"language,omitempty" jsonschema:"Language code for search results (e.g., 'en', 'zh')"`
ArxivCategory string `json:"arxiv_category,omitempty" jsonschema:"Arxiv category for academic paper search (e.g., 'cs.AI', 'math.CO')"`
SearchDepth string `` /* 135-byte string literal not displayed */
IncludeAcademic bool `json:"include_academic,omitempty" jsonschema:"Include academic papers from Arxiv (default: false)"`
AutoQueryExpand bool `` /* 145-byte string literal not displayed */
AutoDeduplicate bool `json:"auto_deduplicate,omitempty" jsonschema:"Automatically deduplicate results by URL (default: true)"`
}
WebSearchParams represents the parameters for web_search tool
type WebSearchResponse ¶ added in v0.2.0
type WebSearchResponse struct {
TotalResults int `json:"total_results"`
Summary SearchSummary `json:"summary"`
Results []SearchResult `json:"results"`
SearchTime string `json:"search_time"`
}
type WebServer ¶ added in v0.2.0
type WebServer struct {
// contains filtered or unexported fields
}
WebServer represents the MCP web search server
func NewWebServer ¶ added in v0.2.0
NewWebServer creates a new web search server
func (*WebServer) AvailableEngines ¶ added in v0.3.2
AvailableEngines returns a list of available search engine names.
func (*WebServer) CreateMcpServer ¶ added in v0.2.0
CreateMcpServer creates the MCP server with tools
func (*WebServer) HandleWebFetch ¶ added in v0.3.2
func (s *WebServer) HandleWebFetch(ctx context.Context, params WebFetchParams) (*WebFetchResponse, error)
func (*WebServer) HandleWebSearch ¶ added in v0.3.2
func (s *WebServer) HandleWebSearch(ctx context.Context, params WebSearchParams) (*WebSearchResponse, error)
HandleWebSearch handles the unified web_search tool