Skip to main content
Glama

list_devices

Retrieve a detailed list of all devices connected to the Tailscale network, optionally including route information, for streamlined network management and monitoring.

Instructions

List all devices in the Tailscale network

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
includeRoutesYesInclude route information for each device

Implementation Reference

  • The handler function that implements the core logic of the 'list_devices' MCP tool. It uses the unified Tailscale client to fetch devices (via API or CLI), handles both response formats, optionally includes route info, and returns a formatted markdown string listing all devices.
    async function listDevices(
      args: z.infer<typeof ListDevicesSchema>,
      context: ToolContext,
    ): Promise<CallToolResult> {
      try {
        logger.debug("Listing devices with options:", args);
    
        // Use unified client which will automatically choose between API and CLI
        const result = await context.client.listDevices();
    
        if (!result.success) {
          return returnToolError(result);
        }
    
        const devices = result.data || [];
        let output = `Found ${devices.length} devices:\n\n`;
    
        for (const device of devices) {
          // Handle both string arrays (from CLI) and TailscaleDevice objects (from API)
          if (typeof device === "string") {
            // CLI returns simple string array of hostnames
            output += `**${device}**\n`;
            output += "  - Source: CLI (limited info available)\n\n";
          } else {
            // API returns full TailscaleDevice objects
            const typedDevice = device;
            output += `**${typedDevice.name}** (${typedDevice.hostname})\n`;
            output += `  - ID: ${typedDevice.id}\n`;
            output += `  - OS: ${typedDevice.os}\n`;
            output += `  - Addresses: ${typedDevice.addresses.join(", ")}\n`;
            output += `  - Authorized: ${typedDevice.authorized ? "✅" : "❌"}\n`;
            output += `  - Last seen: ${typedDevice.lastSeen}\n`;
            output += `  - Client version: ${typedDevice.clientVersion}\n`;
    
            if (
              args.includeRoutes &&
              Array.isArray(typedDevice.advertisedRoutes) &&
              typedDevice.advertisedRoutes.length > 0
            ) {
              output += `  - Advertised routes: ${typedDevice.advertisedRoutes.join(
                ", ",
              )}\n`;
              output += `  - Enabled routes: ${
                Array.isArray(typedDevice.enabledRoutes)
                  ? typedDevice.enabledRoutes.join(", ")
                  : "—"
              }\n`;
            }
    
            output += "\n";
          }
        }
    
        return returnToolSuccess(output);
      } catch (error: unknown) {
        logger.error("Error listing devices:", error);
        return returnToolError(error);
      }
    }
  • Zod schema defining the input parameters for the 'list_devices' tool. Supports an optional 'includeRoutes' boolean (defaults to false).
    const ListDevicesSchema = z.object({
      includeRoutes: z
        .boolean()
        .optional()
        .default(false)
        .describe("Include route information for each device"),
    });
  • The registration of the 'list_devices' tool within the deviceTools module. Specifies name, description, input schema, and handler function.
      name: "list_devices",
      description: "List all devices in the Tailscale network",
      inputSchema: ListDevicesSchema,
      handler: listDevices,
    },
  • Registration of the deviceTools module (containing list_devices) into the central ToolRegistry during loadTools().
    this.registerModule(deviceTools);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action 'List all devices' but doesn't mention any behavioral traits such as pagination, rate limits, authentication requirements, or what the output format looks like (e.g., JSON array, list of objects). This is a significant gap for a tool with no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without any fluff or redundancy. It's appropriately sized and front-loaded, making it easy for an agent to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of listing network devices and the lack of annotations and output schema, the description is incomplete. It doesn't address key contextual aspects like output format, error handling, or how the tool interacts with other device-related operations (e.g., filtering or sorting), leaving gaps for the agent to navigate.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with the parameter 'includeRoutes' clearly documented as a boolean to include route information. The description doesn't add any meaning beyond the schema, as it doesn't mention parameters at all. With high schema coverage, the baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'List' and the resource 'all devices in the Tailscale network', providing a specific purpose. However, it doesn't distinguish this tool from potential siblings like 'device_action' or 'manage_device_tags', which might also involve devices but serve different functions.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'get_network_status' or 'manage_device_tags', there's no indication of when listing devices is appropriate versus checking status or managing tags, leaving the agent to infer usage from tool names alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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