huckleberry-mcp-worker

huckleberry-mcp-worker

An always-on MCP server that lets AI assistants read and write sleep, feeding, diaper, and growth records for the Huckleberry baby-tracking app through a Cloudflare Worker using the Firebase REST API.

Category
访问服务器

README

huckleberry-mcp-worker

A Model Context Protocol server for the Huckleberry baby-tracking app, running as a Cloudflare Worker.

This is a TypeScript port of bckenstler/py-huckleberry-mcp. The original is a Python stdio server that talks to Firestore through google-cloud-firestore, which speaks gRPC and therefore cannot run on Workers. This port reaches the same backend over the Firebase REST API using fetch, and serves MCP over Streamable HTTP.

The practical difference: it is always on. No laptop has to be awake for a client to log a nap.

Tools

All 23 tools from the Python server are implemented, plus delete_record.

Area Tools
Children list_children, get_child_name
Sleep log_sleep, start_sleep, pause_sleep, resume_sleep, complete_sleep, cancel_sleep, get_sleep_history
Feeding log_breastfeeding, log_bottle_feeding, start_breastfeeding, pause_feeding, resume_feeding, switch_feeding_side, complete_feeding, cancel_feeding, get_feeding_history
Diaper log_diaper, get_diaper_history
Growth log_growth, get_latest_growth, get_growth_history
Records delete_record

Every history tool reports each record's interval_id, which is what delete_record takes.

Fixes relative to the Python server

Four defects were found while porting and are corrected here.

Breastfeeding durations were written in the wrong unit. The backend stores leftDuration / rightDuration in seconds — that is what the app's own timer writes — but log_breastfeeding passed the caller's minutes straight through. Logging a 5 minute feed recorded 5 seconds. Callers previously had to pass 300 to mean 5 minutes; here left_duration_minutes: 5 means five minutes.

Single-day history queries returned nothing. Both ends of a date range were resolved to midnight, so start_date == end_date produced an empty window and the server reported no records for a day that had plenty. Ranges are now half-open [start_of_start_date, start_of_end_date + 1 day), making both ends inclusive.

end_time in sleep history was always null. The code read an end field that the backend never writes. It is now derived from start + duration.

birth_date in list_children was always null. The backend field is birthdate; the server read birthDate.

get_feeding_history also now returns each record's mode, plus the details that go with it: amount and type for bottles, food names and reactions for solids. Without them a solids record is an empty row, indistinguishable from a zero-length nursing session — which is exactly how a perfectly good record gets mistaken for a missing one.

Setup

Requires Node 18+ and a Cloudflare account.

npm install
npx wrangler login

Set the secrets — they are stored encrypted by Cloudflare and never live in the repository:

npx wrangler secret put HUCKLEBERRY_EMAIL
npx wrangler secret put HUCKLEBERRY_PASSWORD
npx wrangler secret put MCP_AUTH_TOKEN     # a long random string you generate
npx wrangler secret put HUCKLEBERRY_TIMEZONE   # e.g. America/Sao_Paulo

HUCKLEBERRY_TIMEZONE defaults to America/New_York. It decides how naive datetimes like "2026-08-17T15:47:00" are interpreted, so setting it correctly matters.

Deploy:

npm run deploy

Authentication

The Worker URL is public, and the server holds credentials to a child's health record, so every request must carry the bearer token:

Authorization: Bearer <MCP_AUTH_TOKEN>

Requests without a valid token get a 401 before any Huckleberry call is made. Generate a token with something like openssl rand -base64 32.

Clients that cannot send headers

Some MCP clients accept only a URL — claude.ai custom connectors, for one, take a URL and optional OAuth credentials with no field for Authorization. For those, the server also accepts the token as the last path segment:

POST https://<your-worker>.workers.dev/mcp/<MCP_URL_TOKEN>

MCP_URL_TOKEN is a separate secret from MCP_AUTH_TOKEN, and deliberately so: request paths end up in access logs, browser history, and referrers in a way headers do not. Keeping them apart means a leak through a URL does not compromise the header credential, and either can be rotated on its own. If MCP_URL_TOKEN is unset the route falls back to MCP_AUTH_TOKEN, which is convenient but gives up that separation.

npx wrangler secret put MCP_URL_TOKEN

Prefer the header route wherever the client supports it.

Client configuration

For Claude Code:

claude mcp add --transport http huckleberry https://<your-worker>.workers.dev/mcp \
  --header "Authorization: Bearer <MCP_AUTH_TOKEN>"

Local development

cp .dev.vars.example .dev.vars   # then fill it in; .dev.vars is gitignored
npm run dev
curl -X POST http://localhost:8787/mcp \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json, text/event-stream' \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'

Design notes

Stateless. Each request builds a fresh McpServer via createMcpHandler from Cloudflare's agents SDK. No Durable Objects and no session storage are involved, because every tool is a self-contained read or write.

Token caching. Firebase ID tokens last an hour and are cached in module scope, so requests landing on a warm isolate skip re-authentication. A cold isolate costs one extra round trip. A token rejected mid-flight triggers one re-authentication and retry.

Numeric types. Firestore distinguishes integers from doubles, and the app writes some fields as one and some as the other. Values that must be stored as doubles are wrapped in dbl() so records written here match records written by the app.

Multi-entry documents. History lives in two shapes: ordinary documents with a top-level start, and batch documents holding many entries under data. Nested starts cannot be filtered server-side, so batch documents are fetched whole and filtered in the Worker. Records report which shape they came from via is_multi_entry.

Deleting records

The Python server had no delete, and the received wisdom was that the backend did not allow one. It does: a DELETE on the document path returns 200. What was actually missing was the record's id, which the history tools never reported.

So history tools now return interval_id, and delete_record removes the record it names. Batched entries — several records packed into one document under data — are addressed as <documentId>#<entryKey> and removed as a field of their parent.

Deleting also repoints prefs.last* at the newest surviving record. The app reads those pointers directly, so a delete without the repoint leaves it showing a record that no longer exists.

Known limitations

  • Deletes are permanent. There is no undo. Confirm with a history query before calling delete_record.
  • Solids are read-only. get_feeding_history reports solids entries with their food names and reactions, but there is no tool to create one.
  • start_sleep does not guard against an already-running timer. The Python server documented that it would fail in that case but never checked; the behaviour is preserved here rather than silently changed.
  • Notes do not round-trip into sleep records. The details field is a fixed structure of checkboxes, not free text.

License

MIT

推荐服务器

Baidu Map

Baidu Map

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

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

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

官方
精选
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

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

官方
精选
本地
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

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

官方
精选
本地
TypeScript
VeyraX

VeyraX

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

官方
精选
本地
Kagi MCP Server

Kagi MCP Server

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

官方
精选
Python
graphlit-mcp-server

graphlit-mcp-server

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

官方
精选
TypeScript
Exa MCP Server

Exa MCP Server

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

官方
精选
mcp-server-qdrant

mcp-server-qdrant

这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。

官方
精选
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选