molmcp
A graph-based codebase capability discovery engine for LLM agents, exposing indexed code symbols, signatures, and relationships over MCP to enable agents to find and use tools without guessing names.
README
<h1 align="center">molmcp</h1>
<p align="center"> <strong>The MCP foundation for the MolCrafts ecosystem</strong> </p>
<p align="center"> <a href="https://pypi.org/project/molcrafts-molmcp/"><img alt="PyPI" src="https://img.shields.io/pypi/v/molcrafts-molmcp?logo=python&logoColor=white&label=PyPI"></a> <a href="https://pypi.org/project/molcrafts-molmcp/"><img alt="Python" src="https://img.shields.io/pypi/pyversions/molcrafts-molmcp.svg"></a> <a href="https://github.com/MolCrafts/molmcp/blob/master/LICENSE"><img alt="License" src="https://img.shields.io/badge/license-BSD--3--Clause-blue"></a> <a href="https://github.com/MolCrafts/molmcp/actions"><img alt="CI" src="https://github.com/MolCrafts/molmcp/actions/workflows/ci.yml/badge.svg"></a> </p>
<p align="center"> <a href="https://molcrafts.github.io/molmcp/"><strong>Documentation</strong></a> · <a href="https://molcrafts.github.io/molmcp/get-started/quickstart/"><strong>Quickstart</strong></a> · <a href="https://github.com/MolCrafts/molmcp/issues"><strong>Issues</strong></a> </p>
Why molmcp
The MolCrafts ecosystem ships many packages — molpy, molcfg, molexp, molpack, mollog, molq, molrec, molvis — and each of them benefits from being callable by an LLM agent. The hard part is discovery: an agent needs to find out what a codebase actually provides instead of guessing function, class, or tool names.
molmcp solves this with a graph-based codebase capability discovery engine. It statically indexes a repository into a code graph — symbols, signatures, docstrings, relationships, examples, and tests — and exposes that graph to agents over the Model Context Protocol.
It does two things:
- Runs a discovery engine that indexes any codebase (a local path, an installed package, or — soon — a GitHub repository) into a snapshot-cached code graph, and answers structured queries against it.
- Defines a Provider plugin contract for the narrow class of capabilities discovery cannot answer — stateful queries against local runtime state (a jobs DB, a workspace catalog) — under a single coordinated MCP server with shared security defaults.
molmcp core imports nothing from the MolCrafts packages. That's the point — it's pure infrastructure, and any codebase can be indexed without molmcp depending on it.
Discovery, not guessing
The discovery engine is built so an agent resolves capabilities from indexed code structure rather than guessing names:
- It parses source with a per-language analyzer (Python today on the stdlib
astmodule; TypeScript, Rust, and C++ slot in behind the sameLanguageAnalyzerinterface) into a shared graph of nodes and edges. - A two-phase pipeline — extraction then resolution — links calls, base classes, imports, tests, and docstring examples into a connected graph.
- The graph is stored as one SQLite database per source snapshot, keyed on a content hash (local) or commit SHA (GitHub) — never a branch name — so cached results are always tied to exact source.
- Every tool response carries a
snapshotblock, so an agent always knows which revision it is looking at.
Discovery tools
When discovery sources are configured, molmcp exposes six composable, graph-backed tools (all read-only):
| Tool | Purpose |
|---|---|
molmcp_find_capability |
Primary tool — describe a task, get ranked symbol matches with signatures, examples, tests, and callers. |
molmcp_search_symbols |
Search indexed symbols by name, qualname, or summary. |
molmcp_describe_symbol |
Full detail for one symbol, optionally with source code. |
molmcp_relations |
Walk the graph from a symbol: callers, callees, implementers, subclasses, references, examples, tests, impact. |
molmcp_outline |
Map a source's packages/modules to their symbols — the "where do I look" tool. |
molmcp_refresh |
Force a fresh re-index of a source. |
Provider plugin contract
Discovery answers most questions. For the rest — queries that depend on local runtime state no static analysis can recover — molmcp defines a Provider plugin contract. A Provider earns a tool slot only when all four conditions hold: stable signature, read-only/idempotent, every-session frequency, single-shot answer. See docs/concepts/provider-design.md.
Install
pip install molcrafts-molmcp
Requires Python ≥ 3.12. The PyPI distribution is molcrafts-molmcp; the import name is molmcp. The discovery engine adds no required runtime dependency — it uses the standard library.
60-second quickstart
Start an MCP server that indexes the installed MolCrafts packages:
python -m molmcp
molmcp auto-detects whichever of {molpy, molpack, molrs, molq, molexp} are importable and registers discovery over them. Point it anywhere with --source:
python -m molmcp --source pkg:molpy --source /path/to/a/repo
Wire it into Claude Code:
claude mcp add molcrafts -- python -m molmcp
Inspect the engine — or verify it works — without an MCP client:
molmcp discovery verify pkg:molpy # self-check: counts, FTS, sample query
molmcp discovery index pkg:molpy
molmcp discovery outline pkg:molpy
molmcp discovery query pkg:molpy "radial distribution function"
molmcp discovery verify prints a health report and exits non-zero on
failure, so it doubles as a CI/setup check. See the
discovery engine guide
for the full verification walkthrough.
Source specs
A discovery source is one of:
path/to/repo— a local directory.pkg:<name>— an installed Python package (resolved by import name).github:owner/repo[@ref]— a GitHub repository (downloaded at a resolved commit;GITHUB_TOKENis used when set).
Architecture
┌────────────────────────────────────┐
│ MCP clients │
│ (Claude Code, Claude Desktop, …) │
└──────────────┬─────────────────────┘
│ stdio / http / sse
▼
┌────────────────────────────────────┐
│ molmcp │
│ • DiscoveryProvider (molmcp_* ) │
│ • Discovery engine core │
│ source → snapshot → extract │
│ → resolve → SQLite graph │
│ • Provider contract + discovery │
│ • PathSafety / ResponseLimit │
│ • Annotations validator │
└──────────────┬─────────────────────┘
│
┌──────────────────┼──────────────────────┐
▼ ▼ ▼
MolqProvider MolexpProvider third-party providers
(jobs.db) (workspace.json (entry-point group
catalog) molmcp.providers)
The discovery engine core (molmcp.discovery) is MCP-free — it can be imported, scripted, and tested without FastMCP. Only molmcp.discovery.provider touches MCP.
Adding domain tools
Before adding a Provider tool, check it against the four-condition rule in docs/concepts/provider-design.md. If a tool earns a slot:
from fastmcp import FastMCP
from mcp.types import ToolAnnotations
class MolpackProvider:
name = "molpack"
def register(self, mcp: FastMCP) -> None:
@mcp.tool(annotations=ToolAnnotations(readOnlyHint=True))
def list_pack_targets(workdir: str) -> list[dict]:
"""Return the in-progress pack targets cached under workdir."""
from molpack import workspace
return [t.to_dict() for t in workspace.scan(workdir).targets]
Declare the entry point in the package's pyproject.toml:
[project.entry-points."molmcp.providers"]
molpack = "molpack_mcp:MolpackProvider"
python -m molmcp discovers it automatically.
Status
Alpha. The discovery engine and Provider contract may shift before 1.0. Pin to molcrafts-molmcp >= 0.2, < 0.3.
Contributing
git clone https://github.com/MolCrafts/molmcp.git
cd molmcp
pip install -e ".[dev]"
pytest
License
BSD-3-Clause. See LICENSE.
Acknowledgements
molmcp is part of the MolCrafts project. It implements the Model Context Protocol using the fastmcp server library.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。