Skip to main content
Glama
qpd-v

MCP Web Research Server

by qpd-v

visit_page

Extract webpage content by visiting a specified URL on the MCP Web Research Server, enabling real-time data retrieval for web research.

Instructions

Visit a webpage and extract its content

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesURL to visit

Implementation Reference

  • Main handler for the 'visit_page' tool: validates URL, launches browser page if needed, navigates safely, extracts title and markdown content, returns JSON result.
    case 'visit_page': {
        const args = request.params.arguments as unknown as VisitPageArgs;
        if (!args?.url) {
            throw new McpError(ErrorCode.InvalidParams, 'URL is required');
        }
    
        if (!isValidUrl(args.url)) {
            throw new McpError(
                ErrorCode.InvalidParams,
                `Invalid URL: ${args.url}. Only http and https protocols are supported.`
            );
        }
    
        const page = await ensureBrowser();
        try {
            await safePageNavigation(page, args.url);
            const title = await page.title();
            const content = await extractContentAsMarkdown(page);
    
            return {
                content: [
                    {
                        type: 'text',
                        text: JSON.stringify({
                            url: args.url,
                            title,
                            content
                        }, null, 2)
                    }
                ]
            };
        } catch (error) {
            throw new McpError(
                ErrorCode.InternalError,
                `Failed to visit page: ${(error as Error).message}`
            );
        }
    }
  • src/index.ts:149-161 (registration)
    Registers the 'visit_page' tool in the listTools response, including name, description, and input schema.
        name: 'visit_page',
        description: 'Visit a webpage and extract its content',
        inputSchema: {
            type: 'object',
            properties: {
                url: {
                    type: 'string',
                    description: 'URL to visit'
                }
            },
            required: ['url']
        }
    }
  • TypeScript interface defining the input shape for visit_page arguments, used for type casting in handler.
    interface VisitPageArgs {
        url: string;
    }
  • Helper function to extract main content from the webpage and convert it to clean Markdown using TurndownService.
    async function extractContentAsMarkdown(page: Page): Promise<string> {
        const html = await page.evaluate(() => {
            // Try standard content containers first
            const contentSelectors = [
                'main',
                'article',
                '[role="main"]',
                '#content',
                '.content',
                '.main',
                '.post',
                '.article'
            ];
    
            for (const selector of contentSelectors) {
                const element = document.querySelector(selector);
                if (element) {
                    return element.outerHTML;
                }
            }
    
            // Fallback to cleaning full body content
            const body = document.body;
            const elementsToRemove = [
                'header', 'footer', 'nav',
                '[role="navigation"]', 'aside',
                '.sidebar', '[role="complementary"]',
                '.nav', '.menu', '.header',
                '.footer', '.advertisement',
                '.ads', '.cookie-notice'
            ];
    
            elementsToRemove.forEach(sel => {
                body.querySelectorAll(sel).forEach(el => el.remove());
            });
    
            return body.outerHTML;
        });
    
        if (!html) {
            return '';
        }
    
        try {
            const markdown = turndownService.turndown(html);
            return markdown
                .replace(/\n{3,}/g, '\n\n')
                .replace(/^- $/gm, '')
                .replace(/^\s+$/gm, '')
                .trim();
        } catch (error) {
            console.error('Error converting HTML to Markdown:', error);
            return html;
        }
    }
  • Helper function for safe navigation to the URL with timeout, checks for bot protection and suspicious indicators.
    async function safePageNavigation(page: Page, url: string): Promise<void> {
        await page.goto(url, {
            waitUntil: 'domcontentloaded',
            timeout: 10000 // 10 second timeout
        });
    
        // Quick check for bot protection or security challenges
        const validation = await page.evaluate(() => {
            const botProtectionExists = [
                '#challenge-running',
                '#cf-challenge-running',
                '#px-captcha',
                '#ddos-protection',
                '#waf-challenge-html'
            ].some(selector => document.querySelector(selector));
    
            const suspiciousTitle = [
                'security check',
                'ddos protection',
                'please wait',
                'just a moment',
                'attention required'
            ].some(phrase => document.title.toLowerCase().includes(phrase));
    
            return {
                botProtection: botProtectionExists,
                suspiciousTitle,
                title: document.title
            };
        });
    
        if (validation.botProtection) {
            throw new Error('Bot protection detected');
        }
    
        if (validation.suspiciousTitle) {
            throw new Error(`Suspicious page title detected: "${validation.title}"`);
        }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'visit a webpage and extract its content', which implies a read operation, but doesn't specify details like authentication needs, rate limits, error handling, or what 'extract content' entails (e.g., HTML, text, metadata). For a tool with no annotations, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's function without unnecessary words. It is front-loaded with the core action ('visit a webpage') and purpose ('extract its content'), making it easy to understand quickly. Every part of the sentence earns its place by conveying essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a web interaction tool with potential behavioral nuances) and the lack of annotations and output schema, the description is incomplete. It doesn't cover what 'extract content' means in terms of output format, error cases, or limitations. For a tool that interacts with external webpages, more context is needed to ensure proper usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with the 'url' parameter clearly documented as 'URL to visit'. The description adds no additional meaning beyond this, as it doesn't elaborate on URL format constraints or extraction specifics. With high schema coverage, the baseline score of 3 is appropriate, as the description doesn't compensate but doesn't need to given the schema's clarity.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('visit') and resource ('webpage'), and specifies the action ('extract its content'). However, it doesn't differentiate this tool from potential sibling tools like 'deep_research' or 'parallel_search', which might have overlapping functionality. The description is not tautological but lacks sibling distinction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention any context, prerequisites, or exclusions, and doesn't reference sibling tools like 'deep_research' or 'parallel_search' that might be related. Usage is implied only by the tool's name and description, with no explicit guidelines.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/qpd-v/mcp-DEEPwebresearch'

If you have feedback or need assistance with the MCP directory API, please join our Discord server