modelcontextprotocol / modelcontextprotocol/servers

Implement Mechanism to Exclude Specific <div> Elements by ID or Class Name in Fetch MCP Server

Open
#841 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TypeScript
Stars
90.5k
Forks
11.7k
Avg merge
2d 2h
Merged PRs (30d)
5

Description

Description:
We propose enhancing the Fetch MCP Server by introducing a feature that allows users to exclude certain

elements from processing, based on their id or class attributes. This functionality would grant users finer control over the content fetched, particularly in scenarios where specific sections of a webpage are irrelevant or detrimental to the intended data extraction.

Problem Statement:
Currently, when fetching content from webpages with extensive sidebars or navigation menus—such as a lengthy index on the left side—the server retrieves these sections in large chunks (e.g., 20,000 tokens at a time). This can lead to inefficiencies, as large language models (LLMs) may process these sizable, non-essential sections first and prematurely determine that the website is unsuitable for the query, thereby diverting to alternative approaches. This behavior hampers the effectiveness of data retrieval and processing, especially when the main content is overshadowed by voluminous ancillary sections.

Use Case:
Consider a webpage where the left sidebar contains an extensive index with numerous items, each enclosed within

elements with specific ids or class names. A user interested solely in the main content would benefit from the ability to exclude these sidebar elements during the fetching process, ensuring that the LLM focuses on the pertinent information without being sidetracked by the irrelevant index items.

Proposed Solution:
Introduce a configuration option within the Fetch MCP Server that enables users to specify a list of ids and/or class names corresponding to

elements they wish to exclude from processing. The server would then bypass these elements during the fetching phase. This could be implemented through:
1. Configuration File: Allow users to define the ids and class names to exclude within the server’s configuration file.
2. API Parameters: Introduce API parameters that accept arrays of ids and class names to exclude during a fetch request.

Benefits:
Enhanced Data Relevance: By excluding non-essential

elements, the fetched content becomes more focused on the main subject matter, improving the quality of data processed by LLMs. 
Optimized Token Utilization: Reducing the amount of irrelevant content helps in staying within token limits of LLMs, thereby preventing premature termination of processing due to token overflows. 
Improved Processing Efficiency: With less extraneous data to handle, the overall efficiency of data processing workflows is enhanced, leading to faster and more accurate outcomes.

Potential Challenges:
Complexity in Implementation: Accurately identifying and excluding specified

elements without disrupting the overall structure of the fetched content may require sophisticated parsing mechanisms.
User Configuration Errors: Incorrectly specified ids or class names could lead to unintended exclusions, necessitating robust validation and clear documentation to guide users in configuring exclusions appropriately.

References:
The need to manage large content sections during data processing with LLMs has been discussed in various forums. For instance, strategies to handle large HTML documents for LLMs with limited token sizes have been explored, highlighting the importance of content segmentation to optimize processing efficiency. 

Conclusion:
Implementing a feature to exclude specific

elements by id or class name in the Fetch MCP Server would significantly enhance its flexibility and usability. It would empower users to tailor the data fetching process to their specific needs, ensuring that LLMs process only relevant content, thereby improving the overall effectiveness of data retrieval and processing workflows.

Thank you for considering this feature request.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the Fetch MCP Server and its existing fetch configuration and API entry points, then trace how fetched HTML is parsed and processed. Determine how exclusion lists should be supplied and applied to div elements, including validation behavior. Done means users can specify IDs or class names and the resulting fetch omits the matching sections without disrupting other content.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.