Skip to main content
Glama

sn_codesearch

Read-onlyIdempotent

Search ServiceNow script fields across code tables to find business rules, script includes, UI/client scripts, REST operations, ES modules, and ATF scripts; returns snippets around matches.

Instructions

Search across ServiceNow code artifacts — business rules, script includes, UI scripts, client scripts, scripted REST operations, ES modules and ATF step scripts. Returns matches with a snippet around the first hit; with no table, tables take turns so each is on page 1.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "search_term": "<search_term>",
      "profile": "<profile>"
    },
    "name": "sn_codesearch"
  }
}

Input Schema

NameRequiredDescriptionDefault
fieldNoSpecific field to search (default: the table's script field)
limitNoMax total results (default 20, max 1000)
tableNoSearch one table only (default: all code tables you may read). Options: sys_script, sys_script_include, sys_ui_script, sys_script_client, sys_ws_operation, sys_module, sys_atf_step
offsetNoOffset into the combined results (default 0)
profileYesConfigured ServiceNow profile name (required; no default fallback).
search_termYesText to search for in script fields

Output Schema

NameRequiredDescriptionDefault
dataYes
profileYesConfigured ServiceNow profile name (required; no default fallback).
metadataYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed5 schema fields changedv2.3.0
    • changedInput schema / properties / field / description
      Previous value: -"Specific field to search (default: script)"New value: +"Specific field to search (default: the table's script field)"
    • changedInput schema / properties / offset / description
      Previous value: -"Deterministic combined-result offset (default 0)"New value: +"Offset into the combined results (default 0)"
    • changedInput schema / properties / table / description
      Previous value: -"Search a specific table only (default: searches all code tables). Options: sys_script, sys_script_include, sys_ui_script, sys_script_client, sys_ws_operation"New value: +"Search one table only (default: all code tables you may read). Options: sys_script, sys_script_include, sys_ui_script, sys_script_client, sys_ws_operation, sys_module, sys_atf_step"
    • addedOutput schema / properties / metadata / properties / cache
      Added value: +{
      +  "enum": [
      +    "hit",
      +    "miss",
      +    "bypass",
      +    "mixed"
      +  ],
      +  "type": "string"
      +}
    • addedOutput schema / properties / metadata / properties / timing
      Added value: +{
      +  "additionalProperties": false,
      +  "properties": {
      +    "total_ms": {
      +      "minimum": 0,
      +      "type": "integer"
      +    },
      +    "upstream_ms": {
      +      "minimum": 0,
      +      "type": "integer"
      +    },
      +    "watermark_ms": {
      +      "minimum": 0,
      +      "type": "integer"
      +    }
      +  },
      +  "required": [
      +    "total_ms",
      +    "upstream_ms",
      +    "watermark_ms"
      +  ],
      +  "type": "object"
      +}
  2. Changed10 schema fields changedv2.2.0
    • addedInput schema / additionalProperties
      Added value: +false
    • addedInput schema / properties / limit / default
      Added value: +20
    • changedInput schema / properties / limit / description
      Previous value: -"Max total results (default 20)"New value: +"Max total results (default 20, max 1000)"
    • addedInput schema / properties / limit / maximum
      Added value: +1000
    • addedInput schema / properties / limit / minimum
      Added value: +1
    • changedInput schema / properties / limit / type
      Previous value: -"number"New value: +"integer"
    • addedInput schema / properties / offset
      Added value: +{
      +  "default": 0,
      +  "description": "Deterministic combined-result offset (default 0)",
      +  "maximum": 10000,
      +  "minimum": 0,
      +  "type": "integer"
      +}
    • addedInput schema / properties / profile
      Added value: +{
      +  "description": "Configured ServiceNow profile name (required; no default fallback).",
      +  "maxLength": 128,
      +  "minLength": 1,
      +  "type": "string"
      +}
    • changedInput schema / required
      Previous value: -[
      -  "search_term"
      -]New value: +[
      +  "search_term",
      +  "profile"
      +]
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "additionalProperties": false,
      +  "properties": {
      +    "data": {
      +      "additionalProperties": false,
      +      "properties": {
      +        "results": {
      +          "items": {},
      +          "type": "array"
      +        },
      +        "warnings": {
      +          "items": {
      +            "type": "string"
      +          },
      +          "type": "array"
      +        }
      +      },
      +      "required": [
      +        "results"
      +      ],
      +      "type": "object"
      +    },
      +    "metadata": {
      +      "additionalProperties": false,
      +      "properties": {
      +        "kind": {
      +          "enum": [
      +            "single",
      +            "collection",
      +            "operation"
      +          ],
      +          "type": "string"
      +        },
      +        "limits": {
      +          "additionalProperties": false,
      +          "properties": {
      +            "max_bytes": {
      +              "maximum": 14680064,
      +              "minimum": 1000,
      +              "type": "integer"
      +            },
      +            "max_records": {
      +              "exclusiveMinimum": 0,
      +              "maximum": 9007199254740991,
      +              "type": "integer"
      +            }
      +          },
      +          "required": [
      +            "max_records",
      +            "max_bytes"
      +          ],
      +          "type": "object"
      +        },
      +        "pagination": {
      +          "anyOf": [
      +            {
      +              "additionalProperties": false,
      +              "properties": {
      +                "mode": {
      +                  "const": "none",
      +                  "type": "string"
      +                }
      +              },
      +              "required": [
      +                "mode"
      +              ],
      +              "type": "object"
      +            },
      +            {
      +              "additionalProperties": false,
      +              "properties": {
      +                "has_more": {
      +                  "type": "boolean"
      +                },
      +                "limit": {
      +                  "exclusiveMinimum": 0,
      +                  "maximum": 9007199254740991,
      +                  "type": "integer"
      +                },
      +                "mode": {
      +                  "const": "offset",
      +                  "type": "string"
      +                },
      +                "next_offset": {
      +                  "maximum": 9007199254740991,
      +                  "minimum": 0,
      +                  "type": "integer"
      +                },
      +                "offset": {
      +                  "maximum": 9007199254740991,
      +                  "minimum": 0,
      +                  "type": "integer"
      +                },
      +                "order_by": {
      +                  "items": {
      +                    "minLength": 1,
      +                    "type": "string"
      +                  },
      +                  "maxItems": 8,
      +                  "minItems": 1,
      +                  "type": "array"
      +                },
      +                "recovery": {
      +                  "const": "adjust_request_and_retry_same_offset",
      +                  "type": "string"
      +                },
      +                "returned": {
      +                  "maximum": 9007199254740991,
      +                  "minimum": 0,
      +                  "type": "integer"
      +                }
      +              },
      +              "required": [
      +                "mode",
      +                "limit",
      +                "offset",
      +                "returned",
      +                "has_more",
      +                "order_by"
      +              ],
      +              "type": "object"
      +            }
      +          ]
      +        },
      +        "record_count": {
      +          "maximum": 9007199254740991,
      +          "minimum": 0,
      +          "type": "integer"
      +        },
      +        "truncation": {
      +          "additionalProperties": false,
      +          "properties": {
      +            "dropped_records": {
      +              "maximum": 9007199254740991,
      +              "minimum": 0,
      +              "type": "integer"
      +            },
      +            "reason": {
      +              "enum": [
      +                "record_limit",
      +                "byte_limit"
      +              ],
      +              "type": "string"
      +            },
      +            "truncated": {
      +              "type": "boolean"
      +            }
      +          },
      +          "required": [
      +            "truncated"
      +          ],
      +          "type": "object"
      +        }
      +      },
      +      "required": [
      +        "kind",
      +        "record_count",
      +        "limits",
      +        "pagination",
      +        "truncation"
      +      ],
      +      "type": "object"
      +    },
      +    "profile": {
      +      "description": "Configured ServiceNow profile name (required; no default fallback).",
      +      "maxLength": 128,
      +      "minLength": 1,
      +      "type": "string"
      +    }
      +  },
      +  "required": [
      +    "data",
      +    "metadata",
      +    "profile"
      +  ],
      +  "type": "object"
      +}
  3. First observedv1.0.0

TDQS

A4.1/5.0
Behavior4/5

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

Annotations already declare readOnly, idempotent, non-destructive and open-world behavior, so the description needn't restate safety. It adds genuinely non-obvious behavior instead: results carry a snippet around the first hit, and without a table the tool rotates across tables so each appears on page 1 — a pagination semantic an agent could not infer from annotations. It stops short of covering cost, rate limits, or result-count behavior across tables.

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

Conciseness4/5

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

Two sentences, front-loaded with the artifact scope, with no filler or repeated title text. The second sentence is compact to the point of ambiguity — 'tables take turns so each is on page 1' requires a second read to parse as round-robin pagination across tables.

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 six-parameter read tool with a full output schema and complete annotation coverage, the description supplies what structured fields cannot: coverage scope and multi-table pagination semantics. Return-value detail is legitimately omitted because an output schema exists; only explicit alternative-tool guidance and permission prerequisites are missing.

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?

Schema description coverage is 100%, so the baseline is 3, but the description earns a step up by explaining the effect of omitting 'table' — tables take turns and each lands on page 1 — which goes beyond the schema's 'default: all code tables you may read'. It adds little about field, limit, or offset beyond what the schema already documents.

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 opens with a specific verb and resource ('Search across ServiceNow code artifacts') and then enumerates the artifact families covered — business rules, script includes, UI scripts, client scripts, scripted REST operations, ES modules, ATF step scripts. Combined with the table options in the schema, an agent can distinguish this code-search tool from record-oriented siblings like sn_query or sn_aggregate without opening another schema.

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

Usage Guidelines3/5

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

The intended usage context (find script code rather than records) is implied by the artifact list, and the note about omitting the table parameter gives one concrete usage pattern. However, there is no explicit 'use this instead of X when Y' guidance against sn_query/sn_aggregate, and no statement of prerequisites such as the required profile or read permissions beyond the schema's passing mention.

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