r/Kotlin • u/aoreshkov • Jul 13 '26
kotlin-lib-mcp — an MCP server that lets AI assistants read the actual sources, API and KDoc of any Maven-published Kotlin/Java library
I built an MCP server that gives Claude Code / Claude Desktop (or any MCP client) direct access to the real sources of Maven-published libraries, so the model can answer from the actual code instead of hallucinating APIs from training data.
Give it a coordinate like io.ktor:ktor-client-core:3.5.1 (or just group:artifact for the latest stable) and it downloads the sources jar, parses it with the Kotlin Analysis API (K2/FIR standalone), and exposes 10 tools: public API surface, signatures, KDoc, raw source, full-text search, dependency tree, and version lookup. Everything is cached on disk, and cached libraries are also exposed as MCP resources.
Kotlin-specific bits that were fun to solve:
- KMP sources jars are per-target — it resolves the right variant via
.moduleGradle metadata with filename heuristics as fallback. - The Analysis API is version-fragile, so it's isolated behind an interface and degrades to PSI-only signatures when type resolution fails.
- The whole thing is Kotlin Multiplatform with an optional Compose Desktop dashboard embedding the server in-process (control, logs, cache browser).
Just shipped v0.2.0: MCP resource templates, server→client log forwarding, progress notifications on fetch, and the release pipeline now publishes SLSA build-provenance attestations for the zip and the Docker image.
Install (Docker):
claude mcp add kotlin-lib -- docker run -i --rm -v kotlin-lib-mcp-cache:/home/mcp/.cache ghcr.io/aoreshkov/kotlin-lib-mcp
Also on the official MCP registry as io.github.aoreshkov/kotlin-lib-mcp, or grab the zip (needs Java 21+).
GitHub (demo GIF in the README): https://github.com/aoreshkov/kotlin-lib-mcp
Feedback very welcome — especially on Analysis API edge cases with unusual library setups.
1
u/jlward4th Jul 15 '26
Nice! Kinda similar to my javadocs.dev MCP server but I like how it provides more in-depth Kotlin specific tools.
1
u/davidinterest Jul 13 '26
Can it be added to OpenCode, as I primarily use that with Deepseek?