Gradle-mcp searching_dependency_sources
git clone https://github.com/rnett/gradle-mcp
T=$(mktemp -d) && git clone --depth=1 https://github.com/rnett/gradle-mcp "$T" && mkdir -p ~/.claude/skills && cp -r "$T/src/main/skills/searching_dependency_sources" ~/.claude/skills/rnett-gradle-mcp-searching-dependency-sources && rm -rf "$T"
src/main/skills/searching_dependency_sources/SKILL.mdAuthoritative Dependency Source & API Exploration
Explores, navigates, and analyzes the internal logic, APIs, and symbol implementations of external libraries and plugins with absolute precision using high-performance, indexed searching.
Constitution
- ALWAYS use
as the primary discovery tool for external library and plugin code.search_dependency_sources - ALWAYS prefer reading source code over interactive REPL exploration for understanding unfamiliar library APIs.
- ALWAYS provide absolute paths for
.projectRoot - ALWAYS use the
prefix for reading specific files (e.g.,{group}/{artifact}
). Thepath="org.mongodb/mongodb-driver-sync/org/mongodb/client/MongoClient.kt"
parameter should only be used to filter the search scope for performance when searching across libraries, not as the primary way to specify a path.dependency - NEVER use
in this skill; usegradleSource: true
for Gradle's internal implementation.researching_gradle_internals - NEVER use generic shell tools like
orgrep
to locate dependency sources; they reside in remote caches whose paths are not predictable in advance.find - MAY use shell tools like
orrg
to operate on a sources root path explicitly returned byast-grep
orread_dependency_sources
in thesearch_dependency_sources
header line. Dependency directories inside the sources root are symlinks; always passSources root: <path>
to--follow
(e.g.,rg
).rg --follow <pattern> <sources-root> - ALWAYS escape Lucene special characters (
,:
,=
,+
,-
,*
) in/
searches using a backslash (e.g.,FULL_TEXT
) or double quotes.\: - ALWAYS use
once a specific file path has been identified via search.read_dependency_sources - ALWAYS use
if a search returns afresh: true
with anSearchResponse
indicating a missing index; the tool will return an error message rather than throwing an exception if the index is not found.error - BE AWARE that indexing and extraction failures (e.g.,
) are still propagated and will cause the tool to fail with a descriptive error.ZipException - NOTE that the
filter targets ONLY the specific library version matched, NOT its transitive dependencies.dependency - BE AWARE that buildscript (plugin) dependencies are excluded from
andsearch_dependency_sources
by default to reduce noise.read_dependency_sources - ALWAYS use
(root project) orsourceSetPath=":buildscript"
(subproject) to search or read plugin source code. This targets the virtualsourceSetPath=":app:buildscript"
source set which aggregates all classpath plugins.buildscript
Directives
- Identify Search Mode Authoritatively:
- DECLARATION: Best for classes, methods, or interfaces. Matches against the simple name (tokenized for CamelCase) and the full path (exact literal). All declaration searches are case-sensitive. Do NOT include keywords like
,class
, orinterface
. Supports exact names, exact FQNs, glob wildcards (e.g.,fun
,*
), and regular expressions. Partial package paths require wildcards (e.g., use**
to find*.MyClass
). You can target specific fields usingcom.example.MyClass
(discovery) orname:
(precision) prefixes.fqn: - FULL_TEXT: Best for literal strings, constants, and complex code patterns using Lucene. Case-insensitive.
- GLOB: Best for finding specific files (XML, properties, etc.) by name or extension. Case-insensitive.
- DECLARATION: Best for classes, methods, or interfaces. Matches against the simple name (tokenized for CamelCase) and the full path (exact literal). All declaration searches are case-sensitive. Do NOT include keywords like
- Invoke Precisely: ALWAYS set
explicitly if the intent is not a general full-text search. This improves result accuracy and reduces noise.searchType - Scope Surgically: Use
,projectPath
, orconfigurationPath
to narrow the search and improve performance if the target library's context is known. To search a plugin, usesourceSetPath
.sourceSetPath=":buildscript" - ALWAYS scope with a project, configuration, or source set (or use
) — unscoped search is no longer supported.gradleSource: true - Target Libraries Directly: Use the
parameter to filter searches to a single library. It supportsdependency
,group:name:version:variant
,group:name:version
, or justgroup:name
. This bypasses project-level index merging and provides instantaneous results from the global extracted source cache.group - Troubleshoot Targeted Searches: If a targeted search using the
parameter fails or returns no matches, usedependency
first to verify the exact coordinates (group, name, version, variant) of the dependency as resolved by Gradle.inspect_dependencies - Refresh Indices: Use
if project dependencies have recently changed to ensure the index is up-to-date.fresh: true - Use Returned Sources Root: Every response from
andread_dependency_sources
includes asearch_dependency_sources
header. Use this path withSources root: <absolute-path>
,rg
, or other shell tools for operations not covered by the MCP tools (e.g., regex-heavy searches). Because dependency directories are symlinks, always passast-grep
to--follow
:rg
.rg --follow <pattern> <sources-root> - Explore Packages Authoritatively: Use
with a dot-separated package path (e.g.,read_dependency_sources
) to list its direct symbols and sub-packages. This is backed by the symbol index and is more reliable than directory-based exploration for Kotlin projects.org.gradle.api - Analyze Implementation: Use
to retrieve the implementation logic. If the file is large, useread_dependency_sources
to read specific sections. You can target plugins by passingpagination
.sourceSetPath=":buildscript" - Trace Symbols Authoritatively: When encountering an unknown symbol, use
search to jump directly to its definition in the library. This is the only reliable way to understand exact behavior and available methods.DECLARATION
When to Use
Decision rule: If the question is "what does this API look like or how does it work?" — use this skill. If you need to run code to see what it does at runtime — use
(REPL). Read before you run.interacting_with_project_runtime
- API & Symbol Discovery: When you need to find the implementation, signature, or documentation of a class, interface, or method imported from a library.
- Library Usage Research: When understanding how to use a library's API by reading its internal implementation or looking for usage patterns in its source.
- Internal Logic Auditing: When researching how a dependency handles specific operations, edge cases, or performance-critical logic.
- Resource File Location: When searching for configuration files (XML, JSON, properties), specific named files (e.g.,
), or metadata (AndroidManifest.xml) packaged within library jars.build.gradle - Constant & Literal Research: When searching for specific constant values, error strings, or literal keys within external code.
Workflows
1. Tracing a Symbol from Project Code
- Identify the symbol name (e.g.,
) or fully qualified name from an import.JsonConfiguration - Call
.search_dependency_sources(query="<SymbolName>", searchType="DECLARATION", projectPath=":") - Identify the correct file path from the results.
- Call
to analyze the implementation.read_dependency_sources(path="<path>", projectPath=":")
2. Discovering API Usage through Source
- Search for a known entry point (e.g., a constructor or main class) using
orDECLARATION
.FULL_TEXT - Once the file is found, use
to read its source.read_dependency_sources - Look for internal calls, helper methods, or factory patterns to understand the library's preferred usage.
3. Searching for Constants or Error Codes
- Identify the constant name or a snippet of an error message.
- Call
(defaults tosearch_dependency_sources(query="\"<text>\"", projectPath=":")
).FULL_TEXT - Review matches to find where the value is defined or used.
Targeted Search for a Single Library
- Identify the dependency coordinates (e.g., from
or project files).inspect_dependencies - Call
.search_dependency_sources(query="<query>", dependency="<group:artifact>", projectPath=":") - The results will be scoped ONLY to that library, ensuring maximum speed and relevance.
Path Syntax and Targeted Searching
When reading specific dependency source files, it is STRONGLY RECOMMENDED to use the full path syntax including the
{group}/{artifact} prefix (e.g., path = "org.mongodb/mongodb-driver-sync/org/mongodb/client/MongoClient.kt"). The
dependency parameter should be reserved for filtering the scope of search_dependency_sources for performance, rather than as a way to shorten paths. This explicitly avoids Windows file system issues with colons.
Examples
Search for a specific class definition within a targeted library
{ "query": "MongoClient", "searchType": "DECLARATION", "dependency": "org.mongodb:mongodb-driver-sync", "projectPath": ":" }
// Reasoning: Using the 'dependency' parameter to target only the 'mongodb-driver-sync' library for a fast, focused search.
Read sources from a specific dependency
{ "path": "org.jetbrains.kotlinx/kotlinx-coroutines-core/kotlinx/coroutines/Job.kt", "projectPath": ":" }
// Reasoning: Reading 'Job.kt' using the recommended
{group}/{artifact} syntax.
Search for a specific class definition
{ "query": "JsonConfiguration", "searchType": "DECLARATION", "projectPath": ":" }
// Reasoning: Using DECLARATION search to find a class named 'JsonConfiguration' across both name and FQN fields, scoped to the root project.
Search with field-specific precision
{ "query": "fqn:kotlinx.serialization.json.*", "searchType": "DECLARATION", "projectPath": ":" }
// Reasoning: Using the 'fqn:' prefix with a wildcard to find all declarations within a specific package literal.
Search with name-specific discovery (CamelCase)
{ "query": "name:Configuration", "searchType": "DECLARATION", "projectPath": ":" }
// Reasoning: Using the 'name:' prefix to find classes like 'JsonConfiguration' via CamelCase tokenization.
Trace a method signature using wildcards
{ "query": "encodeTo*", "searchType": "DECLARATION", "projectPath": ":" }
// Reasoning: Finding all definitions starting with 'encodeTo' across both name and FQN fields.
Use regular expressions for complex matching
{ "query": "fqn:/.*\.internal\..*/", "searchType": "DECLARATION", "projectPath": ":" }
// Reasoning: Using a regular expression on the 'fqn' field to find all internal declarations.
Search for a constant value assignment
{ "query": "DEFAULT_TIMEOUT_MS \\: 5000", "projectPath": ":" }
// Reasoning: Using FULL_TEXT (default) with escaped colon to find a specific constant assignment.
Locate a specific file by its exact name
{ "query": "**/AndroidManifest.xml", "searchType": "GLOB", "projectPath": ":" }
// Reasoning: Using GLOB search to find a specific file by name across the dependency graph.
Read a specific dependency source file
{ "path": "kotlinx/serialization/json/Json.kt", "projectPath": ":" }
// Reasoning: Reading the implementation of a known class path identified from previous search results, scoped to the root project.
Explore a package via its FQN
{ "path": "org.gradle.api", "projectPath": ":" }
// Reasoning: Listing the direct symbols and sub-packages of 'org.gradle.api' using index-backed exploration, scoped to the root project.
Resources
- Lucene Query Syntax: Refer to the tool description for
for details on complex queries and escaping.search_dependency_sources - Troubleshooting Targeted Searches: If
filter fails, rundependency
to confirm the exact coordinates.inspect_dependencies