connect_network
Enable automated Tailscale network connections, manage subnet routes, DNS settings, and device hostnames using predefined configurations for streamlined network integration.
Instructions
Connect to the Tailscale network
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| acceptDNS | Yes | Accept DNS configuration from the network | |
| acceptRoutes | Yes | Accept subnet routes from other devices | |
| advertiseRoutes | No | CIDR routes to advertise to other devices | |
| authKey | No | Authentication key for unattended setup | |
| hostname | No | Set a custom hostname for this device | |
| loginServer | No | Custom coordination server URL |
Implementation Reference
- src/tools/network-tools.ts:124-154 (handler)The handler function that implements the core logic of the connect_network tool. It processes input arguments, prepares options for Tailscale connection, calls the client.connect method, and returns success or error.
async function connectNetwork( args: z.infer<typeof ConnectNetworkSchema>, context: ToolContext, ): Promise<CallToolResult> { try { const options = { acceptRoutes: args.acceptRoutes || false, acceptDns: args.acceptDNS ?? false, // Note: CLI uses acceptDns, not acceptDNS hostname: args.hostname, advertiseRoutes: args.advertiseRoutes || [], authKey: args.authKey, loginServer: args.loginServer, }; logger.debug("Connecting to Tailscale network with options:", options); // Use unified client - this operation is CLI-only const result = await context.client.connect(options); if (!result.success) { return returnToolError(result.error); } return returnToolSuccess( `Successfully connected to Tailscale network\n\n${result.data}`, ); } catch (error: unknown) { logger.error("Error connecting to network:", error); return returnToolError(error); } } - src/tools/network-tools.ts:17-41 (schema)Zod schema defining the input validation and types for the connect_network tool parameters.
const ConnectNetworkSchema = z.object({ acceptRoutes: z .boolean() .optional() .default(false) .describe("Accept subnet routes from other devices"), acceptDNS: z .boolean() .optional() .default(false) .describe("Accept DNS configuration from the network"), hostname: z .string() .optional() .describe("Set a custom hostname for this device"), advertiseRoutes: z .array(z.string()) .optional() .describe("CIDR routes to advertise to other devices"), authKey: z .string() .optional() .describe("Authentication key for unattended setup"), loginServer: z.string().optional().describe("Custom coordination server URL"), }); - src/tools/network-tools.ts:234-239 (registration)The object registering the connect_network tool within the networkTools module's tools array, associating the name, description, input schema, and handler function.
{ name: "connect_network", description: "Connect to the Tailscale network", inputSchema: ConnectNetworkSchema, handler: connectNetwork, },