Skip to main content
Glama

get_page_source

Extract complete page source code including HTML, scripts, and styles for web development debugging and analysis.

Instructions

Extrai todo o código fonte da página incluindo scripts, styles e recursos

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
includeScriptsNoIncluir conteúdo de todos os scripts
includeStylesNoIncluir conteúdo de todos os estilos

Implementation Reference

  • Main handler function that implements the get_page_source tool by evaluating the page to extract HTML, scripts, styles, and links.
    export async function handleGetPageSource(args: unknown, currentPage: Page): Promise<ToolResponse> {
      const typedArgs = args as unknown as GetPageSourceArgs;
      const { includeScripts = true, includeStyles = true } = typedArgs;
    
      const sources = await currentPage.evaluate(
        (incScripts: boolean, incStyles: boolean): PageSource => {
          const result: PageSource = {
            html: document.documentElement.outerHTML,
            scripts: [],
            styles: [],
            links: [],
          };
    
          if (incScripts) {
            document.querySelectorAll('script').forEach((script) => {
              result.scripts.push({
                src: script.src || null,
                inline: !script.src,
                content: script.src ? null : script.textContent,
                type: script.type || 'text/javascript',
              });
            });
          }
    
          if (incStyles) {
            document.querySelectorAll('style').forEach((style) => {
              result.styles.push({
                inline: true,
                content: style.textContent || '',
              });
            });
    
            document.querySelectorAll('link[rel="stylesheet"]').forEach((link) => {
              result.styles.push({
                inline: false,
                href: (link as HTMLLinkElement).href,
              });
            });
          }
    
          document.querySelectorAll('link').forEach((link) => {
            result.links.push({
              rel: link.rel,
              href: link.href,
              type: link.type,
            });
          });
    
          return result;
        },
        includeScripts,
        includeStyles
      );
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(sources, null, 2),
          },
        ],
      };
    }
  • MCP tool schema definition including input schema for get_page_source.
    {
      name: 'get_page_source',
      description: 'Extrai todo o código fonte da página incluindo scripts, styles e recursos',
      inputSchema: {
        type: 'object',
        properties: {
          includeScripts: {
            type: 'boolean',
            description: 'Incluir conteúdo de todos os scripts',
            default: true,
          },
          includeStyles: {
            type: 'boolean',
            description: 'Incluir conteúdo de todos os estilos',
            default: true,
          },
        },
      },
    },
  • src/index.ts:91-94 (registration)
    Runtime dispatch/registration in the main server handler switch statement.
    case 'get_page_source': {
      const currentPage = await initBrowser();
      return await handleGetPageSource(args, currentPage);
    }
  • TypeScript interface defining input arguments for the handler.
    export interface GetPageSourceArgs {
      includeScripts?: boolean;
      includeStyles?: boolean;
    }
  • TypeScript interface defining the output structure returned by the handler.
    export interface PageSource {
      html: string;
      scripts: Array<{
        src: string | null;
        inline: boolean;
        content: string | null;
        type: string;
      }>;
      styles: Array<{
        inline: boolean;
        content?: string;
        href?: string;
      }>;
      links: Array<{
        rel: string;
        href: string;
        type: string;
      }>;
    }
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 states what is extracted (source code, scripts, styles, resources) but doesn't cover important traits like whether this is a read-only operation, potential performance impacts, network dependencies, or output format (e.g., raw HTML string). For a tool with zero annotation coverage, 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 in Portuguese that directly states the tool's function. It's front-loaded with the core purpose and includes relevant details (scripts, styles, resources) without unnecessary elaboration. Every word earns its place, making it highly concise and well-structured.

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

Completeness3/5

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

Given the tool's moderate complexity (extracting page source with optional inclusions), no annotations, and no output schema, the description is minimally adequate. It covers what is extracted but lacks details on behavioral traits, usage context, or return values. It meets a basic threshold but has clear gaps, especially in guiding the agent on how and when to invoke it effectively.

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?

Schema description coverage is 100%, with both parameters (includeScripts and includeStyles) well-documented in the schema. The description adds no specific parameter information beyond implying that scripts and styles are included by default. Since the schema already provides full coverage, the baseline score of 3 is appropriate, as the description doesn't add meaningful semantics beyond what's in the structured data.

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: 'Extrai todo o código fonte da página incluindo scripts, styles e recursos' (Extracts all page source code including scripts, styles, and resources). It specifies the verb (extract) and resource (page source code) with scope details. However, it doesn't explicitly differentiate from sibling tools like get_dom or get_page_info, which might also retrieve page-related data.

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 when this tool is appropriate (e.g., for full HTML extraction vs. DOM structure) or when to prefer siblings like get_dom (for parsed DOM) or get_page_info (for metadata). Usage is implied by the purpose but lacks explicit context or exclusions.

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

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/EmmanuelBarbosaMonteiro/mcp-server-browser'

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