mcp-graphify-autotrigger
Provides efficient knowledge-graph queries and unrestricted shell delegation for AI agents, reducing token usage by 80-150x and bypassing app tier restrictions.
README
<p align="center"> <img src="./assets/banner.svg" alt="mcp-graphify-autotrigger" width="100%"/> </p>
<p align="center"> <a href="https://github.com/ChharithOeun/mcp-graphify-autotrigger/actions/workflows/ci.yml"><img src="https://github.com/ChharithOeun/mcp-graphify-autotrigger/actions/workflows/ci.yml/badge.svg" alt="CI"/></a> <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"/></a> <a href="https://www.python.org/downloads/"><img src="https://img.shields.io/badge/python-3.10+-blue.svg" alt="Python 3.10+"/></a> <a href="https://modelcontextprotocol.io"><img src="https://img.shields.io/badge/MCP-ready-7E22CE.svg" alt="MCP ready"/></a> <a href="https://gofastmcp.com"><img src="https://img.shields.io/badge/FastMCP-3.0+-0EA5E9.svg" alt="FastMCP 3.0+"/></a> <img src="https://img.shields.io/github/stars/ChharithOeun/=flat&logo=github" alt="GitHub Stars"/> <img src="https://img.shields.io/github/last-commit/ChharithOeun/=flat" alt="Last Commit"/> <img src="https://img.shields.io/github/issues/ChharithOeun/=flat" alt="Issues"/> <img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat" alt="PRs Welcome"/> <a href="https://buymeacoffee.com/chharith"><img src="https://img.shields.io/badge/%E2%98%95-Buy%20Me%20A%20Coffee-FFDD00?style=flat&logoColor=white" alt="Buy Me A Coffee"/></a> </p>
<p align="center"> <strong>Auto-trigger graphify knowledge-graph queries on every LLM prompt + MCP shell delegation for Claude Code / Cowork agents.</strong> <br/> Turn 200K-token codebase context dumps into 2K-token graph queries. Give your AI agent unrestricted shell autonomy when tier-restricted apps get in the way. </p>
Why
Token savings - concrete
| Approach | Tool calls | Tokens (avg) | Cost @ Sonnet 4 |
|---|---|---|---|
| read + grep | 30+ | 150K-300K | .45-.90 |
| graphify query | 1 | ~2K | .006 |
Net 80-150x reduction on cross-cutting code questions. The auto-trigger classifier decides per-prompt whether to query the graph, so simple fix login.py:42 prompts pay no extra cost.
Autonomy - concrete
Claude Code / Cowork enforces tier-based restrictions: terminals are click-only, browsers are read-only. Without delegation, an agent debugging your Windows machine can't pip install, can't git commit, can't run any shell command. With delegate_shell it routes through your unrestricted Python process: full autonomy, audit-logged, your config flag away from disabling.
How the auto-trigger decides
flowchart TD
P[User Prompt] --> C{Classifier<br/>regex first}
C -->|Greeting / time / joke| S1[SKIP_GRAPHIFY<br/>0 tokens]
C -->|Explicit file or line| S2[SKIP_GRAPHIFY<br/>direct read]
C -->|where / what calls /<br/>architecture / depends on| G[USE_GRAPHIFY<br/>~2K tokens]
C -->|Ambiguous| L[LLM_CLASSIFY<br/>Ollama vote ~500t]
L -->|GRAPHIFY| G
L -->|DIRECT| S2
G --> Q[graphify query]
Q --> CTX[Context Block]
CTX --> R[Inject into LLM prompt]
Quick Start
# 1. Install
pip install mcp-graphify-autotrigger[all]
# 2. Set up graphify CLI + the slash command in your AI assistant
graphify install
graphify claude install
# 3. Build the first graph for any folder
cd /path/to/your/repo
graphify update .
# 4. Register the MCP server with Claude Code / Cowork
claude mcp add chharbot_tools -- python -m mcp_server.server
# 5. Restart your assistant
After registering and restarting, the new tools appear in the assistant's tool list:
- chharbot toolkit (original 7):
delegate_shell,graphify_query,graphify_build,graphify_preflight,graphify_classify,graphify_path,tools_status, plus the cleanup toolcleanup_session. - Agent-tool parity (v0.3.0+, new 8):
read_file,write_file,edit_file,glob_files,grep_files,bash,skill_dispatch(name),list_skills— same primitives Cowork-Claude / Claude Code use natively, so any tool call from either side has a 1:1 chharbot equivalent.
This means delegating a task from Cowork to chharbot (or back) doesn't lose capability: every Read / Write / Edit / Glob / Grep / Bash call your agent makes has a chharbot MCP version with audit logging and size caps.
Slash commands in Cowork & Claude Code
The repo ships two delivery paths so /graphify and /autotrigger work natively:
Cowork — install the chharbot-tools plugin (a .plugin zip that bundles the skills + MCP config). Open Cowork, drag the file in, click Add. Restart. Done.
Claude Code — double-click skills/installers/install-cowork-skills.bat, which also drops the skill folders into %USERPROFILE%\.claude\skills\.
See skills/README.md and plugins/README.md for layout and manual-install instructions.
Features
- Regex-first classifier with 14/14 self-test, LLM fallback for ambiguous cases
- Universal - works on any drive, any folder (not project-specific)
- Per-target graph cache at
~/.chharbot/graphs/<sha256(realpath)>/so repeat queries are cheap - Token-cost-aware - returns expected cost so the brain can pick the cheaper route
- Graceful degradation - if graphify isn't installed, the wrapper says so without crashing
- stdin / stdout / stderr capture with size caps (256KB / 64KB out, 1MB stdin)
- Audit log at
~/.chharbot/delegate-audit.log(JSONL) for every shell delegation - MCP-ready - exposes 7 FastMCP tools out of the box
- Security-hardened - input size caps, audit logging, ReDoS-safe regex (see SECURITY.md)
Usage
As a Python library
from autotrigger.preflight import preflight, discover_targets
pf = preflight(
prompt="how does the auth flow work in this repo",
targets=discover_targets(),
auto_build=True,
)
if pf.context_block:
user_message = pf.context_block + "\n\n---\n\n" + user_message
Drop-in patch
See examples/agent_run_patch.py - 8 lines you paste at the top of your run() method, before the LLM call.
MCP tools exposed
| Tool | Description |
|---|---|
delegate_shell |
Run any shell command on chharbot's unrestricted Python. No allowlist. Audit-logged. |
graphify_query |
English query against any drive/folder's knowledge graph. |
graphify_build |
Build/rebuild a graph for any folder. |
graphify_path |
Shortest path between two nodes. |
graphify_preflight |
Always-on auto-trigger; returns injectable Markdown context block. |
graphify_classify |
Classifier-only without running graphify. |
tools_status |
Health check (graphify installed, audit log size, cached graphs). |
Security
This package gives external agents unrestricted shell access through delegate_shell. That is the explicit design goal (closing autonomy gaps in tier-restricted environments), but it requires you to think about who can call your MCP server.
See SECURITY.md for:
- Threat model
- Hardening recommendations (allowlist wrapper, env-var gating, audit log rotation)
- Tested attack vectors (command injection, path traversal, ReDoS, OOM)
Related
- graphify - the underlying knowledge-graph CLI by @safishamsi
- FastMCP - the MCP server framework
- Model Context Protocol - the spec
Contributing
PRs welcome! Run the test suite with pytest before opening a PR. CI exercises Python 3.10-3.13 on Ubuntu and Windows.
License
MIT - see LICENSE.
Support
If this saves you tokens or unblocks your agent, consider buying me a coffee:
<p align="center"> <a href="https://buymeacoffee.com/chharith"><img src="https://img.shields.io/badge/%E2%98%95-Buy%20Me%20A%20Coffee-FFDD00?style=for-the-badge&logoColor=white" alt="Buy Me A Coffee"/></a> </p>
Issues and PRs welcome at GitHub.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。