Skip to main content

MCP server for resolving project dependencies and providing local source code paths

Project description

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):

  1. deps.dev API -- Google's unified package-to-repo mapping (Maven, PyPI, npm, Go, etc.). Responses are cached locally.
  2. Registry fallback -- Maven Central POM <scm> element; PyPI JSON API project_urls.
  3. Heuristics -- Maven groupId patterns (com.github.*), package name matching.

Clone and Worktree Management

  • Full clones into <output_dir>/<hostname>/<owner>/<repo>
  • git fetch --all --tags before 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.json for 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).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

libsrc_mcp-0.1.0.tar.gz (144.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

libsrc_mcp-0.1.0-py3-none-any.whl (29.1 kB view details)

Uploaded Python 3

File details

Details for the file libsrc_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: libsrc_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 144.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for libsrc_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 90f89d1ee3b999e30b135ec45895ed8113a598d842943ff2144870c8b4f95acb
MD5 f9c79d7a47a2640a9e8fbc28386be4da
BLAKE2b-256 c69efac20602d055e97be35a67ffe519e4f009a27f00ca9df848a56facd116a9

See more details on using hashes here.

File details

Details for the file libsrc_mcp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: libsrc_mcp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 29.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for libsrc_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fd56d16988355d24ce3723e7726f1a81f7c186730babe623278ebb5f36a2c7cf
MD5 fb9f890f21353748467f1902a2842421
BLAKE2b-256 6627540bc0446685d78d9d17af5c1741d172103887e5a846245401c144c94e20

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page