« All posts

kotlin-lib-mcp: an MCP server exposing real sources of any Maven library to AI

kotlin-lib-mcp is an open-source MCP server letting AI assistants read real Maven library sources, API surface, and KDoc directly.

kotlin-lib-mcp is an MCP server that gives AI assistants like Claude Code or Claude Desktop direct access to the actual sources, public API, and KDoc of any Maven-published Kotlin or Java library. The goal is to let models answer from real code instead of hallucinating APIs from training data.

Given a library coordinate (e.g. io.ktor:ktor-client-core:3.5.1), the server downloads the sources jar and parses it using the Kotlin Analysis API (K2/FIR standalone), exposing 10 tools covering public API surface, signatures, KDoc, raw source, full-text search, dependency trees, and version lookup. Results are cached on disk and also exposed as MCP resources for reuse.

Kotlin-specific challenges included resolving per-target KMP sources jars via .module Gradle metadata, and isolating the version-fragile Analysis API behind an interface that gracefully degrades to PSI-only signatures when type resolution fails. The project is built with Kotlin Multiplatform and ships an optional Compose Desktop dashboard for control, logs, and cache browsing. The newly released v0.2.0 adds MCP resource templates, server-to-client log forwarding, fetch progress notifications, and SLSA build-provenance attestations in its release pipeline — giving engineers a more grounded, verifiable way to bring AI-assisted coding closer to actual library internals.