Skip to main content
Glama
jomon003

PlayMCP Browser Automation Server

by jomon003

getStylesheets

Extract all CSS stylesheets from a webpage to analyze styling, debug layout issues, or collect design assets during browser automation.

Instructions

Get all CSS stylesheets from the current page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler function that executes the logic to retrieve stylesheets from the current page using Playwright's page.evaluate, collecting inline styles and external stylesheet URLs.
    async getStylesheets(): Promise<string[]> {
      try {
        if (!this.isInitialized()) {
          throw new Error('Browser not initialized');
        }
        this.log('Getting page stylesheets');
        const stylesheets = await this.state.page?.evaluate(() => {
          const styleElements = Array.from(document.querySelectorAll('style, link[rel="stylesheet"]'));
          return styleElements.map(element => {
            if (element.tagName === 'LINK') {
              const link = element as HTMLLinkElement;
              return `/* External stylesheet: ${link.href} */`;
            }
            return element.textContent || element.innerHTML;
          }).filter(content => content.trim().length > 0);
        });
        this.log('Stylesheets retrieved:', stylesheets?.length);
        return stylesheets || [];
      } catch (error: any) {
        console.error('Get stylesheets error:', error);
        throw new BrowserError('Failed to get stylesheets', 'Check if the page is loaded');
      }
    }
  • Tool schema definition specifying name, description, and empty input schema (no parameters required).
    const GET_STYLESHEETS_TOOL: Tool = {
      name: "getStylesheets",
      description: "Get all CSS stylesheets from the current page",
      inputSchema: {
        type: "object",
        properties: {},
        required: []
      }
    };
  • src/server.ts:714-719 (registration)
    MCP server request handler case that dispatches the tool call to the Playwright controller's getStylesheets method and formats the response.
    case 'getStylesheets': {
      const stylesheets = await playwrightController.getStylesheets();
      return {
        content: [{ type: "text", text: stylesheets.join('\n') }]
      };
    }      case 'getMetaTags': {
  • src/server.ts:527-527 (registration)
    Registration of the tool in the tools object passed to MCP server capabilities.
    getStylesheets: GET_STYLESHEETS_TOOL,
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states what the tool does but doesn't describe how it behaves: e.g., whether it returns raw CSS text, structured data, or URLs; if it's synchronous or asynchronous; or any error conditions. This leaves significant gaps for an agent to understand the tool's operation.

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, clear sentence with no wasted words. It's front-loaded with the core action and resource, making it efficient and easy to parse for an agent.

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 lack of annotations and output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., list of stylesheet URLs, CSS content, or metadata), which is critical for a retrieval tool. This gap makes it harder for an agent to use the tool effectively without trial and error.

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

Parameters4/5

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

The tool has 0 parameters, and the input schema has 100% description coverage (though empty). The description doesn't need to add parameter details, so it meets the baseline of 4 for zero-parameter tools by not introducing confusion or redundancy.

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 verb 'Get' and resource 'CSS stylesheets from the current page', making the purpose unambiguous. However, it doesn't explicitly distinguish this from sibling tools like getScripts or getMetaTags, which follow a similar pattern for different resources.

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 prerequisites (e.g., needing an open browser page), exclusions, or related tools like getPageSource that might overlap in functionality.

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/jomon003/PlayMCP'

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