Skip to main content
Glama

focus_tab

Switch the active tab to the one identified by its index (from list_tabs) or by a URL substring.

Instructions

Switch the active tab by index (from list_tabs) or by URL substring.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
indexNo
urlContainsNo

Implementation Reference

  • Handler function for focus_tab. Accepts optional 'index' (tab number from list_tabs) or 'urlContains' (URL substring). Iterates all contexts/pages, matches by index or URL substring, brings the matching tab to front, and sets it as the active page. Throws if no match found.
    async function focusTab(args: { index?: number; urlContains?: string }) {
      if (!browser) throw new Error('Not attached.');
      let i = 0;
      for (const ctx of browser.contexts()) {
        for (const p of ctx.pages()) {
          const matchByIndex = args.index !== undefined && i === args.index;
          const matchByUrl = args.urlContains && p.url().includes(args.urlContains);
          if (matchByIndex || matchByUrl) {
            page = p;
            await p.bringToFront().catch(() => {});
            return { url: p.url(), title: await p.title().catch(() => '') };
          }
          i++;
        }
      }
      throw new Error('No matching tab. Try list_tabs first.');
    }
  • Schema definition for the focus_tab tool. Describes the tool and its input schema with two optional properties: 'index' (number) and 'urlContains' (string).
    {
      name: 'focus_tab',
      description: 'Switch the active tab by index (from list_tabs) or by URL substring.',
      inputSchema: {
        type: 'object',
        properties: {
          index: { type: 'number' },
          urlContains: { type: 'string' },
        },
      },
    },
  • src/index.ts:463-463 (registration)
    Registration/dispatch of focus_tab in the CallToolRequestSchema handler. Routes incoming 'focus_tab' calls to the focusTab function with proper type casting.
    case 'focus_tab':    result = await focusTab(args as { index?: number; urlContains?: string }); break;
Behavior2/5

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

No annotations are provided, so the description must carry the burden. It only states the action (switch active tab) but does not disclose behaviors like what happens if index or URL substring is invalid, whether it errors silently, or side effects like changing focus. Minimal transparency.

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?

Single sentence, front-loaded with action and methods. Every word earns its place with no redundancy or filler.

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 simple nature and no output schema, the description is adequate but lacks details on behavior when both params are missing or multiple matches. The robot can infer basic usage from sibling tools but additional context would improve completeness.

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 has 2 parameters with 0% description coverage. The description explains that 'index' comes from list_tabs and 'urlContains' is a substring, adding meaning beyond raw schema. However, it does not specify behavior if both are provided or if neither is provided.

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 switches the active tab and identifies two methods: by index (from list_tabs) or by URL substring. It distinguishes itself from sibling tools like list_tabs (listing) and navigate (URL navigation). However, it does not explicitly mention 'browser tab', which is implied from context.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage after list_tabs to get index or URL, but does not explicitly state when to use this tool versus alternatives like navigate or click. No guidance on when not to use it 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/flying-pisces/mcp-helm'

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