Documentation
¶
Index ¶
- Constants
- func FilterHTMLByFragment(logger *logrus.Logger, htmlContent string, fragment string) (string, error)
- func ProcessContent(logger *logrus.Logger, response *FetchURLResponse, raw bool, fragment string) (string, error)
- type ContentTypeInfo
- type FetchURLRequest
- type FetchURLResponse
- type FetchURLTool
- type MarkdownConverter
- type ParsedURL
- type WebClient
Constants ¶
const ( // DefaultTimeout for HTTP requests DefaultTimeout = 15 * time.Second // UserAgent for web requests UserAgent = "mcp-devtools-fetch/1.0 (AI Assistant Tool)" // MaxContentSize to prevent memory issues (20MB) MaxContentSize = 20 * 1024 * 1024 )
Variables ¶
This section is empty.
Functions ¶
func FilterHTMLByFragment ¶ added in v0.58.0
func FilterHTMLByFragment(logger *logrus.Logger, htmlContent string, fragment string) (string, error)
FilterHTMLByFragment filters HTML content to only include the section identified by the fragment ID and its subsections. For heading elements, this includes all following content until the next heading of the same or higher level. For container elements (like section, div, article), this includes all child content. Returns the filtered HTML or the original content if the fragment is not found.
func ProcessContent ¶
func ProcessContent(logger *logrus.Logger, response *FetchURLResponse, raw bool, fragment string) (string, error)
ProcessContent determines how to process content based on its type
Types ¶
type ContentTypeInfo ¶
ContentTypeInfo represents information about detected content type
func DetectContentType ¶
func DetectContentType(contentType, content string) ContentTypeInfo
DetectContentType analyses the content type and determines how to process it
type FetchURLRequest ¶
type FetchURLRequest struct {
URL string `json:"url"`
MaxLength int `json:"max_length,omitempty"`
StartIndex int `json:"start_index,omitempty"`
Raw bool `json:"raw,omitempty"`
// contains filtered or unexported fields
}
FetchURLRequest represents the parameters for the fetch-url tool
type FetchURLResponse ¶
type FetchURLResponse struct {
ContentType string `json:"content_type,omitempty"`
StatusCode int `json:"status_code,omitempty"`
Content string `json:"content"`
Truncated bool `json:"truncated"`
StartIndex int `json:"start_index"`
EndIndex int `json:"end_index"`
TotalLength int `json:"total_length"`
TotalLines int `json:"total_lines"`
StartLine int `json:"start_line"`
EndLine int `json:"end_line"`
NextChunkPreview string `json:"next_chunk_preview,omitempty"`
RemainingLines int `json:"remaining_lines"`
Message string `json:"message,omitempty"`
}
FetchURLResponse represents the response from the fetch-url tool
type FetchURLTool ¶
type FetchURLTool struct{}
FetchURLTool implements URL fetching with HTML-to-markdown conversion
func (*FetchURLTool) Definition ¶
func (t *FetchURLTool) Definition() mcp.Tool
Definition returns the tool's definition for MCP registration
func (*FetchURLTool) Execute ¶
func (t *FetchURLTool) Execute(ctx context.Context, logger *logrus.Logger, cache *sync.Map, args map[string]any) (*mcp.CallToolResult, error)
Execute executes the fetch-url tool
func (*FetchURLTool) ProvideExtendedInfo ¶ added in v0.22.0
func (t *FetchURLTool) ProvideExtendedInfo() *tools.ExtendedHelp
ProvideExtendedInfo provides detailed usage information for the fetch_url tool
type MarkdownConverter ¶
type MarkdownConverter struct {
// contains filtered or unexported fields
}
MarkdownConverter handles HTML to markdown conversion with custom rules
func NewMarkdownConverter ¶
func NewMarkdownConverter() *MarkdownConverter
NewMarkdownConverter creates a new converter with AI-friendly settings
func (*MarkdownConverter) ConvertToMarkdown ¶
func (c *MarkdownConverter) ConvertToMarkdown(logger *logrus.Logger, htmlContent string) (string, error)
ConvertToMarkdown converts HTML content to clean markdown
type ParsedURL ¶ added in v0.58.0
ParsedURL contains the URL split into components. Fragment is derived from the URL's fragment component (after '#') when present, rather than being exposed as a separate tool parameter.
type WebClient ¶
type WebClient struct {
// contains filtered or unexported fields
}
WebClient handles HTTP requests for fetching web content
func NewWebClient ¶
func NewWebClient() *WebClient
NewWebClient creates a new web client with proper timeouts, context support and proxy configuration
func (*WebClient) FetchContent ¶
func (c *WebClient) FetchContent(ctx context.Context, logger *logrus.Logger, targetURL string) (*FetchURLResponse, error)
FetchContent fetches content from a URL with context support