opnsense_svc_control
Start, stop, or restart any OPNsense service by name, providing direct control over firewall services via the REST API.
Instructions
Start, stop, or restart a service by name
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| service_name | Yes | Name of the service (e.g. 'unbound', 'openssh', 'configd') | |
| action | Yes | Action to perform on the service |
Implementation Reference
- src/tools/system.ts:165-171 (handler)Handler case for 'opnsense_svc_control' — parses args with ServiceControlSchema, calls POST /core/service/{action}/{service_name}, and returns the result as JSON.
case "opnsense_svc_control": { const parsed = ServiceControlSchema.parse(args); const result = await client.post( `/core/service/${parsed.action}/${encodeURIComponent(parsed.service_name)}`, ); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } - src/tools/system.ts:9-12 (schema)ServiceControlSchema — Zod object validating service_name (string) and action (start/stop/restart enum).
const ServiceControlSchema = z.object({ service_name: z.string().min(1, "Service name is required"), action: ServiceActionSchema, }); - src/utils/validation.ts:54-54 (schema)ServiceActionSchema — Zod enum allowing 'start', 'stop', or 'restart' actions.
export const ServiceActionSchema = z.enum(["start", "stop", "restart"]); - src/tools/system.ts:96-114 (registration)Tool definition registration — declares 'opnsense_svc_control' with name, description, and inputSchema (service_name, action).
{ name: "opnsense_svc_control", description: "Start, stop, or restart a service by name", inputSchema: { type: "object" as const, properties: { service_name: { type: "string", description: "Name of the service (e.g. 'unbound', 'openssh', 'configd')", }, action: { type: "string", enum: ["start", "stop", "restart"], description: "Action to perform on the service", }, }, required: ["service_name", "action"], }, }, - src/index.ts:64-64 (registration)Registration: maps 'opnsense_svc_control' to handleSystemTool in the toolHandlers map.
for (const def of systemToolDefinitions) toolHandlers.set(def.name, handleSystemTool);