Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/tools/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
truncationFooter,
} from '../utils/response-helpers.js';
import { saveOutput } from '../utils/save-output.js';
import { defineModule } from './module.js';
import { defineModule, type ToolDefinition } from './module.js';
import type { McpToolResponse } from '../types/common.js';

export const listConsoleMessagesTool = {
Expand Down Expand Up @@ -63,7 +63,7 @@ export const listConsoleMessagesTool = {
},
},
},
};
} satisfies ToolDefinition;

export const clearConsoleMessagesTool = {
name: 'clear_console_messages',
Expand All @@ -75,7 +75,7 @@ export const clearConsoleMessagesTool = {
type: 'object',
properties: {},
},
};
} satisfies ToolDefinition;

const DEFAULT_LIMIT = 50;

Expand Down
14 changes: 7 additions & 7 deletions src/tools/debugging.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { successResponse, errorResponse } from '../utils/response-helpers.js';
import { compareVersions } from '../utils/version.js';
import { remoteValueToNative } from '../utils/remote-value.js';
import { defineModule } from './module.js';
import { defineModule, type ToolDefinition } from './module.js';
import type { McpToolResponse } from '../types/common.js';

const MIN_VERSION = '153';
Expand Down Expand Up @@ -34,7 +34,7 @@ export const enableDebuggerTool = {
readOnlyHint: false,
},
inputSchema: { type: 'object', properties: {} },
};
} satisfies ToolDefinition;

export const listScriptsTool = {
name: 'list_scripts',
Expand All @@ -44,7 +44,7 @@ export const listScriptsTool = {
readOnlyHint: true,
},
inputSchema: { type: 'object', properties: {} },
};
} satisfies ToolDefinition;

export const getScriptSourceTool = {
name: 'get_script_source',
Expand All @@ -60,7 +60,7 @@ export const getScriptSourceTool = {
},
required: ['scriptUrl'],
},
};
} satisfies ToolDefinition;

export const setLogpointTool = {
name: 'set_logpoint',
Expand All @@ -81,7 +81,7 @@ export const setLogpointTool = {
},
required: ['url', 'line', 'expression'],
},
};
} satisfies ToolDefinition;

export const removeLogpointTool = {
name: 'remove_logpoint',
Expand All @@ -96,7 +96,7 @@ export const removeLogpointTool = {
},
required: ['logpoint'],
},
};
} satisfies ToolDefinition;

export const getLogpointResultsTool = {
name: 'get_logpoint_results',
Expand All @@ -111,7 +111,7 @@ export const getLogpointResultsTool = {
},
required: ['logpoint'],
},
};
} satisfies ToolDefinition;

// ============================================================================
// Handlers
Expand Down
14 changes: 7 additions & 7 deletions src/tools/downloads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { successResponse, errorResponse, jsonResponse } from '../utils/response-helpers.js';
import { defineModule } from './module.js';
import { defineModule, type ToolDefinition } from './module.js';
import type { McpToolResponse } from '../types/common.js';

// Tool definitions
Expand All @@ -15,7 +15,7 @@ export const listDownloadsTool = {
readOnlyHint: true,
},
inputSchema: {
type: 'object' as const,
type: 'object',
properties: {
status: {
type: 'string',
Expand All @@ -37,23 +37,23 @@ export const listDownloadsTool = {
},
},
},
};
} satisfies ToolDefinition;

export const clearDownloadsTool = {
name: 'clear_downloads',
description: 'Clear the tracked downloads buffer.',
inputSchema: {
type: 'object' as const,
type: 'object',
properties: {},
},
};
} satisfies ToolDefinition;

export const setDownloadBehaviorTool = {
name: 'set_download_behavior',
description:
'Control how downloads are handled: allow (save silently to the default download directory), deny (cancel), or reset to default. Avoids the native save-file dialog. Requires a recent Firefox.',
inputSchema: {
type: 'object' as const,
type: 'object',
properties: {
behavior: {
type: 'string',
Expand All @@ -64,7 +64,7 @@ export const setDownloadBehaviorTool = {
},
required: ['behavior'],
},
};
} satisfies ToolDefinition;

// Tool handlers
export async function handleListDownloads(args: unknown): Promise<McpToolResponse> {
Expand Down
8 changes: 4 additions & 4 deletions src/tools/firefox-management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { readFileSync, existsSync, statSync } from 'node:fs';
import { errorResponse, successResponse } from '../utils/response-helpers.js';
import { defineModule } from './module.js';
import { defineModule, type ToolDefinition } from './module.js';

// ============================================================================
// Tool: get_firefox_logs
Expand Down Expand Up @@ -35,7 +35,7 @@ export const getFirefoxLogsTool = {
},
},
},
};
} satisfies ToolDefinition;

export async function handleGetFirefoxLogs(input: unknown) {
try {
Expand Down Expand Up @@ -121,7 +121,7 @@ export const getFirefoxInfoTool = {
type: 'object',
properties: {},
},
};
} satisfies ToolDefinition;

export async function handleGetFirefoxInfo(_input: unknown) {
try {
Expand Down Expand Up @@ -239,7 +239,7 @@ export const restartFirefoxTool = {
},
},
},
};
} satisfies ToolDefinition;

export async function handleRestartFirefox(input: unknown) {
try {
Expand Down
6 changes: 3 additions & 3 deletions src/tools/firefox-prefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { successResponse, errorResponse } from '../utils/response-helpers.js';
import { generatePrefScript } from '../firefox/pref-utils.js';
import { defineModule } from './module.js';
import { defineModule, type ToolDefinition } from './module.js';
import type { McpToolResponse } from '../types/common.js';

// ============================================================================
Expand Down Expand Up @@ -34,7 +34,7 @@ export const setFirefoxPrefsTool = {
},
required: ['prefs'],
},
};
} satisfies ToolDefinition;

export async function handleSetFirefoxPrefs(args: unknown): Promise<McpToolResponse> {
try {
Expand Down Expand Up @@ -145,7 +145,7 @@ export const getFirefoxPrefsTool = {
},
required: ['names'],
},
};
} satisfies ToolDefinition;

export async function handleGetFirefoxPrefs(args: unknown): Promise<McpToolResponse> {
try {
Expand Down
14 changes: 7 additions & 7 deletions src/tools/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { successResponse, errorResponse } from '../utils/response-helpers.js';
import { handleUidError } from '../utils/uid-helpers.js';
import { defineModule } from './module.js';
import { defineModule, type ToolDefinition } from './module.js';
import type { McpToolResponse } from '../types/common.js';

// Tool definitions
Expand All @@ -29,7 +29,7 @@ export const clickByUidTool = {
},
required: ['uid'],
},
};
} satisfies ToolDefinition;

export const hoverByUidTool = {
name: 'hover_by_uid',
Expand All @@ -47,7 +47,7 @@ export const hoverByUidTool = {
},
required: ['uid'],
},
};
} satisfies ToolDefinition;

export const fillByUidTool = {
name: 'fill_by_uid',
Expand All @@ -69,7 +69,7 @@ export const fillByUidTool = {
},
required: ['uid', 'value'],
},
};
} satisfies ToolDefinition;

export const dragByUidToUidTool = {
name: 'drag_by_uid_to_uid',
Expand All @@ -91,7 +91,7 @@ export const dragByUidToUidTool = {
},
required: ['fromUid', 'toUid'],
},
};
} satisfies ToolDefinition;

export const fillFormByUidTool = {
name: 'fill_form_by_uid',
Expand Down Expand Up @@ -123,7 +123,7 @@ export const fillFormByUidTool = {
},
required: ['elements'],
},
};
} satisfies ToolDefinition;

export const uploadFileByUidTool = {
name: 'upload_file_by_uid',
Expand All @@ -145,7 +145,7 @@ export const uploadFileByUidTool = {
},
required: ['uid', 'filePath'],
},
};
} satisfies ToolDefinition;

// Handlers
export async function handleClickByUid(args: unknown): Promise<McpToolResponse> {
Expand Down
22 changes: 21 additions & 1 deletion src/tools/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,31 @@

import type { McpToolResponse } from '../types/common.js';

export type JsonSchemaType = 'array' | 'boolean' | 'integer' | 'number' | 'object' | 'string';

export interface JsonSchemaProperty {
type: JsonSchemaType | readonly JsonSchemaType[];
description?: string;
enum?: readonly string[];
/** Schema of array elements (when type is 'array'). */
items?: JsonSchemaProperty;
/** Schema for values of an open-key object (prefs-style maps). */
additionalProperties?: { oneOf: Array<{ type: JsonSchemaType }> };
properties?: Record<string, JsonSchemaProperty>;
required?: readonly string[];
}

export interface InputSchema {
type: 'object';
properties: Record<string, JsonSchemaProperty>;
required?: readonly string[];
}

export interface ToolDefinition {
name: string;
description: string;
annotations?: { readOnlyHint?: boolean; [key: string]: unknown };
inputSchema: Record<string, unknown>;
inputSchema: InputSchema;
}

export type ToolHandler = (input: unknown) => Promise<McpToolResponse>;
Expand Down
10 changes: 5 additions & 5 deletions src/tools/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
TOKEN_LIMITS,
} from '../utils/response-helpers.js';
import { saveOutput } from '../utils/save-output.js';
import { defineModule } from './module.js';
import { defineModule, type ToolDefinition } from './module.js';
import type { McpToolResponse } from '../types/common.js';
import type { NetworkBodyResult } from '../firefox/events/network.js';

Expand All @@ -27,7 +27,7 @@ export const listNetworkRequestsTool = {
readOnlyHint: true,
},
inputSchema: {
type: 'object' as const,
type: 'object',
properties: {
limit: {
type: 'number',
Expand Down Expand Up @@ -92,7 +92,7 @@ export const listNetworkRequestsTool = {
},
},
},
};
} satisfies ToolDefinition;

export const getNetworkRequestTool = {
name: 'get_network_request',
Expand All @@ -102,7 +102,7 @@ export const getNetworkRequestTool = {
readOnlyHint: true,
},
inputSchema: {
type: 'object' as const,
type: 'object',
properties: {
id: {
type: 'string',
Expand All @@ -129,7 +129,7 @@ export const getNetworkRequestTool = {
},
},
},
};
} satisfies ToolDefinition;

/**
* Fetch a body without letting a missing facade method or transport error fail
Expand Down
Loading