Skip to main content
Glama

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
NameRequiredDescriptionDefault
operationYesPolicy file operation to perform
policyNoPolicy content (HuJSON format) for update operation
testRequestNoAccess test parameters for test_access operation

Implementation Reference

  • 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); } }
  • 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"), });
  • 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, },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/HexSleeves/tailscale-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server