Skip to main content
Glama
BrowserGenie

BrowserGenie MCP Server

by BrowserGenie

modify_css

Apply custom CSS styles to selected page elements using a CSS selector and property-value pairs. Modify colors, display, or any style attribute directly.

Instructions

Modify CSS styles of elements on the page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorYesCSS selector of the element(s) to style
stylesYesObject of CSS property-value pairs (e.g., {"color": "red", "display": "none"})
tabIdNoTarget tab ID (defaults to active tab)
apiKeyNoAPI key for authentication

Implementation Reference

  • The handler function for the 'modify_css' tool. It accepts a CSS selector and a styles object, sends a 'modify_css' command via WebSocket to the browser extension, and returns a success/error message.
    server.tool(
      'modify_css',
      'Modify CSS styles of elements on the page',
      {
        selector: z.string().describe('CSS selector of the element(s) to style'),
        styles: z.record(z.string()).describe('Object of CSS property-value pairs (e.g., {"color": "red", "display": "none"})'),
        tabId: z.number().optional().describe('Target tab ID (defaults to active tab)'),
        apiKey: z.string().optional().describe('API key for authentication'),
      },
      async ({ selector, styles, tabId, apiKey }) => {
        const result = await bridge.sendCommand({
          command: 'modify_css',
          params: { selector, styles },
          tabId,
          apiKey,
        });
        if (!result.success) {
          return { content: [{ type: 'text', text: `Error: ${result.error?.message}` }], isError: true };
        }
        return { content: [{ type: 'text', text: `Applied ${Object.keys(styles).length} style(s) to ${selector}` }] };
      }
    );
  • Input schema for the 'modify_css' tool: selector (string), styles (record of strings), optional tabId (number), optional apiKey (string).
    {
      selector: z.string().describe('CSS selector of the element(s) to style'),
      styles: z.record(z.string()).describe('Object of CSS property-value pairs (e.g., {"color": "red", "display": "none"})'),
      tabId: z.number().optional().describe('Target tab ID (defaults to active tab)'),
      apiKey: z.string().optional().describe('API key for authentication'),
    },
  • Registration function that registers 'modify_css' (and 'modify_html') as MCP tools on the server.
    export function registerDevtoolsModifyTools(server: McpServer, bridge: WebSocketBridge) {
      server.tool(
        'modify_html',
        'Modify DOM elements on the page (set HTML, attributes, or remove elements)',
        {
          selector: z.string().describe('CSS selector of the element to modify'),
          action: z.enum(['setOuterHTML', 'setInnerHTML', 'setAttribute', 'removeAttribute', 'removeNode'])
            .describe('The modification action to perform'),
          value: z.string().optional().describe('New HTML content or attribute value'),
          attributeName: z.string().optional().describe('Attribute name (for setAttribute/removeAttribute)'),
          tabId: z.number().optional().describe('Target tab ID (defaults to active tab)'),
          apiKey: z.string().optional().describe('API key for authentication'),
        },
        async ({ selector, action, value, attributeName, tabId, apiKey }) => {
          const result = await bridge.sendCommand({
            command: 'modify_html',
            params: { selector, action, value, attributeName },
            tabId,
            apiKey,
          });
          if (!result.success) {
            return { content: [{ type: 'text', text: `Error: ${result.error?.message}` }], isError: true };
          }
          return { content: [{ type: 'text', text: `Modified ${selector}: ${action}` }] };
        }
      );
    
      server.tool(
        'modify_css',
        'Modify CSS styles of elements on the page',
        {
          selector: z.string().describe('CSS selector of the element(s) to style'),
          styles: z.record(z.string()).describe('Object of CSS property-value pairs (e.g., {"color": "red", "display": "none"})'),
          tabId: z.number().optional().describe('Target tab ID (defaults to active tab)'),
          apiKey: z.string().optional().describe('API key for authentication'),
        },
        async ({ selector, styles, tabId, apiKey }) => {
          const result = await bridge.sendCommand({
            command: 'modify_css',
            params: { selector, styles },
            tabId,
            apiKey,
          });
          if (!result.success) {
            return { content: [{ type: 'text', text: `Error: ${result.error?.message}` }], isError: true };
          }
          return { content: [{ type: 'text', text: `Applied ${Object.keys(styles).length} style(s) to ${selector}` }] };
        }
      );
    }
  • registerAllTools calls registerDevtoolsModifyTools to register the modify tools (including modify_css).
    registerDevtoolsModifyTools(server, bridge);
Behavior2/5

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

No annotations are provided, so the description must fully disclose behavior. It only says 'modify' without detailing persistence, scope, or side effects.

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

Conciseness4/5

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

The description is a single concise sentence with no redundancy. However, some behavioral details are missing, so not perfect.

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?

For a simple mutation tool, the description covers basic purpose but lacks usage context and behavioral details. It's adequate but not comprehensive given the number of sibling tools.

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 coverage is 100% and descriptions are adequate. The description adds no extra meaning beyond what's in the input schema, meeting baseline expectations.

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

Purpose5/5

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

The description clearly states the action (modify CSS styles) and resource (elements on the page). It effectively distinguishes from siblings like modify_html and get_computed_styles.

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 vs alternatives (e.g., execute_javascript, modify_html), no prerequisites or context.

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/BrowserGenie/mcp'

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