Shadow-Core Sentinel

Shadow-Core Sentinel

An MCP filesystem telemetry server that watches directories and records every file change with SHA-256 hashes, enabling verification of edits through tools like recent_changes and query_events, with multi-project support and idle suspension.

Category
访问服务器

README

Shadow-Core Sentinel — MCP Filesystem Telemetry

Sentinel records every file change under a watched directory, with a SHA-256 of each file, so a change can be confirmed against what actually happened on disk rather than assumed.

It records what changed, never whether the change is correct. It is a filesystem oracle, not a semantic one — it will not catch a deleted function, a wrong value, or a broken test. Linters and tests remain the tools for that.

Key features

  • Non-blocking — hashing is offloaded to a thread pool so OS events are not dropped while a large file is read.
  • Cryptographically verified — every event carries a SHA-256, so "did this file revert to its original state?" is answerable.
  • Context-optimised — recent_changes answers "did my edit land?" in tens of rows. query_events takes a whole date, which on a busy project is tens of thousands (measured: 19,936 in one day).
  • Multi-project — several projects watched at once, each with its own database and audit directory. Adding a watch never removes another, so two sessions cannot silently stop each other's monitoring.
  • Idle suspension with gap recovery — an inactive project suspends rather than being watched forever. Suspension is not removal: history stays intact and the next prompt resumes it. Changes made while suspended are reconstructed from a SHA-256 comparison and written into the trail marked as detected-on-resume, so the unwatched period is visible rather than missing.
  • Atomic-write aware — editors that write via a temp file and rename record as a single MODIFIED of the real path, with no phantom DELETE of the file they just replaced.
  • Noise guard — high-churn directories (node_modules, .git, venv, build output) are ignored by default.

Requirements

Python 3.11. The pinned versions in requirements.txt are verified against it.

Install

pip install -r requirements.txt

For development — this is what you need to run the test suite, which requirements.txt alone does not provide:

pip install -e ".[dev]"

Run

python main.py

Sentinel boots watching nothing and stays idle until a session calls watch_project. That is deliberate: it starts with the machine, and coming up recording a directory nobody asked about means CPU spent hashing and an audit trail nobody reads.

To start it automatically at logon, see INSTALL.md.

Flag Default Meaning
--mcp-port 7702 MCP SSE endpoint
--mcp-host 127.0.0.1 Bind address — loopback is deliberate
--dashboard-port 7654 HTML dashboard
--no-dashboard off Run without the dashboard
--watch PATH none Watch a directory at startup
--log-level INFO DEBUG/INFO/WARNING/ERROR

--port is a deprecated alias for --dashboard-port.

Environment variables

Variable Default Meaning
MCP_PORT / MCP_HOST 7702 / 127.0.0.1 MCP SSE endpoint
DASHBOARD_PORT 7654 Dashboard port
DASHBOARD_ENABLED true Set false to disable the dashboard
AUDIT_DIR ./audit_logs Where per-project audit data is written
WATCH_DIR ./watched Startup watch directory
SENTINEL_FLUSH_ON_START true Deletes all recorded audit data at startup. See below
WATCH_IDLE_TTL_SECONDS 3600 Idle time before a watch suspends; 0 disables
WATCH_SWEEP_SECONDS 60 How often idle watches are checked
LOG_LEVEL INFO Logging level

Flush on start

SENTINEL_FLUSH_ON_START defaults to true: every start deletes all recorded audit data, so a run begins with no history. This completes what Sentinel already did — it boots watching nothing, and its in-RAM ring starts empty — and it bounds disk, which nothing else did. Before this the trail had reached 252 MB with no retention policy at all, 38% of it a dead project created by a typo in a watched path.

What you lose, stated plainly: cross-restart forensics. list_audit_dates, get_daily_report and query_events can only answer about the current run, and "what changed while I wasn't looking" — the one question git cannot answer — is unanswerable across a restart, because the evidence is deleted first. Gap reconstruction still works, but only across a suspend/resume inside one run.

Set SENTINEL_FLUSH_ON_START=false to keep history.

The flush only removes things it recognises as its own: a directory holding a sentinel.db or Sentinel's markdown artifacts, an empty project directory, or a loose sentinel.*/audit-*.md/snapshot-*.md/gap-*.md at the audit root. Anything else is left alone and logged, and an AUDIT_DIR closer than three path components to a filesystem root is refused outright — a mis-set AUDIT_DIR must not be able to delete source.

MCP client configuration

Sentinel speaks MCP over SSE, not stdio. It is not spawned by the client — it must already be running, and the client connects to it:

{
  "mcpServers": {
    "shadow-core-sentinel": {
      "type": "sse",
      "url": "http://127.0.0.1:7702/sse"
    }
  }
}

A "command"/"args" entry — the stdio spawn form — does not work here. The client launches the process, waits for stdio that never comes, and hangs, because main.py runs mcp.run(transport="sse", ...) and serves HTTP instead.

Verify it is up:

curl http://127.0.0.1:7702/health

Using it

At the start of a session:

watch_project(path="<absolute path of the working directory>")

Additive and idempotent — it never stops another session's watch, and re-calling it for an already-watched directory only renews its lease.

Before reporting that a change is complete:

recent_changes(minutes=15)

Compare files you intended to change against what the filesystem recorded. This catches an edit that silently did not land, and files changed that were not meant to be touched. It is worth most after a build, install, or generated-file step, where an exit code of 0 is not evidence that a file was written.

Endpoints

Endpoint Purpose
GET /health Liveness, watch list, and failed_writes — non-zero means the trail is incomplete
POST /api/touch Keepalive; renews and resumes the watch for a path (localhost only)
POST /admin/shutdown Graceful stop without elevated taskkill (localhost only)
http://127.0.0.1:7654 Dashboard, one tab per watched project

Selecting a dashboard tab is a client-side view change: it does not move the server's default project or affect another session.

Tests

python -m pytest -m "not slow"

Layout

File Responsibility
main.py Startup: build state, wire components, run
mcp_server.py The nine MCP tools and two resources
dashboard_wiring.py Which project a dashboard request is answered from
dashboard.py Dashboard HTTP layer and template
http_routes.py /health, /api/touch, /admin/shutdown
observer.py watchdog handler: ignore, debounce, atomic-write handling
watch_registry.py The watched projects and longest-prefix event routing
lease.py Idle suspension, resume, and gap reconstruction
storage.py SQLite event store, one per project
report_builder.py Markdown audit logs and snapshots
config.py Settings and the ignore filter

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选