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,

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