Skip to main content
Glama

nrf_search

Search code and documentation in the nRF Connect SDK repository using GitHub's search qualifiers to find specific files, samples, or configuration examples.

Instructions

Search for code or documentation across the nRF Connect SDK repo using GitHub code search.

Supports GitHub search qualifiers to narrow results:

  • Plain keyword: "DFU_TARGET_IMAGE_TYPE_ANY"

  • Docs only: "FOTA path:doc/nrf"

  • Samples only: "peripheral_hr path:samples"

  • Specific extension: "CONFIG_BT_PERIPHERAL extension:conf"

  • Source files only: "bt_le_adv_start extension:c"

  • Headers only: "struct bt_conn extension:h"

Returns matching file paths (up to 20). Use nrf_read to fetch the content. Note: Requires GITHUB_TOKEN for reliable results (unauthenticated search is heavily rate-limited).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch terms with optional GitHub qualifiers (path:, extension:, filename:)

Implementation Reference

  • Handler function for nrf_search tool - executes GitHub code search API call, constructs query with repo qualifier, and returns up to 20 matching file paths
    if (name === "nrf_search") {
      const query = (args as { query: string }).query;
      const fullQuery = `${query} repo:${REPO}`;
      const url = `${BASE_URL}/search/code?q=${encodeURIComponent(fullQuery)}&per_page=20`;
      const data = await githubGet(url) as {
        total_count: number;
        items: Array<{ path: string; name: string }>;
      };
    
      if (!data.items || data.items.length === 0) {
        return {
          content: [{ type: "text", text: `No results found for: ${query}` }],
        };
      }
    
      const results = data.items.map((item) => item.path).join("\n");
      const text = `Found ${data.total_count} result(s) (showing up to 20):\n\n${results}`;
      return {
        content: [{ type: "text", text }],
      };
    }
  • src/index.ts:106-130 (registration)
    Tool registration in TOOLS array defining nrf_search with name, description, and input schema requiring a query parameter
      {
        name: "nrf_search",
        description: `Search for code or documentation across the nRF Connect SDK repo using GitHub code search.
    
    Supports GitHub search qualifiers to narrow results:
    - Plain keyword:        "DFU_TARGET_IMAGE_TYPE_ANY"
    - Docs only:           "FOTA path:doc/nrf"
    - Samples only:        "peripheral_hr path:samples"
    - Specific extension:  "CONFIG_BT_PERIPHERAL extension:conf"
    - Source files only:   "bt_le_adv_start extension:c"
    - Headers only:        "struct bt_conn extension:h"
    
    Returns matching file paths (up to 20). Use nrf_read to fetch the content.
    Note: Requires GITHUB_TOKEN for reliable results (unauthenticated search is heavily rate-limited).`,
        inputSchema: {
          type: "object",
          properties: {
            query: {
              type: "string",
              description: "Search terms with optional GitHub qualifiers (path:, extension:, filename:)",
            },
          },
          required: ["query"],
        },
      },
  • Helper function for making authenticated GitHub API requests with error handling and rate limit detection
    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();
    }
  • Input schema for nrf_search tool defining the required query parameter with support for GitHub search qualifiers
    inputSchema: {
      type: "object",
      properties: {
        query: {
          type: "string",
          description: "Search terms with optional GitHub qualifiers (path:, extension:, filename:)",
        },
      },
      required: ["query"],
    },
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 traits: it's a read-only search operation (implied by 'search'), returns up to 20 file paths, requires authentication for reliability, and is rate-limited without it. However, it lacks details on error handling or exact response format, which could be beneficial for completeness.

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 front-loaded, starting with the core purpose. Each sentence adds essential information: search capabilities, qualifier examples, return details, and authentication requirements. There is no wasted text, and the bulleted examples are concise and illustrative, making it easy to scan and understand.

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?

Given the tool's complexity (search with qualifiers, authentication needs) and lack of annotations and output schema, the description is largely complete. It covers purpose, usage, parameters, and behavioral traits. However, it doesn't specify the exact output format (e.g., JSON structure) or error scenarios, which could aid the agent in handling responses, preventing a perfect score.

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

Parameters4/5

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

The schema description coverage is 100%, so the baseline is 3. The description adds significant value beyond the schema by providing examples of GitHub search qualifiers (e.g., 'path:doc/nrf', 'extension:c'), which clarify how to construct the query parameter effectively. This enhances understanding but doesn't fully cover all possible qualifiers, keeping it from a perfect score.

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 tool's purpose: 'Search for code or documentation across the nRF Connect SDK repo using GitHub code search.' It specifies the verb ('search'), resource ('code or documentation'), and scope ('nRF Connect SDK repo'), and distinguishes it from sibling tools by mentioning 'Use nrf_read to fetch the content,' indicating it returns file paths rather than content.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool versus alternatives. It states 'Returns matching file paths (up to 20). Use nrf_read to fetch the content,' clearly differentiating from nrf_read for content retrieval. It also specifies 'Requires GITHUB_TOKEN for reliable results (unauthenticated search is heavily rate-limited),' indicating prerequisites and performance considerations.

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