read_stylesheets
Retrieve CSS stylesheets from a web page. Get all loaded stylesheets or filter by URL to inspect specific styling rules.
Instructions
Read CSS stylesheets loaded on the page. Returns all stylesheets or a specific one by URL.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | No | Specific stylesheet URL to read (returns all if omitted) | |
| tabId | No | Target tab ID (defaults to active tab) | |
| apiKey | No | API key for authentication |
Implementation Reference
- src/tools/devtools-sources.ts:28-48 (handler)The tool handler for 'read_stylesheets' - an MCP tool registration that defines the tool logic. It receives optional 'url', 'tabId', and 'apiKey' parameters, sends a 'read_stylesheets' command via WebSocketBridge, and returns the result as JSON.
server.tool( 'read_stylesheets', 'Read CSS stylesheets loaded on the page. Returns all stylesheets or a specific one by URL.', { url: z.string().optional().describe('Specific stylesheet URL to read (returns all if omitted)'), tabId: z.number().optional().describe('Target tab ID (defaults to active tab)'), apiKey: z.string().optional().describe('API key for authentication'), }, async ({ url, tabId, apiKey }) => { const result = await bridge.sendCommand({ command: 'read_stylesheets', params: { url }, tabId, apiKey, }); if (!result.success) { return { content: [{ type: 'text', text: `Error: ${result.error?.message}` }], isError: true }; } return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] }; } ); - src/tools/devtools-sources.ts:31-35 (schema)Input schema for the 'read_stylesheets' tool: optional url (string), optional tabId (number), optional apiKey (string).
{ url: z.string().optional().describe('Specific stylesheet URL to read (returns all if omitted)'), tabId: z.number().optional().describe('Target tab ID (defaults to active tab)'), apiKey: z.string().optional().describe('API key for authentication'), }, - src/tools/index.ts:12-12 (registration)Registration of the registerDevtoolsSourcesTools function which contains the read_stylesheets tool.
import { registerDevtoolsSourcesTools } from './devtools-sources.js'; - src/tools/index.ts:39-39 (registration)Call to registerDevtoolsSourcesTools which registers the read_stylesheets tool on the server.
registerDevtoolsSourcesTools(server, bridge);