graphify-mcp

graphify-mcp

A Python MCP server that exposes the Graphify knowledge graph as MCP tools, prompts, and resources, enabling AI assistants to explore codebases through a token-budgeted, structural graph during development.

Category
访问服务器

README

graphify-mcp

CI License: MIT Python 3.10+

A Python MCP server that exposes the Graphify knowledge graph as MCP tools, prompts and resources — so an AI assistant can explore your codebase through the graph during development, cheaply (token-budgeted) and structurally.

Note: Graphify ships its own embedded MCP server (graphify ./raw --mcp). This project adds analysis tools, token-budgeted subgraph extraction, git freshness checks, per-community resources, reusable prompts, and LLM-friendly tool annotations + structured (JSON) output on top.

Installation

# graphify-mcp itself
pip install graphify-mcp

# plus the Graphify CLI it wraps (needed for build/query/path/explain/add)
pip install graphifyy && graphify install

From source:

git clone https://github.com/yasinyaman/graphify-mcp
cd graphify-mcp
pip install -e ".[dev]"

Running

GRAPHIFY_PROJECT_DIR=/path/to/repo graphify-mcp-server
# equivalently, collision-proof:
GRAPHIFY_PROJECT_DIR=/path/to/repo python -m graphify_mcp

Heads-up: graphifyy ships its own graphify-mcp console script (its embedded server), so if both packages are installed the bare graphify-mcp command resolves to whichever was installed last. Use graphify-mcp-server or python -m graphify_mcp to always launch this server.

Claude Code

Copy mcp.json to a .mcp.json at your project root. GRAPHIFY_PROJECT_DIR: "." uses the project root.

Claude Desktop / Cowork

Add the contents of claude_desktop_config.json to your Claude Desktop config:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

Transport (stdio default, optional HTTP)

stdio is the default and the right choice for a per-developer local server. To serve over HTTP instead (e.g. a shared graph for a team or a web MCP client):

GRAPHIFY_TRANSPORT=streamable-http GRAPHIFY_HOST=127.0.0.1 GRAPHIFY_PORT=8000 \
  GRAPHIFY_PROJECT_DIR=/path/to/repo graphify-mcp-server

Any HTTP transport force-enables path containment (GRAPHIFY_RESTRICT_PATHS) so a network client can't drive graphify_build to extract arbitrary filesystem paths. HTTP binds 127.0.0.1 by default; if you expose it beyond localhost (GRAPHIFY_HOST=0.0.0.0), put it behind your own auth / reverse proxy.

Environment variables

Variable Default Description
GRAPHIFY_PROJECT_DIR . Project root to extract the graph from
GRAPHIFY_OUT_DIR graphify-out Output folder name
GRAPHIFY_BIN graphify CLI path
GRAPHIFY_TIMEOUT 600 CLI timeout (seconds)
GRAPHIFY_RESTRICT_PATHS 0 Confine graphify_build's path to the project dir (auto-on for HTTP)
GRAPHIFY_TRANSPORT stdio stdio | streamable-http | sse
GRAPHIFY_HOST 127.0.0.1 Bind host for HTTP transports
GRAPHIFY_PORT 8000 Bind port for HTTP transports

Tools

CLI-backed (the first two write state; the rest are read-only):

Tool Purpose
graphify_build Build/update the graph (--update, --cluster-only, --mode deep)
graphify_add Add a source by URL (arXiv, tweet)
graphify_query Natural-language query (--dfs, --budget)
graphify_path Exact path between two nodes
graphify_explain Everything about a node

graph.json analysis (read-only, no CLI needed, as_json=True for structured output):

Tool Purpose
graphify_overview Call first — size, god nodes, communities, surprises, suggested next steps
graphify_god_nodes Most connected nodes
graphify_communities Leiden community summaries
graphify_surprises Unexpected cross-domain connections
graphify_search Node search
graphify_neighbors 1-hop neighbors of a node
graphify_subgraph Token-budgeted BFS subgraph around a node — the cheap way to feed the model just the relevant slice
graphify_node_details Node metadata: type, source file/line, docstring, community
graphify_freshness Is the graph stale vs. git HEAD? Returns recommended_action (fresh/update/rebuild) + reason — deletions/large changes steer to a full rebuild
graphify_validate Lint the graph for dangling/duplicate/self-loop edges and orphan nodes (read-only)

Semantic naming (uses the host model via MCP sampling — no API key — or a backend key):

Tool Purpose
graphify_sampling_status Capability test: reports whether the client supports host-LLM sampling, whether a backend key is set, and which method will be used
graphify_label_communities Give Leiden communities human-readable names. method="auto" (sampling → key → placeholder), "sampling", "cli", or "placeholder"

Naming communities without an API key (MCP sampling)

The Leiden clustering is keyless, but turning Community 7 into Authentication needs a model. Three ways, in graphify_label_communities's preference order:

  1. Host-LLM sampling — the server asks the connected client to run the completion via MCP sampling/createMessage. The model the user already uses (e.g. Claude in a sampling-capable client) does the naming; the server holds no API key. Subject to client support — call graphify_sampling_status first; it degrades gracefully when unsupported.
  2. Backend API key (method="cli") — set GEMINI_API_KEY / OPENAI_API_KEY / ANTHROPIC_API_KEY / … (or run a local ollama) and graphify's own backend names them. This option always remains available.
  3. Placeholders — no model anywhere: names stay Community N.

Resources

  • graphify://report — GRAPH_REPORT.md
  • graphify://graph — graph.json (raw)
  • graphify://community/{id} — per-community wiki (members + internal/boundary edges)

Prompts

Reusable templates that orchestrate the tools for the assistant:

  • onboard — orient to the codebase (overview → communities → subgraphs → surprises → summary)
  • trace_bug(symptom) — find likely root-cause locations through the graph
  • explain_flow(flow) — end-to-end walkthrough of a named flow with file:line refs

LLM-friendliness

  • Tool annotations (readOnlyHint, destructiveHint, titles) tell the model which tools are safe to call freely vs. which mutate state.
  • Server instructions describe the recommended flow (overview → targeted subgraph/query → build update).
  • as_json output on every analysis tool returns structured data the model can chain on instead of re-parsing prose.
  • Token budgeting (graphify_subgraph) keeps context small on large graphs — the core of Graphify's ~71× compression.
  • Host-LLM sampling (graphify_label_communities) lets the server borrow the client's model via MCP sampling/createMessage, so semantic naming works with no server-side API key — with a capability test (graphify_sampling_status) and a backend-key fallback.

Typical workflow

  1. graphify_overview() — orientation
  2. graphify_communities() — subsystems
  3. graphify_subgraph("SomeNode") — token-cheap targeted exploration
  4. graphify_query("how does the auth flow work?") — questions
  5. After code changes: graphify_freshness() → graphify_build(".", update=True)

Project layout

graphify-mcp/
├── src/graphify_mcp/      # package (server.py, __init__.py)
├── tests/                 # pytest suite + fixture graph.json
├── .github/workflows/     # CI (ruff + pytest, py 3.10–3.12)
├── pyproject.toml         # packaging + console script
├── mcp.json               # Claude Code example config
└── claude_desktop_config.json

Development

pip install -e ".[dev]"
ruff check .
pytest -q

See CONTRIBUTING.md. Licensed under MIT.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选