CaffeineCurfew

CaffeineCurfew

Tracks caffeine decay and predicts safe bedtimes using a half-life model. No external integrations needed, intake is passed as parameters.

Category
访问服务器

README

Caffeine Curfew MCP Server

A local Model Context Protocol server that tracks caffeine decay and predicts safe bedtimes. All caffeine intake is passed directly as parameters. No external integrations are required.

How It Works

Caffeine decays according to the standard half-life formula:

remaining = initial * (0.5 ^ (hours_elapsed / half_life))

The server calculates the sum of that formula across every entry in your intake log to determine your total current caffeine level and find the earliest time it drops below your personal sleep interference threshold.

The half-life is adjustable from 3 to 10 hours (default 5). The sleep interference threshold is adjustable from 10 to 50 mg (default 25 mg).

Quickstart for Claude Code Users

No installation required. Add this block to your Claude Code MCP settings file and restart Claude Code. uvx will fetch and run the server automatically on first use.

On macOS the settings file is located at:

~/Library/Application Support/Claude/claude_desktop_config.json
{
  "mcpServers": {
    "caffeineCurfew": {
      "command": "uvx",
      "args": ["caffeine-curfew-mcp"]
    }
  }
}

That is the only step. The four Caffeine Curfew tools will appear in Claude Code after restart.

Tools

get_caffeine_level

Returns the current total caffeine level in the body.

Parameters:

entries           list of {amount_mg, consumed_at} intake records
half_life_hours   float, caffeine half-life in hours (default 5)

get_safe_bedtime

Returns the earliest time at which caffeine will drop below the threshold.

Parameters:

entries           list of {amount_mg, consumed_at} intake records
half_life_hours   float (default 5)
threshold_mg      float, sleep interference threshold in mg (default 25)

simulate_drink

Shows how adding a new drink right now would shift the safe bedtime.

Parameters:

entries           list of {amount_mg, consumed_at} intake records
half_life_hours   float (default 5)
threshold_mg      float (default 25)
new_drink_mg      float, caffeine content of the hypothetical drink in mg

get_status_summary

Returns a full summary including current level, safe bedtime, and whether a target bedtime is reachable.

Parameters:

entries           list of {amount_mg, consumed_at} intake records
half_life_hours   float (default 5)
threshold_mg      float (default 25)
target_bedtime    string, optional ISO 8601 datetime the user wants to sleep by

Sample Entries for Testing

The timestamps below should be replaced with real ISO 8601 datetimes that are a few hours before the current time when you run the tests.

[
  {
    "amount_mg": 150,
    "consumed_at": "2025-01-15T08:00:00"
  },
  {
    "amount_mg": 80,
    "consumed_at": "2025-01-15T12:30:00"
  },
  {
    "amount_mg": 100,
    "consumed_at": "2025-01-15T15:00:00"
  }
]

The first entry represents a morning coffee (approximately 150 mg). The second represents a lunchtime espresso (approximately 80 mg). The third represents an afternoon cold brew (approximately 100 mg).

A typical get_status_summary call with the sample entries and a 10 pm target bedtime:

{
  "entries": [
    {"amount_mg": 150, "consumed_at": "2025-01-15T08:00:00"},
    {"amount_mg": 80,  "consumed_at": "2025-01-15T12:30:00"},
    {"amount_mg": 100, "consumed_at": "2025-01-15T15:00:00"}
  ],
  "half_life_hours": 5,
  "threshold_mg": 25,
  "target_bedtime": "2025-01-15T22:00:00"
}

Remote Deployment (Claude Mobile App)

To use Caffeine Curfew from the Claude iOS or Android app, you need the server running on a machine that is reachable over the internet with a valid HTTPS URL. A spare Linux machine on your home network works well for this.

The recommended setup uses Cloudflare Tunnel, which gives you a free persistent HTTPS URL without opening any ports on your router.

Step 1: Install the server on Linux

pip3 install caffeine-curfew-mcp

Or clone the repo and install in editable mode for easier updates:

git clone https://github.com/YOUR_USERNAME/caffeine-curfew-mcp
cd caffeine-curfew-mcp
pip3 install -e .

Step 2: Install Cloudflare Tunnel

curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb -o cloudflared.deb
sudo dpkg -i cloudflared.deb

Then log in to your Cloudflare account (free account at cloudflare.com is enough):

cloudflared tunnel login

Create a named tunnel:

cloudflared tunnel create caffeine-curfew

Note the tunnel ID that is printed. Create a config file at ~/.cloudflared/config.yml:

tunnel: YOUR_TUNNEL_ID
credentials-file: /home/YOUR_USER/.cloudflared/YOUR_TUNNEL_ID.json

ingress:
  - hostname: caffeine.yourdomain.com
    service: http://localhost:8000
  - service: http_status:404

Route your domain to the tunnel (requires a domain managed by Cloudflare):

cloudflared tunnel route dns caffeine-curfew caffeine.yourdomain.com

If you do not have a domain, you can use a temporary public URL for testing:

cloudflared tunnel --url http://localhost:8000

This prints a random URL like https://random-words.trycloudflare.com. It works immediately but changes every time the process restarts.

Step 3: Start the server

In one terminal, start the MCP server in SSE mode:

caffeine-curfew-mcp --transport sse

In another terminal, start the Cloudflare Tunnel:

cloudflared tunnel run caffeine-curfew

To run both automatically on boot, create systemd services for each. A minimal service file for the MCP server at /etc/systemd/system/caffeine-curfew.service:

[Unit]
Description=Caffeine Curfew MCP Server
After=network.target

[Service]
ExecStart=/usr/local/bin/caffeine-curfew-mcp --transport sse
Restart=always
User=YOUR_USER

[Install]
WantedBy=multi-user.target

Enable and start it:

sudo systemctl enable caffeine-curfew
sudo systemctl start caffeine-curfew

Step 4: Connect in the Claude App

Open the Claude app, go to Settings, then Integrations (or Tools, depending on app version), and add a new MCP server with the URL:

https://caffeine.yourdomain.com/sse

The four Caffeine Curfew tools will be available in every conversation.

Security note

Anyone with the URL can call your server. If you want to restrict access, add a shared secret by setting an environment variable before starting the server and putting the Cloudflare Tunnel behind Cloudflare Access (free for personal use), which adds an authentication layer without changing the server code.

Local Development Setup

Clone the repository and install in editable mode:

git clone https://github.com/YOUR_USERNAME/caffeine-curfew-mcp
cd caffeine-curfew-mcp
pip3 install -e ".[dev]"

Run the server directly:

python3 -m caffeine_curfew.server

To point your local Claude Code at a development checkout instead of the published package, use the python3 form in your MCP settings:

{
  "mcpServers": {
    "caffeineCurfew": {
      "command": "python3",
      "args": ["/absolute/path/to/caffeine-curfew-mcp/caffeine_curfew/server.py"]
    }
  }
}

Publishing to PyPI

Build and upload with standard tooling:

pip3 install build twine
python3 -m build
python3 -m twine upload dist/*

After publishing, any user with uvx installed can connect to the server using the one-line config shown in the Quickstart section above.

Notes

Caffeine half-life varies significantly between individuals. Common ranges:

Average adult          4 to 6 hours
Oral contraceptives    can double the half-life
Smokers                roughly half the half-life of non-smokers
Pregnancy              can extend half-life to 15 hours or more

The default half-life of 5 hours is a reasonable starting point for most adults. All times returned are provided in both UTC and the local system timezone.

推荐服务器

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

官方
精选