GridWatch MCP
MCP server exposing distributed industrial asset data (battery storage, EV chargers, solar arrays) with tools for asset status, geospatial search, alerts, anomaly explanation, and load simulation.
README
GridWatch MCP
An MCP interface layer for a distributed industrial asset platform.
Industrial operators — battery energy storage sites, EV charger networks, solar arrays, IoT sensor fleets — manage assets spread across geography, with health, telemetry, and alert data usually locked behind a dashboard. GridWatch exposes that operational data to AI assistants via the Model Context Protocol (MCP), so instead of clicking through charts, an engineer can ask Claude "which sites near Aachen have critical alerts?" and get a live, tool-backed answer grounded in real data.
This is a demo/portfolio build: the platform and its data are synthetic, but the MCP server, auth, geospatial queries, and data model are real and meant to mirror how an actual industrial platform would expose itself as an MCP server.
▶ Live demo: https://map-beta-plum.vercel.app
▶ MCP endpoint: https://map-beta-plum.vercel.app/api/mcp (Streamable HTTP transport, bearer-token auth)
Why this exists
Model Context Protocol is a young interface layer between AI assistants and software platforms — the patterns for how an industrial platform should expose itself (which operations, what auth model, what the tool surface looks like) are still forming. This project is my attempt to work through that problem concretely: design a tool surface for a real operational domain (distributed energy/industrial assets), and build it to a standard where security, latency, and scale are treated as first-class constraints, not afterthoughts.
Architecture
flowchart LR
subgraph Client["AI Assistant"]
C[Claude / any MCP client]
end
subgraph Vercel["Vercel — Fluid Compute"]
MCP["/api/mcp\nStreamable HTTP handler"]
Auth["Bearer-token auth\n(withMcpAuth)"]
RateLimit["Rate limiter\n(sliding window)"]
Dash["/ dashboard\n(Next.js RSC)"]
MCP --> Tools
subgraph Tools["MCP Tools"]
T1[get_asset_status]
T2[find_assets_near]
T3[list_alerts]
T4[explain_anomaly]
T5[simulate_load]
end
end
subgraph DB["Neon Postgres + PostGIS"]
Assets[(assets)]
Telemetry[(telemetry_readings)]
Alerts[(alerts)]
end
C -- "JSON-RPC over HTTPS" --> RateLimit --> Auth --> MCP
Dash --> Assets
Dash --> Telemetry
Dash --> Alerts
Tools --> Assets
Tools --> Telemetry
Tools --> Alerts
Stack:
- Next.js (App Router) on Vercel Fluid Compute — one deployable for both the MCP server and the human-facing dashboard
mcp-handler— wraps the official MCP SDK as a Web-standardRequest → Responsehandler; handles the Streamable HTTP transport and bearer-token auth (withMcpAuth)- Neon Postgres + PostGIS — relational data plus real geospatial queries
(
ST_DWithin,ST_Distance) for thefind_assets_neartool - Drizzle ORM — typed schema and queries
- Leaflet — the human-facing map view (not part of the MCP surface itself)
MCP tool surface
| Tool | Purpose |
|---|---|
get_asset_status |
Current status + latest telemetry for one asset, by external ID |
find_assets_near |
Geospatial radius search (PostGIS ST_DWithin), optional asset-type filter |
list_alerts |
Fleet-wide alert feed, filterable by severity/category/resolution state |
explain_anomaly |
Root-cause explanation for one alert, grounded in surrounding telemetry |
simulate_load |
Deterministic what-if projection under a named stress scenario |
Each tool call is authenticated, rate-limited, and logged — see Security, latency, scale below.
Data model
erDiagram
assets ||--o{ telemetry_readings : has
assets ||--o{ alerts : raises
assets {
int id PK
text external_id UK
text name
text asset_type
double latitude
double longitude
text status
}
telemetry_readings {
bigint id PK
int asset_id FK
timestamp recorded_at
double soc_percent
double temperature_c
double voltage
double health_score
}
alerts {
int id PK
int asset_id FK
text event_id UK
int severity
text category
text message
boolean resolved
}
35 synthetic assets are seeded across 9 European cities (battery storage, EV
chargers, solar arrays, IoT sensors), each with ~48 hours of hourly telemetry
and a realistic spread of alerts. See scripts/seed.ts.
Security, latency, scale
This is the part of the ACCURE thesis prompt ("evaluated for security, latency, and scale") I tried to take seriously rather than hand-wave:
Security
- Every tool call requires a bearer token, verified via
withMcpAuthbefore the request reaches any tool (src/app/api/mcp/route.ts) - Input validation on every tool via Zod schemas — the MCP layer rejects malformed calls before they touch the database
- No raw SQL string interpolation — all queries go through Drizzle or Neon's parameterized tagged templates, including the PostGIS raw-SQL queries
Latency
- Neon's HTTP driver (
@neondatabase/serverless) avoids TCP connection setup cost per request, which matters on serverless/Fluid Compute where instances scale to zero - Vercel Fluid Compute reuses warm instances across requests instead of cold-starting per call, which is the main latency lever at this scale
Scale
- The rate limiter (
src/lib/rate-limit.ts) is in-memory and documented as such — it's effective per-instance under Fluid Compute's instance reuse, but not distributed. The honest note in that file explains exactly what would change (swap for Upstash Redis +@upstash/ratelimit) to make it correct across many concurrent instances. list_alertsandfind_assets_nearcap result sets (50/100 rows) rather than returning unbounded fleets — a real platform integration needs pagination once fleets grow past a few thousand assets, which this intentionally punts on for demo scope.
Running locally
npm install
vercel env pull .env.local # or copy .env.local from your own Neon/Vercel setup
npx dotenv -e .env.local -- npx tsx scripts/enable-postgis.ts
npx dotenv -e .env.local -- npx drizzle-kit generate
npx dotenv -e .env.local -- npx drizzle-kit migrate
npx dotenv -e .env.local -- npx tsx scripts/seed.ts
npx dotenv -e .env.local -- npm run dev
Set MCP_API_KEY in .env.local — it's the bearer token required to call
/api/mcp. Without it set, local dev falls back to an open (logged-loudly)
mode so npm run dev works out of the box; production deployments should
always set it.
Connecting an MCP client
{
"mcpServers": {
"gridwatch": {
"url": "https://<your-deployment>.vercel.app/api/mcp",
"headers": { "Authorization": "Bearer <MCP_API_KEY>" }
}
}
}
What I'd build next
- Distributed rate limiting (Upstash Redis) for true multi-instance correctness
- OAuth/CIMD-based auth instead of a static bearer token, for multi-tenant access
- Pagination on
list_alerts/find_assets_near - A real anomaly-detection model behind
explain_anomaly(currently rule-based heuristics per alert category) — natural extension of prior work on smart-building-fault-detection
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。