Skip to main content
Glama

Chrome MCP Server

window.tsβ€’1.47 kB
import { createErrorResponse, ToolResult } from '@/common/tool-handler'; import { BaseBrowserToolExecutor } from '../base-browser'; import { TOOL_NAMES } from 'chrome-mcp-shared'; class WindowTool extends BaseBrowserToolExecutor { name = TOOL_NAMES.BROWSER.GET_WINDOWS_AND_TABS; async execute(): Promise<ToolResult> { try { const windows = await chrome.windows.getAll({ populate: true }); let tabCount = 0; const structuredWindows = windows.map((window) => { const tabs = window.tabs?.map((tab) => { tabCount++; return { tabId: tab.id || 0, url: tab.url || '', title: tab.title || '', active: tab.active || false, }; }) || []; return { windowId: window.id || 0, tabs: tabs, }; }); const result = { windowCount: windows.length, tabCount: tabCount, windows: structuredWindows, }; return { content: [ { type: 'text', text: JSON.stringify(result), }, ], isError: false, }; } catch (error) { console.error('Error in WindowTool.execute:', error); return createErrorResponse( `Error getting windows and tabs information: ${error instanceof Error ? error.message : String(error)}`, ); } } } export const windowTool = new WindowTool();

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/haithemobeidi/mcp-chrome'

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