Skip to main content
Glama

nrf_list

Browse directory contents in the nRF Connect SDK repository to locate documentation, sample projects, and source files for embedded development.

Instructions

List the contents of a directory in the nRF Connect SDK repo (nrfconnect/sdk-nrf @ main).

Useful starting paths:

  • "doc/nrf" → Documentation root (RST files)

  • "doc/nrf/protocols" → Bluetooth, LTE, Thread, Zigbee docs

  • "doc/nrf/libraries" → Library reference docs

  • "doc/nrf/applications" → Application-level docs

  • "samples" → All sample projects

  • "samples/bluetooth" → Bluetooth LE samples

  • "samples/cellular" → LTE/cellular modem samples

  • "samples/matter" → Matter protocol samples

  • "samples/nfc" → NFC samples

  • "samples/tfm" → Trusted Firmware-M samples

  • "samples/crypto" → Cryptography samples

Returns dirs first, then files, with full paths you can pass to nrf_read.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesDirectory path within the repo (e.g. 'samples/bluetooth')

Implementation Reference

  • Handler function for nrf_list tool - fetches directory contents from GitHub API, sorts directories first then files, and returns formatted listing
    if (name === "nrf_list") {
      const path = (args as { path: string }).path.replace(/^\/+|\/+$/g, "");
      const url = `${BASE_URL}/repos/${REPO}/contents/${encodePath(path)}?ref=${REF}`;
      const data = await githubGet(url);
    
      if (!Array.isArray(data)) {
        return {
          content: [{ type: "text", text: `'${path}' is a file, not a directory. Use nrf_read to read it.` }],
        };
      }
    
      const items = (data as Array<{ name: string; path: string; type: string }>)
        .sort((a, b) => {
          if (a.type === b.type) return a.name.localeCompare(b.name);
          return a.type === "dir" ? -1 : 1;
        })
        .map((item) => `${item.type === "dir" ? "[dir] " : "[file]"} ${item.path}`)
        .join("\n");
    
      return {
        content: [{ type: "text", text: items || "Empty directory" }],
      };
    }
  • src/index.ts:54-83 (registration)
    Tool registration including name 'nrf_list', description with useful starting paths, and inputSchema defining 'path' parameter
    const TOOLS: Tool[] = [
      {
        name: "nrf_list",
        description: `List the contents of a directory in the nRF Connect SDK repo (nrfconnect/sdk-nrf @ ${REF}).
    
    Useful starting paths:
    - "doc/nrf"                    → Documentation root (RST files)
    - "doc/nrf/protocols"          → Bluetooth, LTE, Thread, Zigbee docs
    - "doc/nrf/libraries"          → Library reference docs
    - "doc/nrf/applications"       → Application-level docs
    - "samples"                    → All sample projects
    - "samples/bluetooth"          → Bluetooth LE samples
    - "samples/cellular"           → LTE/cellular modem samples
    - "samples/matter"             → Matter protocol samples
    - "samples/nfc"                → NFC samples
    - "samples/tfm"                → Trusted Firmware-M samples
    - "samples/crypto"             → Cryptography samples
    
    Returns dirs first, then files, with full paths you can pass to nrf_read.`,
        inputSchema: {
          type: "object",
          properties: {
            path: {
              type: "string",
              description: "Directory path within the repo (e.g. 'samples/bluetooth')",
            },
          },
          required: ["path"],
        },
      },
  • Input schema for nrf_list defining 'path' as required string parameter for directory path within repo
    inputSchema: {
      type: "object",
      properties: {
        path: {
          type: "string",
          description: "Directory path within the repo (e.g. 'samples/bluetooth')",
        },
      },
      required: ["path"],
    },
  • githubGet helper function that makes authenticated requests to GitHub API with rate limit handling
    async function githubGet(url: string): Promise<unknown> {
      const response = await fetch(url, { headers: githubHeaders() });
      if (!response.ok) {
        const body = await response.text();
        // Surface rate limit info if that's the issue
        const remaining = response.headers.get("x-ratelimit-remaining");
        const reset = response.headers.get("x-ratelimit-reset");
        if (response.status === 403 && remaining === "0" && reset) {
          const resetTime = new Date(parseInt(reset) * 1000).toISOString();
          throw new Error(`GitHub rate limit exceeded. Resets at ${resetTime}. Set GITHUB_TOKEN for higher limits.`);
        }
        throw new Error(`GitHub API ${response.status}: ${body}`);
      }
      return response.json();
    }
  • encodePath helper function that encodes each path segment individually while preserving slashes
    function encodePath(path: string): string {
      // Encode each path segment individually, preserving slashes
      return path.split("/").map(encodeURIComponent).join("/");
    }
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key behaviors: the tool lists directory contents, returns directories first then files, provides full paths, and those paths can be used with nrf_read. It doesn't mention error conditions, rate limits, or authentication needs, but covers the core operational behavior well.

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 well-structured and appropriately sized. The first sentence states the core purpose, followed by a practical 'Useful starting paths' section that provides immediate utility, and ends with important behavioral details about the return format. Every sentence earns its place with no wasted words.

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

Completeness4/5

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

For a single-parameter tool with no output schema, the description provides good completeness. It explains what the tool does, how to use it with examples, and describes the return format. The main gap is the lack of error handling information, but given the tool's simplicity and the provided context, it's reasonably complete.

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?

Schema description coverage is 100%, so the schema already documents the single 'path' parameter. The description adds some value by providing concrete examples of paths (e.g., 'samples/bluetooth') in the 'Useful starting paths' section, but doesn't add significant semantic meaning beyond what the schema provides.

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

Purpose5/5

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

The description clearly states the specific action ('List the contents of a directory') and resource ('nRF Connect SDK repo'), distinguishing it from sibling tools nrf_read (likely reads file contents) and nrf_search (likely searches within files). The phrase 'Returns dirs first, then files, with full paths you can pass to nrf_read' further clarifies its role in the toolchain.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool (listing directory contents in a specific repo) and includes a helpful list of 'Useful starting paths' to guide initial usage. However, it does not explicitly state when NOT to use it or mention alternatives like nrf_search for different operations.

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

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/pshanesmith/nrf-mcp'

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