Skip to main content
@mcp-b/extension-tools wraps Chrome Extension APIs as MCP tool classes. Each API is a dedicated class that handles permission checking, error formatting, and tool registration against an McpServer instance.
npm: @mcp-b/extension-tools
license: MIT
dependencies: @mcp-b/smart-dom-reader, @mcp-b/webmcp-ts-sdk, zod
peer: @types/chrome (dev)

Installation

npm install @mcp-b/extension-tools @modelcontextprotocol/sdk

Minimal example

Usage

Register tool classes in your Chrome extension’s background script:
import { TabsApiTools, BookmarksApiTools, StorageApiTools } from '@mcp-b/extension-tools';
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';

const server = new McpServer({
  name: 'chrome-extension-server',
  version: '1.0.0',
});

const tabsTools = new TabsApiTools(server, {
  listActiveTabs: true,
  createTab: true,
  closeTabs: true,
});
tabsTools.register();

const bookmarksTools = new BookmarksApiTools(server, {
  getBookmarks: true,
  createBookmark: true,
});
bookmarksTools.register();
Each tool class constructor takes two arguments:
  1. An McpServer instance
  2. An options object where each key corresponds to a tool method. Set a key to true to register that tool, or false (or omit it) to skip it.

BaseApiTools

All API tool classes extend BaseApiTools<TOptions>:
abstract class BaseApiTools<TOptions> {
  protected abstract apiName: string;

  constructor(server: McpServer, options: TOptions);

  abstract checkAvailability(): ApiAvailability;
  abstract registerTools(): void;

  register(): void;

  protected shouldRegisterTool(toolName: string): boolean;
  protected formatError(error: unknown): CallToolResult;
  protected formatSuccess(message: string, data?: unknown): CallToolResult;
  protected formatJson(data: unknown): CallToolResult;
}
MethodDescription
register()Checks API availability, then calls registerTools() if available
checkAvailability()Returns { available: boolean, message: string }
shouldRegisterTool(name)Returns false if the option for that tool is explicitly false
formatError(error)Wraps an error into a structured CallToolResult with isError: true
formatSuccess(message, data?)Returns a success CallToolResult with optional JSON data

Available API tool classes (62)

Each class name follows the pattern <ApiName>ApiTools. The table below lists all implemented classes grouped by category.

Core browser

ClassChrome PermissionDescription
TabsApiToolstabsCreate, update, query, close, group, move tabs
WindowsApiTools(none)Control browser windows
TabGroupsApiToolstabGroupsManage tab groups
BookmarksApiToolsbookmarksCRUD operations on bookmarks
HistoryApiToolshistorySearch and manage browsing history
SessionsApiToolssessionsQuery and restore browser sessions
TopSitesApiToolstopSitesAccess most-visited sites
ReadingListApiToolsreadingListAccess the reading list

Content and scripting

ClassChrome PermissionDescription
ScriptingApiToolsscriptingExecute scripts and inject CSS
UserScriptsApiToolsuserScriptsExecute user scripts
DomApiTools(none)Access DOM from extensions
ContentSettingsApiToolscontentSettingsManage content settings
DeclarativeContentApiToolsdeclarativeContentTake actions based on page content

Storage and data

ClassChrome PermissionDescription
StorageApiToolsstorageGet, set, remove, clear extension storage (local, sync, session)
CookiesApiToolscookiesManage browser cookies
BrowsingDataApiToolsbrowsingDataClear browsing data

Network

ClassChrome PermissionDescription
WebRequestApiToolswebRequestIntercept and modify requests
WebNavigationApiToolswebNavigationMonitor web navigation events
DeclarativeNetRequestApiToolsdeclarativeNetRequestModify network requests declaratively
ProxyApiToolsproxyManage proxy settings

Downloads and capture

ClassChrome PermissionDescription
DownloadsApiToolsdownloadsControl file downloads
PageCaptureApiToolspageCaptureSave pages as MHTML
TabCaptureApiToolstabCaptureCapture tab media streams
DesktopCaptureApiToolsdesktopCaptureCapture desktop content

UI and interaction

ClassChrome PermissionDescription
NotificationsApiToolsnotificationsCreate system notifications
OmniboxApiTools(none)Customize the address bar
ContextMenusApiToolscontextMenusCreate context menu items
SidePanelApiToolssidePanelControl the side panel
CommandsApiTools(none)Manage keyboard shortcuts

DevTools

ClassChrome PermissionDescription
DevtoolsInspectedWindowApiTools(none)Interact with inspected window
DevtoolsNetworkApiTools(none)Retrieve network information
DevtoolsPanelsApiTools(none)Create DevTools panels

Identity and auth

ClassChrome PermissionDescription
IdentityApiToolsidentityOAuth2 authentication
WebAuthenticationProxyApiToolswebAuthenticationProxyWeb authentication proxy
CertificateProviderApiToolscertificateProviderProvide certificates for TLS
PlatformKeysApiToolsplatformKeysPlatform-specific keys

System

ClassChrome PermissionDescription
AlarmsApiToolsalarmsSet and manage alarms
IdleApiToolsidleDetect idle state
PowerApiToolspowerPower management
SystemCpuApiToolssystem.cpuQuery CPU information
SystemMemoryApiToolssystem.memoryGet memory information
SystemStorageApiToolssystem.storageQuery storage devices
SystemLogApiToolssystemLogAdd system log entries (ChromeOS)

Extension management

ClassChrome PermissionDescription
RuntimeApiTools(none)Access extension runtime information
ExtensionApiTools(none)Extension utilities
ManagementApiToolsmanagementManage installed extensions
PermissionsApiTools(none)Request optional permissions at runtime
OffscreenApiToolsoffscreenManage offscreen documents

Media and output

ClassChrome PermissionDescription
AudioApiToolsaudioAudio device management (ChromeOS)
TtsApiToolsttsText-to-speech
TtsEngineApiToolsttsEngineImplement a TTS engine
FontSettingsApiToolsfontSettingsManage font settings
PrintingApiToolsprintingPrint documents (ChromeOS)
PrintingMetricsApiToolsprintingMetricsPrinting metrics (ChromeOS)

Internationalization and messaging

ClassChrome PermissionDescription
I18nApiTools(none)Internationalization utilities
GcmApiToolsgcmGoogle Cloud Messaging
InstanceIDApiTools(none)Instance ID operations
SearchApiToolssearchSearch via default provider

Enterprise and platform

ClassChrome PermissionDescription
EnterpriseDeviceAttributesApiTools(policy required)Access enterprise device attributes
EnterpriseHardwarePlatformApiTools(policy required)Access enterprise hardware info
EnterpriseNetworkingAttributesApiTools(policy required)Access enterprise network attributes
EnterprisePlatformKeysApiTools(policy required)Enterprise platform keys
LoginStateApiToolsloginStateRead login state (ChromeOS)
VpnProviderApiToolsvpnProviderImplement VPN client (ChromeOS)
WallpaperApiToolswallpaperSet wallpaper (ChromeOS)
DocumentScanApiToolsdocumentScanScan documents (ChromeOS)
InputImeApiTools(none)Input method editor (ChromeOS)
FileBrowserHandlerApiToolsfileBrowserHandlerHandle file browser events (ChromeOS)
FileSystemProviderApiToolsfileSystemProviderProvide file systems (ChromeOS)
DebuggerApiToolsdebuggerDebug network and JavaScript

DOM extraction

ClassChrome PermissionDescription
DomExtractionToolsscriptingToken-efficient DOM extraction using @mcp-b/smart-dom-reader

Chrome API registry

The ChromeApi enum and CHROME_API_REGISTRY constant map every Chrome Extension API to its metadata:
interface ChromeApiMetadata {
  minChromeVersion?: number;
  platform: 'all' | 'chromeos';
  channel: 'stable' | 'dev';
  manifestVersions: (2 | 3)[];
  requiresPolicy: boolean;
  foregroundOnly: boolean;
  contexts: ('background' | 'content' | 'devtools' | 'all')[];
  namespace: string;
}
Helper functions:
FunctionDescription
isApiAvailable(api, context, manifestVersion, platform?, chromeVersion?)Check if an API is available in the current context
getAvailableApis(context, manifestVersion, platform?, chromeVersion?)Get all available APIs for a context
getChromeApiReference(api)Get the runtime chrome.* object for an API

Permission requirements

Declare required permissions in your extension’s manifest.json. APIs like i18n, runtime, and extension work without explicit permissions. Enterprise APIs require force-install via enterprise policy.
{
  "manifest_version": 3,
  "permissions": ["tabs", "bookmarks", "storage", "scripting"],
  "host_permissions": ["<all_urls>"]
}

APIs under development (12)

The following APIs are not yet implemented: AccessibilityFeatures, Action, DevtoolsPerformance, DevtoolsRecorder, Dns, Events, ExtensionTypes, PrinterProvider, Privacy, Processes, SystemDisplay, Types.