tool-definitions.js•13.5 kB
/**
* Web Proxy MCP Tools
* Complete tool definitions for the MCP server
*/
export const TOOLS = {
// Target Management Tools
proxy_add_target: {
name: "proxy_add_target",
description: "Add a new target domain for proxy monitoring",
inputSchema: {
type: "object",
properties: {
domain: {
type: "string",
description: "Domain to monitor (e.g., example.com)"
},
description: {
type: "string",
description: "Optional description of the target"
},
enabled: {
type: "boolean",
description: "Whether the target is active",
default: true
},
captureHeaders: {
type: "boolean",
description: "Capture request/response headers",
default: true
},
captureBody: {
type: "boolean",
description: "Capture request/response body",
default: false
}
},
required: ["domain"]
}
},
proxy_remove_target: {
name: "proxy_remove_target",
description: "Remove a target domain from proxy monitoring",
inputSchema: {
type: "object",
properties: {
domain: {
type: "string",
description: "Domain to remove from monitoring"
}
},
required: ["domain"]
}
},
proxy_list_targets: {
name: "proxy_list_targets",
description: "List all target domains and their status",
inputSchema: {
type: "object",
properties: {
status: {
type: "string",
enum: ["all", "active", "inactive"],
description: "Filter targets by status",
default: "all"
}
}
}
},
proxy_update_target: {
name: "proxy_update_target",
description: "Update target domain configuration",
inputSchema: {
type: "object",
properties: {
domain: {
type: "string",
description: "Domain to update"
},
description: {
type: "string",
description: "New description"
},
enabled: {
type: "boolean",
description: "Enable/disable target"
},
captureHeaders: {
type: "boolean",
description: "Enable/disable header capture"
},
captureBody: {
type: "boolean",
description: "Enable/disable body capture"
}
},
required: ["domain"]
}
},
// Proxy Server Control Tools
proxy_start_server: {
name: "proxy_start_server",
description: "Start the proxy server with optional SSL bumping",
inputSchema: {
type: "object",
properties: {
port: {
type: "number",
description: "Port to run proxy server on",
default: 8080
},
host: {
type: "string",
description: "Host to bind proxy server to",
default: "localhost"
},
enableSSLBumping: {
type: "boolean",
description: "Enable SSL bumping for HTTPS traffic interception",
default: false
}
}
}
},
proxy_stop_server: {
name: "proxy_stop_server",
description: "Stop the proxy server",
inputSchema: {
type: "object",
properties: {}
}
},
proxy_server_status: {
name: "proxy_server_status",
description: "Get proxy server status and statistics including SSL bumping status",
inputSchema: {
type: "object",
properties: {}
}
},
// SSL Certificate Management Tools
ssl_create_ca: {
name: "ssl_create_ca",
description: "Create a new Certificate Authority for SSL bumping",
inputSchema: {
type: "object",
properties: {
caName: {
type: "string",
description: "Name for the new CA (default: 'default')",
default: "default"
},
description: {
type: "string",
description: "Description for the CA"
},
overwrite: {
type: "boolean",
description: "Overwrite existing CA if it exists",
default: false
},
subject: {
type: "object",
description: "Certificate subject information",
properties: {
C: { type: "string", description: "Country", default: "US" },
ST: { type: "string", description: "State", default: "CA" },
L: { type: "string", description: "Locality", default: "San Francisco" },
O: { type: "string", description: "Organization", default: "Web Proxy MCP Server" },
OU: { type: "string", description: "Organizational Unit", default: "Development" },
CN: { type: "string", description: "Common Name" }
}
}
}
}
},
ssl_list_cas: {
name: "ssl_list_cas",
description: "List all available Certificate Authorities",
inputSchema: {
type: "object",
properties: {}
}
},
ssl_switch_ca: {
name: "ssl_switch_ca",
description: "Switch to a different Certificate Authority",
inputSchema: {
type: "object",
properties: {
caName: {
type: "string",
description: "Name of the CA to switch to"
}
},
required: ["caName"]
}
},
ssl_get_ca_certificate: {
name: "ssl_get_ca_certificate",
description: "Get CA certificate and installation instructions",
inputSchema: {
type: "object",
properties: {}
}
},
ssl_generate_certificate: {
name: "ssl_generate_certificate",
description: "Generate server certificate for specific domain",
inputSchema: {
type: "object",
properties: {
domain: {
type: "string",
description: "Domain name for the certificate"
},
altNames: {
type: "array",
items: { type: "string" },
description: "Alternative domain names (SAN)",
default: []
}
},
required: ["domain"]
}
},
ssl_ca_status: {
name: "ssl_ca_status",
description: "Get current CA status and configuration",
inputSchema: {
type: "object",
properties: {}
}
},
// Browser Setup Tools
proxy_generate_setup: {
name: "proxy_generate_setup",
description: "Generate browser and system proxy setup scripts",
inputSchema: {
type: "object",
properties: {
proxyHost: {
type: "string",
description: "Proxy server host",
default: "localhost"
},
proxyPort: {
type: "number",
description: "Proxy server port",
default: 8080
},
browsers: {
type: "array",
items: {
type: "string",
enum: ["chrome", "firefox", "curl", "system", "pac"]
},
description: "Browser types to generate setup for",
default: ["chrome", "firefox", "pac"]
}
}
}
},
proxy_get_pac_file: {
name: "proxy_get_pac_file",
description: "Get the current PAC (Proxy Auto-Configuration) file content",
inputSchema: {
type: "object",
properties: {
proxyHost: {
type: "string",
description: "Proxy server host",
default: "localhost"
},
proxyPort: {
type: "number",
description: "Proxy server port",
default: 8080
}
}
}
},
// Traffic Analysis Tools
proxy_get_traffic_log: {
name: "proxy_get_traffic_log",
description: "Get captured traffic log with filtering options",
inputSchema: {
type: "object",
properties: {
domain: {
type: "string",
description: "Filter by specific domain"
},
method: {
type: "string",
description: "Filter by HTTP method (GET, POST, etc.)"
},
limit: {
type: "number",
description: "Maximum number of entries to return",
default: 50
},
since: {
type: "string",
description: "ISO timestamp to get entries since"
}
}
}
},
proxy_export_har: {
name: "proxy_export_har",
description: "Export traffic log as HAR (HTTP Archive) format",
inputSchema: {
type: "object",
properties: {
domain: {
type: "string",
description: "Filter by specific domain"
},
since: {
type: "string",
description: "ISO timestamp to export entries since"
},
filename: {
type: "string",
description: "Output filename (without .har extension)"
}
}
}
},
proxy_clear_traffic_log: {
name: "proxy_clear_traffic_log",
description: "Clear the traffic log",
inputSchema: {
type: "object",
properties: {
domain: {
type: "string",
description: "Clear logs for specific domain only"
},
confirm: {
type: "boolean",
description: "Confirmation flag to prevent accidental deletion",
default: false
}
},
required: ["confirm"]
}
},
// Configuration Management Tools
proxy_import_config: {
name: "proxy_import_config",
description: "Import proxy configuration from file",
inputSchema: {
type: "object",
properties: {
filepath: {
type: "string",
description: "Path to configuration file"
},
merge: {
type: "boolean",
description: "Merge with existing config or replace",
default: false
}
},
required: ["filepath"]
}
},
proxy_export_config: {
name: "proxy_export_config",
description: "Export current proxy configuration to file",
inputSchema: {
type: "object",
properties: {
filepath: {
type: "string",
description: "Output file path"
},
includeTrafficLog: {
type: "boolean",
description: "Include traffic log in export",
default: false
}
}
}
},
// Advanced Analysis Tools
proxy_analyze_traffic: {
name: "proxy_analyze_traffic",
description: "Analyze captured traffic patterns and statistics",
inputSchema: {
type: "object",
properties: {
domain: {
type: "string",
description: "Analyze specific domain only"
},
timeframe: {
type: "string",
enum: ["1h", "24h", "7d", "30d", "all"],
description: "Time frame for analysis",
default: "24h"
},
groupBy: {
type: "string",
enum: ["domain", "method", "status", "hour"],
description: "Group analysis results by",
default: "domain"
}
}
}
},
proxy_get_performance_metrics: {
name: "proxy_get_performance_metrics",
description: "Get proxy server performance metrics",
inputSchema: {
type: "object",
properties: {
reset: {
type: "boolean",
description: "Reset metrics after retrieval",
default: false
}
}
}
}
};
/**
* Get tool by name
* @param {string} name - Tool name
* @returns {Object|null} Tool definition
*/
export function getTool(name) {
return TOOLS[name] || null;
}
/**
* Get all tool names
* @returns {string[]} Array of tool names
*/
export function getToolNames() {
return Object.keys(TOOLS);
}
/**
* Get tools by category
* @param {string} category - Category prefix (e.g., 'proxy_target', 'proxy_server')
* @returns {Object} Tools in category
*/
export function getToolsByCategory(category) {
const categoryTools = {};
for (const [name, tool] of Object.entries(TOOLS)) {
if (name.startsWith(category)) {
categoryTools[name] = tool;
}
}
return categoryTools;
}
/**
* Validate tool arguments against schema
* @param {string} toolName - Tool name
* @param {Object} args - Arguments to validate
* @returns {Object} Validation result
*/
export function validateToolArgs(toolName, args) {
const tool = getTool(toolName);
if (!tool) {
return { valid: false, error: `Unknown tool: ${toolName}` };
}
const schema = tool.inputSchema;
const required = schema.required || [];
// Check required fields
for (const field of required) {
if (!(field in args)) {
return { valid: false, error: `Missing required field: ${field}` };
}
}
// Basic type checking
for (const [field, value] of Object.entries(args)) {
const propSchema = schema.properties[field];
if (!propSchema) {
return { valid: false, error: `Unknown field: ${field}` };
}
if (propSchema.type === 'boolean' && typeof value !== 'boolean') {
return { valid: false, error: `Field ${field} must be boolean` };
}
if (propSchema.type === 'number' && typeof value !== 'number') {
return { valid: false, error: `Field ${field} must be number` };
}
if (propSchema.type === 'string' && typeof value !== 'string') {
return { valid: false, error: `Field ${field} must be string` };
}
if (propSchema.enum && !propSchema.enum.includes(value)) {
return { valid: false, error: `Field ${field} must be one of: ${propSchema.enum.join(', ')}` };
}
}
return { valid: true };
}