libsrc
An MCP server that resolves project dependencies and provides local source code paths for AI agent inspection. It auto-detects the build system, resolves dependencies, looks up source repositories, clones them, and checks out the correct version as a git worktree -- all in a single tool call.
Supported Ecosystems
- Java: Maven (
pom.xml), Gradle (build.gradle,build.gradle.kts) - Python: Poetry (
pyproject.toml+poetry.lock), uv (pyproject.toml+uv.lock)
Plain pip / requirements.txt is not supported (no reliable version resolution without a lock file).
Installation
# Install as a tool
uv tool install libsrc-mcp
# Or run directly without installing
uvx libsrc-mcp serve
# Auto-register in detected AI coding tools
libsrc-mcp install
Auto-install into AI tools
libsrc-mcp install detects installed AI coding tools and adds the MCP server to their configs. Supported: Claude Code, Cursor, Windsurf, Codex CLI, Gemini CLI, JetBrains Junie, VS Code Copilot. Skips tools that aren't installed or already configured.
libsrc-mcp install
libsrc-mcp install --port 8080 # if using a non-default port
Configuration
Create ~/.config/libsrc/config.yml (all fields optional):
# Directory where library sources are cloned (default: ~/devel/libs/)
output_dir: ~/devel/libs/
# HTTP server port (default: 7890)
port: 7890
# Trusted git hostings for cloning (default: github.com, gitlab.com)
trusted_hosts:
- github.com
- gitlab.com
# deps.dev API cache TTL in hours (default: 24)
deps_dev_cache_ttl: 24
Usage
Start the server
libsrc-mcp serve
libsrc-mcp serve --port 8080
Systemd service (Linux)
mkdir -p ~/.config/systemd/user
cp systemd/libsrc-mcp.service ~/.config/systemd/user/
systemctl --user daemon-reload
systemctl --user enable --now libsrc-mcp
Worktree cleanup
Worktrees not accessed for 7+ days are cleaned up automatically on server startup. Manual cleanup:
libsrc-mcp cleanup
MCP Tool: get_library_sources
| Parameter | Type | Description |
|---|---|---|
project_dir |
string |
Absolute path to the project root directory. Build system is auto-detected. |
library_name |
string? |
Substring filter against full identifier (e.g. "hibernate" matches org.hibernate:hibernate-core:6.4.1). When omitted, lists dependencies without cloning. |
transitive |
bool |
Include transitive dependencies (default: false). |
Without library_name: returns the dependency listing for discovery.
With library_name: resolves source repos, clones, creates version worktrees, returns local paths.
How It Works
Dependency Resolution
Lock files are preferred when available, CLI tools are the fallback:
| Ecosystem | Lock File (preferred) | CLI Fallback |
|---|---|---|
| Maven | — | mvnw dependency:tree -DoutputType=json |
| Gradle | — | gradlew dependencies --configuration runtimeClasspath |
| Poetry | poetry.lock (TOML) |
poetry show --tree |
| uv | uv.lock (TOML) |
uv tree |
Build tool wrappers are preferred: mvnw > mvn, gradlew > gradle.
Source Repository Discovery
Layered approach (first match wins):
- deps.dev API -- Google's unified package-to-repo mapping (Maven, PyPI, npm, Go, etc.). Responses are cached locally.
- Registry fallback -- Maven Central POM
<scm>element; PyPI JSON APIproject_urls. - Heuristics -- Maven groupId patterns (
com.github.*), package name matching.
Clone and Worktree Management
- Full clones into
<output_dir>/<hostname>/<owner>/<repo> git fetch --all --tagsbefore each tag lookup- Version worktrees at
<clone_path>.versions/<version>(enables parallel agents on different versions) - Tag matching: tries
v{ver},{ver},release-{ver},{artifact}-{ver}, suffix/contains fallback - Strips release qualifiers (
.Final,.RELEASE,.GA) for projects that omit them from tags - Monorepo dedup: same repo+version = one worktree shared across artifacts
- File-based locking (
fcntl.flock) for concurrent safety
Caching
- Dependency cache:
~/.cache/libsrc/deps/keyed by content hash of all build/lock files (invalidates on any file change) - deps.dev cache:
~/.cache/libsrc/depsdev/with configurable TTL - Worktree tracker:
~/.cache/libsrc/worktree-access.jsonfor LRU cleanup
MCP Client Configuration
Claude Code
claude mcp add libsrc --transport http http://127.0.0.1:7890/mcp
VS Code Copilot (.vscode/mcp.json)
{
"servers": {
"libsrc": { "type": "http", "url": "http://127.0.0.1:7890/mcp" }
}
}
Other tools
{
"mcpServers": {
"libsrc": { "type": "http", "url": "http://127.0.0.1:7890/mcp" }
}
}
See docs/mcp-auto-install.md for tool-specific config details (Cursor, Windsurf, Gemini CLI, Codex CLI, Cline, Continue.dev, JetBrains Junie).
Releasing
Version is derived automatically from git tags via hatch-vcs — no manual version bumping needed.
git tag v<version>
git push origin v<version>
The publish.yml GitHub Action builds and publishes to PyPI automatically via trusted publishing.
Metadata
Release files for libsrc-mcp 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| libsrc_mcp-0.1.2.tar.gz | 148.2 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| libsrc_mcp-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 177.6 kB
Release files / libsrc_mcp-0.1.2.tar.gz
| Download URL | libsrc_mcp-0.1.2.tar.gz |
|---|---|
| Size | 148.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
053391ec3bd70461ac3dccc93cf7fe63074c550e610d7fb3a32d7e803486dfc8
|
|
BLAKE2b-256 checksum How to use checksums |
994f11a52de13a7a3fc4ce0096030a8bd182c060ecdb547e970285438b02ec85
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 8, 2026.
Transparency logRelease files / libsrc_mcp-0.1.2-py3-none-any.whl
| Download URL | libsrc_mcp-0.1.2-py3-none-any.whl |
|---|---|
| Size | 29.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7df04795885af7bd206bab0edc7a1d1d1df05e03c945eae984723cdb27f26d23
|
|
BLAKE2b-256 checksum How to use checksums |
ca69c6a76fdec49dbf45b8378589be48aff29ad43ed3e0a94f02c9c85006d9d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 8, 2026.
Transparency logSecurity for libsrc-mcp 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for libsrc_mcp-0.1.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 8, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.