Skip to main content
Glama

search_symbols

Find Java declarations by name pattern with * and ? wildcards, optionally filtered by kind (class, interface, method, field). Requires loading a project first.

Instructions

Search the project's source declarations by name pattern. Supports glob patterns: * (any chars), ? (single char)

USAGE: search_symbols(query="*Service", kind="class") OUTPUT: One page of matching declarations with locations

KIND (optional, compared case-insensitively):

  • class, interface, enum, record, annotation: exactly the types of that kind (class excludes interfaces, enums, records and annotation types)

  • method: method declarations (constructors are not included, and lambda expressions are not method declarations)

  • field: every field declaration, including static final constants and enum constants; each result's kind is field, constant or enumConstant (record components are not field declarations) Without kind, every type is searched (no methods or fields). Any other kind is rejected with INVALID_PARAMETER. Anonymous classes have no name to match and are never results.

A method's or field's containingType is its declaring type's fully qualified name (pkg.Outer$Inner; an anonymous class is pkg.Outer$1). A type in the default package reports its package as "(default package)".

EXAMPLES:

  • search_symbols(query="Order*") - types starting with Order

  • search_symbols(query="*Repository", kind="interface")

  • search_symbols(query="get*", kind="method")

  • search_symbols(query="log", kind="field")

PAGINATION: the kind and pattern filters apply first, then offset and maxResults select the page. meta.totalCount counts every matching declaration; pagination.hasMore (and meta.truncated) is true when more follow this page, so request offset + returned next. maxResults outside 0 to 1000 is INVALID_PARAMETER.

A query naming the declaring type (Type.member) makes JDT resolve each declaration of the name and keep those of that type and its subtypes; one in a type whose own supertypes do not all resolve may be in that hierarchy, and is a potential match, never a result.

potentialMatches, present only when there are any, holds the places JDT's search reports as possible matches but cannot confirm, because a type or name there does not resolve (a missing dependency or a compile error): count is their exact number, and locations lists them, as many as the results it stands beside may list. They are never counted or listed as results.

IMPORTANT: Requires load_project to be called first.

Input Schema

NameRequiredDescriptionDefault
kindNoOptional, case-insensitive: class, interface, enum, record, annotation, method or field. Omit to search every type. field includes static final constants and enum constants.
queryYesSearch pattern - supports * and ? wildcards
offsetNoSkip the first N matching declarations (default 0)
maxResultsNoMax results to return, 0 to 1000 (default 50)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv1.5.3
    • changedInput schema / properties / kind / description
      Previous value: -"Filter by kind: class, interface, enum, method, field"New value: +"Optional, case-insensitive: class, interface, enum, record, annotation, method or field. Omit to search every type. field includes static final constants and enum constants."
    • changedInput schema / properties / maxResults / description
      Previous value: -"Max results to return (default 50)"New value: +"Max results to return, 0 to 1000 (default 50)"
    • changedInput schema / properties / offset / description
      Previous value: -"Skip first N results for pagination"New value: +"Skip the first N matching declarations (default 0)"
  2. Addedv1.3.4
  3. Removedv1.3.3
  4. First observedv1.2.0

TDQS

A4.5/5.0
Behavior5/5

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

With no annotations, the description carries the full burden and does so: it discloses pagination mechanics (filters apply before offset/maxResults, hasMore/truncated semantics), INVALID_PARAMETER rejection for bad kind and out-of-range maxResults, case-insensitive kind matching, anonymous classes never being results, and the potentialMatches caveat for unresolvable types. This is unusually rich behavioral disclosure for a search tool.

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?

Front-loaded correctly with purpose, usage, output, then per-kind detail, pagination, and edge cases. It is long, but for a tool with this many subtle semantics most sentences earn their place; the JDT-resolution and potentialMatches paragraphs are the most verbose and could be tightened.

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

Completeness5/5

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

No output schema exists, so the description must explain returns, and it does: one page of matching declarations with locations, the meta.totalCount/pagination.hasMore fields, and the conditional potentialMatches structure. Combined with the load_project prerequisite, an agent has everything needed to call and interpret this correctly.

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

Parameters5/5

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

Schema coverage is already 100%, but the description adds substantial meaning beyond it: exactly what each kind includes and excludes (class excludes interfaces/enums/records; method excludes constructors and lambdas; field covers constants and enum constants), the case-insensitive comparison, and the ordering of filter vs pagination parameters.

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?

States a specific verb and resource: 'Search the project's source declarations by name pattern,' with the glob semantics made explicit. It is clearly distinct from usages-oriented siblings like find_references, but it never names or contrasts any sibling explicitly, so it falls short of the 5 bar.

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?

Provides a concrete USAGE line, four worked examples, and states the prerequisite ('Requires load_project to be called first') plus the kind-omitted behavior. However, it never says when to prefer this over sibling search tools such as get_document_symbols or find_references, so no explicit alternative routing.

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