device_action
Manage device permissions and configurations by performing actions like authorizing, deauthorizing, deleting, or expiring keys on a specified device within the Tailscale MCP Server.
Instructions
Perform actions on a specific device
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | The action to perform on the device | |
| deviceId | Yes | The ID of the device to act on |
Implementation Reference
- src/tools/device-tools.ts:93-129 (handler)Executes the device_action tool by dispatching to appropriate UnifiedTailscaleClient methods based on the specified action (authorize, deauthorize, delete, expire-key). Returns success or error messages.async function deviceAction( args: z.infer<typeof DeviceActionSchema>, context: ToolContext, ): Promise<CallToolResult> { try { logger.debug("Performing device action:", args); let result: UnifiedResponse<void>; switch (args.action) { case "authorize": result = await context.client.authorizeDevice(args.deviceId); break; case "deauthorize": result = await context.client.deauthorizeDevice(args.deviceId); break; case "delete": result = await context.client.deleteDevice(args.deviceId); break; case "expire-key": result = await context.client.expireDeviceKey(args.deviceId); break; default: return returnToolError(`Unknown action: ${args.action}`); } if (!result.success) { return returnToolError(result.error); } return returnToolSuccess( `Successfully performed action "${args.action}" on device ${args.deviceId}`, ); } catch (error: unknown) { logger.error("Error performing device action:", error); return returnToolError(error); } }
- src/tools/device-tools.ts:17-22 (schema)Zod schema defining the input parameters for the device_action tool: deviceId (string) and action (enum: authorize, deauthorize, delete, expire-key).const DeviceActionSchema = z.object({ deviceId: z.string().describe("The ID of the device to act on"), action: z .enum(["authorize", "deauthorize", "delete", "expire-key"]) .describe("The action to perform on the device"), });
- src/tools/device-tools.ts:177-181 (registration)Registers the device_action tool within the deviceTools module, specifying name, description, inputSchema, and handler.name: "device_action", description: "Perform actions on a specific device", inputSchema: DeviceActionSchema, handler: deviceAction, },
- src/tools/index.ts:43-46 (registration)Top-level registration of the deviceTools module (containing device_action) in the ToolRegistry's loadTools method.this.registerModule(deviceTools); this.registerModule(networkTools); this.registerModule(aclTools); this.registerModule(adminTools);
- src/types.ts:122-125 (schema)Shared Zod schema for DeviceActionRequest used across the codebase, matching the tool's input schema.export const DeviceActionRequestSchema = z.object({ deviceId: z.string(), action: z.enum(["authorize", "deauthorize", "delete", "expire-key"]), });