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("/");
    }

Tool Definition Quality

Score is being calculated. Check back soon.

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