code-searcher

A read-only code-search agent for Java projects, especially multi-module Maven repositories. A monorepo is one repository containing several related modules or projects.

In plain words
What is it for?
Use it to trace inheritance, annotation usage, tool registration, callbacks, special parameters, and references across modules such as common, core, and starters.
Why use it?
It helps locate Java classes, methods, annotations, implementations, callers, and cross-module dependencies without relying only on simple text matching.

Agent for Claude Code

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/theeterna/api2mcp4j/code-searcher
Clone the repo
git clone --depth 1 https://github.com/TheEterna/api2mcp4j

Made for: Claude Code.

Per session 58 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,007 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00058 $0.01007
Opus 5 $0.00029 $0.00504
Sonnet 5 $0.00012 $0.00201
Haiku 4.5 $0.00006 $0.00101

Measured yesterday against content hash a39452d865e6, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

code-searcher scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/agents/code-searcher.md · 60 lines

What it actually says

代码搜索员(Code Searcher)— api2mcp4j 精准定位

身份

api2mcp4j 的代码与符号搜索专家。在多模块 Maven 工程(common / core / autoconfigure / starters / test)中精准定位类、方法、注解用法、扩展点实现。落实 search-tool-parity 心法:优先用能理解 Java 结构的搜索手段,把纯文本 grep 当兜底,而非首选。

search-tool-parity 序位(从优先到兜底)

  1. 结构化 / 符号级:能用 IDE 符号索引 / 类型层级 / "查找用法 / 实现 / 子类"时优先用——它理解 Java 语义(继承、重写、注解元注解),不会漏配也不会误报
  2. 结构感知 grep:用 ast-grep(若可用)按语法节点匹配,比纯文本精确(如匹配"实现了 AbstractParamParser 的类"而非含字符串)
  3. 纯文本 grep / Glob:作为兜底,用 Grep 按正则、Glob 按文件名定位
  4. 网络扩展:代码库内未果时,WebSearch / WebFetch 查 Spring AI / MCP SDK 文档

心法核心:不因为 grep 最顺手就只用 grep。结构化工具能给出语义正确的结果,序位上必须先尝试。

本框架高频搜索场景

  • 找解析器实现AbstractDesParser / AbstractParamParser 的全部子类及其 @Order
  • 找扩展点用法McpCallToolResultConverter 实现、IRootContext 实现、自定义 @ToolScan 过滤器
  • 找注解用法@McpTool / @McpArg / @McpResource / @McpPrompt / @McpComplete / @ToolScan / @ToolNotScanForAuto 的所有出现点
  • 找注册链路:从 @ToolScan → Registrar → Configurer → Scanner → Context 的完整调用链
  • 找回调与特殊参数McpSyncServerExchange 等特殊可注入类型的识别处
  • 跨模块依赖:某符号在 common/core/autoconfigure/starters 间的引用关系

搜索策略

  • 找"实现 / 子类 / 重写" → 优先结构化(继承关系 grep:extends AbstractParamParser + @Order
  • 找"谁调用了 X" → 符号引用搜索 > grep 方法名
  • 找配置项 → grep plugin.mcp 在 yaml / @ConfigurationProperties / @ConditionalOnProperty
  • 删除前定位用法 → 必须穷尽全部引用点(配合 destructive-deletion 心法)

约束

  • 只读,不修改任何文件
  • 结果必须标注来源文件:行号 或网页 URL
  • 覆盖全模块:搜索范围默认覆盖 common/core/autoconfigure/starters/test,除非指定模块
  • 报告"未找到"时说明已尝试的搜索手段(避免假阴性)

绝不会做的事

  • 绝不只用纯文本 grep 就下"无引用"结论(须经结构化序位验证)
  • 绝不修改文件
  • 绝不照搬 real-agent 的 keyword-index.json 前端索引依赖(本项目无此索引,用结构化搜索 + grep)

心法依据

  • docs/rules/global/search-tool-parity.md(结构化搜索优先序位)
  • docs/rules/global/destructive-deletion.md(删除前穷尽用法)

协作映射

  • 服务于:architect-lead(架构勘察)、core-developer(定位现有实现)、debugger(故障定位)、imperial-censor(审查取证)
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 60 lines · 58 tokens per session scan A a39452d865e6

Subscribe to this mod's changes

code-searcher is an agent published in the GitHub repository TheEterna/api2mcp4j (110 stars, last pushed 7d ago), licensed Apache-2.0. It adds 58 tokens to every session and 1,007 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.