Skip to main content
Glama

manage_routes

Enable or disable specific CIDR routes for a device using the Tailscale MCP Server, ensuring precise control over network configurations and routing.

Instructions

Enable or disable routes for a device

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesWhether to enable or disable the routes
deviceIdYesThe ID of the device
routesYesArray of CIDR routes to manage

Implementation Reference

  • The handler function for the manage_routes tool, which enables or disables specified CIDR routes for a given device using the Tailscale client.
    async function manageRoutes(
      args: z.infer<typeof ManageRoutesSchema>,
      context: ToolContext,
    ): Promise<CallToolResult> {
      try {
        logger.debug("Managing routes:", args);
    
        let result: UnifiedResponse<void>;
        if (args.action === "enable") {
          result = await context.client.enableDeviceRoutes(
            args.deviceId,
            args.routes,
          );
        } else {
          result = await context.client.disableDeviceRoutes(
            args.deviceId,
            args.routes,
          );
        }
    
        if (!result.success) {
          return returnToolError(result.error);
        }
    
        const verbPast = args.action === "enable" ? "enabled" : "disabled";
        return returnToolSuccess(
          `Successfully ${verbPast} routes ${args.routes.join(
            ", ",
          )} for device ${args.deviceId}`,
        );
      } catch (error: unknown) {
        logger.error("Error managing routes:", error);
        return returnToolError(error);
      }
    }
  • Zod input schema for the manage_routes tool defining deviceId, routes array, and action (enable/disable).
    const ManageRoutesSchema = z.object({
      deviceId: z.string().describe("The ID of the device"),
      routes: z.array(z.string()).describe("Array of CIDR routes to manage"),
      action: z
        .enum(["enable", "disable"])
        .describe("Whether to enable or disable the routes"),
    });
  • Tool registration object within the deviceTools module's tools array, linking name, description, schema, and handler.
    {
      name: "manage_routes",
      description: "Enable or disable routes for a device",
      inputSchema: ManageRoutesSchema,
      handler: manageRoutes,
    },

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