libsrc
Resolves project dependencies and provides local source code paths for AI agent inspection by auto-detecting the build system, resolving dependencies, cloning source repos, and checking out correct versions as git worktrees.
README
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.
Why
AI coding agents work best when they can inspect the source code of libraries used in a project. But getting at those sources is harder than it should be:
- Published packages are opaque -- Java distributes compiled JARs, and even when a
-sources.jaris available, it has to be fetched separately and extracted. Python wheels contain bytecode and stripped metadata. In both cases, getting readable source into the agent's hands is needlessly hard. - Packages lose context -- Original source repositories often contain documentation, examples, and markdown files that are stripped from published packages.
- Exact versions matter -- Agents need the precise version a project depends on, not "latest" or "close enough". libsrc resolves the exact version from lock files and build tools, then checks out the matching git tag.
- Standard tools just work on cloned repos -- Giving an agent a local path to a git checkout lets it explore with standard file tools, easily and predictably. No JAR extraction, no archive unpacking, no guessing -- just a normal directory of source files.
- Parallel-friendly -- Each version gets its own git worktree, so multiple agents (or the same agent across tasks) can inspect different versions of the same library concurrently without conflicts.
libsrc bridges this gap: one tool call turns a dependency name into a local path the agent can explore immediately.
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.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。