DEV Community

Stop Claude Code Interface Blindness: Hook Eclipse JDT LS via MCP for AST-Aware Java Refactoring

Why Most Developers Get This Wrong

  • Relying on grep-based search: Claude Code's default file search tools treat Java like raw text, completely missing runtime polymorphism and complex @Qualifier annotations.
  • Ignoring the Model Context Protocol (MCP): Developers waste massive amounts of context window tokens pasting entire classes instead of letting Claude query a local language server.
  • Assuming LLMs understand implicit Spring hierarchies: Claude 3.5 Sonnet cannot trace a PaymentGateway interface to its StripePaymentServiceImpl implementation across deep Gradle subprojects without semantic AST help.

The Right Way

Expose your local Eclipse JDT Language Server (JDT LS) to Claude Code using an MCP wrapper to enable precise, compiler-grade semantic searches.

  • Spin up eclipse.jdt.ls as a background daemon on your local development machine.
  • Configure Claude Code's mcpConfig.json to route Java-specific queries like find-implementations directly to the JDT LS instance.
  • Force the agent to query the actual AST to resolve complex @Autowired bean hierarchies before generating refactoring diffs.

Want to go deeper? javalld.com - machine coding interview problems with working Java code and full execution traces.

Show Me The Code (or Example)

This mcpConfig.json configuration bridges Claude Code to your local JDT LS instance, giving the LLM direct access to Java's compiler APIs:

{
  "mcpServers": {
    "jdtls-ast-bridge": {
      "command": "node",
      "args": ["/usr/local/bin/jdtls-mcp-bridge.js"],
      "env": {
        "JDTLS_PATH": "/opt/eclipse.jdt.ls/plugins/org.eclipse.equinox.launcher_1.6.900.jar",
        "WORKSPACE_DIR": "${userHome}/projects/enterprise-app"
      }
    }
  }
}

Key Takeaways

  • Stop treating Java like Python; compiler-centric languages require AST-aware LLM tools to prevent refactoring regressions.
  • MCP is the bridge that turns Claude Code from a fast-typing intern into a staff-level engineer that respects your type system.
  • Eliminate hallucinated method signatures by forcing Claude to verify method overrides against the actual JDT LS compilation unit before writing code.

Comments

No comments yet. Start the discussion.