Skip to main content
Glama

Serena

by oraios

find_symbol

Search and retrieve symbols like classes or methods within a single file using a name path pattern. Specify depth to include children and restrict searches with paths, file/directory filters, or symbol kinds.

Instructions

Retrieves information on all symbols/code entities (classes, methods, etc.) based on the given name_path, which represents a pattern for the symbol's path within the symbol tree of a single file. The returned symbol location can be used for edits or further queries. Specify depth > 0 to retrieve children (e.g., methods of a class).

The matching behavior is determined by the structure of name_path, which can either be a simple name (e.g. "method") or a name path like "class/method" (relative name path) or "/class/method" (absolute name path). Note that the name path is not a path in the file system but rather a path in the symbol tree within a single file. Thus, file or directory names should never be included in the name_path. For restricting the search to a single file or directory, the within_relative_path parameter should be used instead. The retrieved symbols' name_path attribute will always be composed of symbol names, never file or directory names.

Key aspects of the name path matching behavior:

  • Trailing slashes in name_path play no role and are ignored.
  • The name of the retrieved symbols will match (either exactly or as a substring) the last segment of name_path, while other segments will restrict the search to symbols that have a desired sequence of ancestors.
  • If there is no starting or intermediate slash in name_path, there is no restriction on the ancestor symbols. For example, passing method will match against symbols with name paths like method, class/method, class/nested_class/method, etc.
  • If name_path contains a / but doesn't start with a /, the matching is restricted to symbols with the same ancestors as the last segment of name_path. For example, passing class/method will match against class/method as well as nested_class/class/method but not method.
  • If name_path starts with a /, it will be treated as an absolute name path pattern, meaning that the first segment of it must match the first segment of the symbol's name path. For example, passing /class will match only against top-level symbols like class but not against nested_class/class. Passing /class/method will match against class/method but not nested_class/class/method or method. Returns JSON string: a list of symbols (with locations) matching the name.

Input Schema

NameRequiredDescriptionDefault
depthNoDepth to retrieve descendants (e.g., 1 for class methods/attributes).
exclude_kindsNoOptional. List of LSP symbol kind integers to exclude. Takes precedence over `include_kinds`.
include_bodyNoIf True, include the symbol's source code. Use judiciously.
include_kindsNoOptional. List of LSP symbol kind integers to include. (e.g., 5 for Class, 12 for Function). Valid kinds: 1=file, 2=module, 3=namespace, 4=package, 5=class, 6=method, 7=property, 8=field, 9=constructor, 10=enum, 11=interface, 12=function, 13=variable, 14=constant, 15=string, 16=number, 17=boolean, 18=array, 19=object, 20=key, 21=null, 22=enum member, 23=struct, 24=event, 25=operator, 26=type parameter.
max_answer_charsNoMax characters for the JSON result. If exceeded, no content is returned.
name_pathYesThe name path pattern to search for, see above for details.
relative_pathNoOptional. Restrict search to this file or directory. If None, searches entire codebase. If a directory is passed, the search will be restricted to the files in that directory. If a file is passed, the search will be restricted to that file. If you have some knowledge about the codebase, you should use this parameter, as it will significantly speed up the search as well as reduce the number of results.
substring_matchingNoIf True, use substring matching for the last segment of `name`.

Input Schema (JSON Schema)

{ "properties": { "depth": { "default": 0, "description": "Depth to retrieve descendants (e.g., 1 for class methods/attributes).", "title": "Depth", "type": "integer" }, "exclude_kinds": { "anyOf": [ { "items": { "type": "integer" }, "type": "array" }, { "type": "null" } ], "default": null, "description": "Optional. List of LSP symbol kind integers to exclude. Takes precedence over `include_kinds`.", "title": "Exclude Kinds" }, "include_body": { "default": false, "description": "If True, include the symbol's source code. Use judiciously.", "title": "Include Body", "type": "boolean" }, "include_kinds": { "anyOf": [ { "items": { "type": "integer" }, "type": "array" }, { "type": "null" } ], "default": null, "description": "Optional. List of LSP symbol kind integers to include. (e.g., 5 for Class, 12 for Function).\nValid kinds: 1=file, 2=module, 3=namespace, 4=package, 5=class, 6=method, 7=property, 8=field, 9=constructor, 10=enum,\n11=interface, 12=function, 13=variable, 14=constant, 15=string, 16=number, 17=boolean, 18=array, 19=object,\n20=key, 21=null, 22=enum member, 23=struct, 24=event, 25=operator, 26=type parameter.", "title": "Include Kinds" }, "max_answer_chars": { "default": 200000, "description": "Max characters for the JSON result. If exceeded, no content is returned.", "title": "Max Answer Chars", "type": "integer" }, "name_path": { "description": "The name path pattern to search for, see above for details.", "title": "Name Path", "type": "string" }, "relative_path": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "description": "Optional. Restrict search to this file or directory. If None, searches entire codebase.\nIf a directory is passed, the search will be restricted to the files in that directory.\nIf a file is passed, the search will be restricted to that file.\nIf you have some knowledge about the codebase, you should use this parameter, as it will significantly\nspeed up the search as well as reduce the number of results.", "title": "Relative Path" }, "substring_matching": { "default": false, "description": "If True, use substring matching for the last segment of `name`.", "title": "Substring Matching", "type": "boolean" } }, "required": [ "name_path" ], "title": "applyArguments", "type": "object" }

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/oraios/serena'

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