manage_policy_file
Handle policy files by fetching, updating, or testing ACL access rules on the Tailscale MCP Server using HuJSON format for precise network management.
Instructions
Manage policy files and test ACL access rules
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| operation | Yes | Policy file operation to perform | |
| policy | No | Policy content (HuJSON format) for update operation | |
| testRequest | No | Access test parameters for test_access operation |
Implementation Reference
- src/tools/acl-tools.ts:459-513 (handler)The handler function implementing the core logic for the 'manage_policy_file' tool. Handles 'get' to retrieve the policy file and 'test_access' to test ACL access rules using Tailscale API.async function managePolicyFile( args: z.infer<typeof PolicyFileSchema>, context: ToolContext, ): Promise<CallToolResult> { try { logger.debug("Managing policy file:", args); switch (args.operation) { case "get": { const result = await context.api.getPolicyFile(); if (!result.success) { return returnToolError(result.error); } return returnToolSuccess( `Policy File (HuJSON format):\n\n${result.data}`, ); } case "test_access": { if (!args.testRequest) { return returnToolError( "Test request parameters are required for test_access operation", ); } const { src, dst, proto } = args.testRequest; const result = await context.api.testACLAccess(src, dst, proto); if (!result.success) { return returnToolError(result.error); } const testResult = result.data; return returnToolSuccess( `ACL Access Test Result: - Source: ${src} - Destination: ${dst} - Protocol: ${proto || "any"} - Result: ${testResult?.allowed ? "ALLOWED" : "DENIED"} - Rule: ${testResult?.rule || "No matching rule"} - Match: ${testResult?.match || "N/A"}`, ); } default: return returnToolError( "Invalid policy operation. Use: get or test_access", ); } } catch (error) { logger.error("Error managing policy file:", error); return returnToolError(error); } }
- src/tools/acl-tools.ts:106-122 (schema)Zod input schema defining parameters for the manage_policy_file tool, including operation types and optional policy content or test request.const PolicyFileSchema = z.object({ operation: z .enum(["get", "update", "test_access"]) .describe("Policy file operation to perform"), policy: z .string() .optional() .describe("Policy content (HuJSON format) for update operation"), testRequest: z .object({ src: z.string(), dst: z.string(), proto: z.string().optional(), }) .optional() .describe("Access test parameters for test_access operation"), });
- src/tools/acl-tools.ts:543-548 (registration)Tool registration within the aclTools module's tools array, linking name, description, schema, and handler.{ name: "manage_policy_file", description: "Manage policy files and test ACL access rules", inputSchema: PolicyFileSchema, handler: managePolicyFile, },