durable-mcp
MCP server for Durable energy trading analytics that connects Claude Desktop to Snowflake data, enabling natural-language queries about spreads, constraints, generators, and prices.
README
durable-mcp
MCP server for Durable energy trading analytics. Connects Claude Desktop to your Snowflake data so traders can ask plain-English questions about spread portfolios, nodal prices, transmission constraints, generator performance, and PJM markets — without writing SQL or opening the right dashboard.
How it works
Trader asks a question in Claude Desktop
↓
Claude picks the right tool based on the question
↓
MCP server (this repo, runs locally) queries your Snowflake
↓
Results come back → Claude reads them → answers the question
Note on data privacy: your trading data (PnL, portfolio names, bid paths) passes through Anthropic's servers as part of the Claude conversation. See Data & Security before using in production.
Setup (30 seconds)
1. Add to Claude Desktop
Open your Claude Desktop config file:
- Windows:
%APPDATA%\Claude\claude_desktop_config.json - Mac:
~/Library/Application Support/Claude/claude_desktop_config.json
Add this block:
{
"mcpServers": {
"durable": {
"command": "npx",
"args": ["-y", "github:cshah26/Chatbot-MCP"]
}
}
}
2. Restart Claude Desktop
That's it. The server reads credentials automatically from the Durable desktop app's keyring — no extra configuration needed if you already have the app installed.
Credential fallback
The server tries credentials in this order:
- Durable app keyring — Windows Credential Manager under
durable-desktop / snowflake-config. Works automatically if the desktop app is installed. - Environment variables — copy
.env.exampleto.envand fill in:
SNOWFLAKE_ACCOUNT=your_account.region
SNOWFLAKE_USERNAME=your_username
SNOWFLAKE_PASSWORD=your_password
SNOWFLAKE_WAREHOUSE=COMPUTE_WH
SNOWFLAKE_ROLE=READ_ONLY_ROLE
Available tools
| Tool | What it does |
|---|---|
get_spread_portfolios |
PnL summary by portfolio — total PnL, win rate, best/worst days |
get_spread_analysis |
Breakdown by path (source→sink), book, or book+path — win rate, avg/day |
get_nodal_spread |
DA and RT LMP spread between two nodes — hourly stats, peak-hour breakdown, day-of-week heatmap |
list_price_nodes |
Search available price nodes by name or ISO |
list_constraints |
List all ERCOT transmission constraint names |
get_constraint_loading |
Hourly max/min loading % for a specific ERCOT constraint |
get_flow_analysis |
All constraint loading for a single date — shows which lines are most at risk |
get_gen_comparison |
MUSE forecast vs Edison actual by plant and fuel type |
get_gen_detail |
Hourly Edison vs MUSE generation for a single plant |
get_pjm_wh |
PJM Western Hub DA/RT LMP prices and load with historical daily averages |
get_segment_tracker |
Bid segment counts by day and portfolio — submitted vs unsubmitted |
Example questions
- "What was our total PnL last week?"
- "Show me the spread between HB_NORTH and HB_SOUTH for July"
- "Which constraints were most loaded yesterday?"
- "How accurate was MUSE for gas plants this month?"
- "What were PJM Western Hub prices on July 10th?"
Performance
What was slow (and what's fixed)
Snowflake warehouse cold start — 10–30s on the first question of the day
Snowflake auto-suspends idle warehouses. The server now sends a SELECT 1 immediately on startup — before any trader types anything — so the warehouse is warm and the connection is live by the time the first query arrives.
No caching — every question hit Snowflake live A TTL cache now sits in front of every query:
| Data type | Cache TTL |
|---|---|
| Historical PnL, spreads, constraint loading | 3 minutes |
| Node list, constraint names (static reference data) | 1 hour |
Repeat questions are served from memory instantly.
Expected response times
| Scenario | Before | After |
|---|---|---|
| First question of the day | 15–35s | 1–3s |
| Same question asked again | 3–8s | <100ms |
| New question, warm warehouse | 2–5s | 1–3s |
Snowflake warehouse tip
Set auto-suspend to 10 minutes in your Snowflake account settings (default is 5) to give more buffer during trading hours. Optionally schedule a SELECT 1 at 6am on trading days to pre-warm the warehouse before traders arrive.
Data & Security
What leaves your network
When a tool runs, the SQL results — PnL numbers, portfolio names, bid paths, generator data — are sent to Anthropic's servers as part of the Claude conversation. This is real trading data: positions, performance, and strategy details.
It does not go anywhere else. The MCP server has no telemetry, no external logging, and no analytics calls beyond Snowflake and Claude.
Anthropic's data policy
| Claude API | Claude.ai (consumer) | |
|---|---|---|
| Trains on your data | No | Depends on settings |
| Data retention | Short-term for safety review | Longer |
| Enterprise agreement / BAA | Available | Not available |
Options if your firm has data sensitivity requirements
Option 1 — Claude Enterprise Anthropic's enterprise offering includes a data processing agreement, zero retention, and stricter data handling. Designed for financial firms. The MCP server works unchanged.
Option 2 — Local model Run a local LLM (e.g. Llama 3 via Ollama) instead of Claude. Nothing leaves your network. Tradeoff: local models are less capable. The MCP protocol is identical — only the model endpoint changes.
Option 3 — Data minimization Modify tools to send only aggregated summaries to Claude (totals, averages) rather than raw row data. Claude can still answer most questions but sees less sensitive detail.
Consult your compliance team before using this with live trading data.
Architecture
src/
index.ts — entry point: stdout guard, module loading, server setup, pre-warm
db.ts — Snowflake connection, TTL cache, query execution, auto-retry
keyring.ts — reads credentials from Windows Credential Manager
tools/
spread.ts — get_spread_portfolios, get_spread_analysis
nodal.ts — get_nodal_spread, list_price_nodes
constraints.ts — list_constraints, get_constraint_loading, get_flow_analysis
generators.ts — get_gen_comparison, get_gen_detail
pjm.ts — get_pjm_wh
segments.ts — get_segment_tracker
Key design decisions
stdout guard
Snowflake's SDK (winston) writes logs directly to process.stdout, which would corrupt the MCP JSON-RPC stream. index.ts patches process.stdout.write before any modules load, redirecting anything that isn't a JSON-RPC 2.0 message to stderr. The filter checks for "jsonrpc":"2.0" specifically to avoid false positives.
Read-only enforcement
db.ts rejects any SQL that does not start with SELECT or WITH. No writes possible.
Connection auto-retry If the Snowflake connection drops between queries (idle timeout, network reset), the next query transparently resets the connection state and retries once with a fresh connection before surfacing an error to the caller.
Development
npm install
npm run build # compile TypeScript → dist/
npm start # run the compiled server
The dist/ directory is committed so npx github:... works without a build step on the consumer side.
Publishing updates
Push to GitHub — team members get the latest automatically on the next Claude Desktop restart:
git add -A && git commit -m "your message" && git push
Changelog
391cbaf — fix+perf: resolve 9 code review issues
Bugs fixed
logLevelrestored from'OFF'to'ERROR'— Snowflake SDK error events (TLS drops, connection resets) are visible on stderr again; the stdout intercept already handled MCP stream safety- Auto-retry on stale connection — if the connection drops between queries, it resets and retries once transparently instead of failing
- stdout filter tightened from
"jsonrpc"to"jsonrpc":"2.0"— eliminates false positives from any library that logs JSON containing the word "jsonrpc" - Comment corrected: snowflake-sdk uses winston internally, not log4js
Performance
- Snowflake connection and warehouse pre-warmed on startup — first question no longer pays 10–30s resume cost
- TTL query cache added — repeat questions served from memory; static reference data (node list, constraint names) cached for 1 hour
- Dynamic imports parallelised with
Promise.all— all 8 tool modules load concurrently at startup
Cleanup
console.errorandconsole.warnoverrides removed — dead code (those methods write to stderr internally and never touched stdout)
3f4f7d2 — fix: intercept process.stdout.write to block snowflake log4js from corrupting MCP stream
1017fff — fix: redirect all stdout to stderr to keep MCP protocol stream clean
f706a7b — fix: include dist/ in repo so npx github: works without build step
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。