Skip to main content
Glama
cuongnguyenta

SleepBlocker MCP

šŸš«šŸ’¤ Sleep Blocker MCP Server

Control your Mac's sleep settings through AI assistants using the Model Context Protocol (MCP)

macOS Python MCP License

Sleep Blocker MCP Server enables AI assistants like Claude Code to prevent your Mac from sleeping using natural language commands. Built on the Model Context Protocol, it provides seamless integration with various AI development tools.

✨ Features

  • šŸŽÆ Natural Language Control - "Keep my Mac awake for 2 hours"

  • šŸ”§ Multiple Sleep Modes - Display, idle, disk, AC power, and all

  • ā° Flexible Duration - Preset durations or custom times

  • šŸ“Š Status Monitoring - Check active prevention and remaining time

  • šŸ›”ļø Safe Operation - Automatic cleanup and error handling

  • šŸ”Œ Universal MCP Compatibility - Works with Claude Code, Cursor, and more

Related MCP server: Talk to Your PC MCP Server

šŸš€ Quick Start

1-Minute Setup

# Clone this repository
git clone https://github.com/yourusername/SleepBlocker-MCP.git
cd SleepBlocker-MCP

# Run the installer
./install.sh

# Follow the setup instructions

Manual Setup

# Make server executable
chmod +x mcp_server.py

# Test the server
echo '{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {}}' | python3 mcp_server.py

Configure Your AI Assistant

For Claude Code, add to your MCP settings:

{
  "mcpServers": {
    "sleep-blocker": {
      "command": "python3",
      "args": ["/path/to/SleepBlocker-MCP/mcp_server.py"]
    }
  }
}

šŸ’¬ Usage Examples

Once configured, you can use natural language with your AI assistant:

  • "Prevent my Mac from sleeping for the next hour"

  • "Keep my screen on during this presentation"

  • "Stop sleep prevention"

  • "What's my current sleep status?"

  • "Show me all available sleep modes"

šŸ› ļø Available Tools

Tool

Description

Example

start_sleep_prevention

Start preventing sleep with mode and duration

"Keep system awake for 2 hours"

stop_sleep_prevention

Stop active sleep prevention

"Allow my Mac to sleep again"

get_sleep_status

Check current status and remaining time

"How much time is left?"

list_sleep_modes

Show all available prevention modes

"What sleep modes are available?"

set_duration_preset

Use preset durations (30min, 1hr, 2hr, 4hr)

"Set to 1 hour preset"

šŸŽÆ Sleep Prevention Modes

  • šŸ–„ļø Display - Keep screen on, allow system sleep

  • šŸ’¤ Idle - Keep system awake, allow display sleep (default)

  • šŸ’¾ Disk - Keep hard drives spinning

  • šŸ”Œ AC Power - Only prevent sleep when plugged in

  • 🚫 All - Prevent all sleep (display + system + disk)

šŸ“‹ Requirements

  • macOS (any version with caffeinate command)

  • Python 3.7+

  • MCP-compatible client (Claude Code, Cursor, etc.)

šŸ“š Documentation

šŸŽŖ Real-World Use Cases

šŸ‘Øā€šŸ’¼ Professional

  • Presentations - Keep screen on during demos

  • Long Downloads - Prevent sleep during file transfers

  • Video Calls - Maintain display during meetings

  • Development - Keep system active during builds

šŸŽµ Creative

  • Music Production - Keep drives spinning for sample libraries

  • Video Editing - Prevent interruptions during renders

  • Live Streaming - Maintain system during broadcasts

šŸŽ® Personal

  • Gaming - Extended gaming sessions

  • Movie Nights - Keep display on for movies

  • File Organization - System stays awake during large operations

šŸ”’ Security & Privacy

  • āœ… 100% Local - No network connections or data sharing

  • āœ… Standard Tools - Uses only macOS built-in caffeinate command

  • āœ… Process Safety - Automatic cleanup and proper termination

  • āœ… No Permissions - No special system permissions required

šŸŽÆ Quick Test

After installation, test with your AI assistant:

  1. "What sleep prevention modes are available?"

  2. "Start sleep prevention for 5 minutes"

  3. "Check my sleep status"

  4. "Stop sleep prevention"

šŸ†˜ Need Help?

  1. Installation Issues: Run ./install.sh and follow the colored output

  2. Connection Problems: Check Troubleshooting Guide

  3. Usage Questions: See Examples for inspiration

  4. Technical Details: Review MCP Documentation

šŸŽ‰ Compatible AI Assistants

  • Claude Code āœ…

  • Cursor āœ…

  • Claude Desktop āœ…

  • Windsurf āœ…

  • Any MCP-compatible client āœ…

šŸ“¦ What's Included

SleepBlocker-MCP/
ā”œā”€ā”€ mcp_server.py          # Main MCP server
ā”œā”€ā”€ install.sh             # Automated installer
ā”œā”€ā”€ package.json           # MCP configuration
ā”œā”€ā”€ README.md              # This file
ā”œā”€ā”€ USER_GUIDE.md          # Complete user guide
ā”œā”€ā”€ EXAMPLES.md            # Usage examples
ā”œā”€ā”€ TROUBLESHOOTING.md     # Problem solving
ā”œā”€ā”€ README_MCP.md          # Technical documentation
ā”œā”€ā”€ DISTRIBUTION.md        # Distribution guide
└── LICENSE                # MIT License

šŸš€ Getting Started in 30 Seconds

# 1. Clone and setup
git clone https://github.com/yourusername/SleepBlocker-MCP.git
cd SleepBlocker-MCP
./install.sh

# 2. Add to your AI assistant's MCP config
# (Path shown by installer)

# 3. Restart your AI assistant

# 4. Try it out!
# Say: "Keep my Mac awake for 30 minutes"

šŸŽŠ Why Sleep Blocker MCP?

  • šŸ—£ļø Natural Language - No complex commands to remember

  • šŸ”§ Flexible Control - Multiple modes for different needs

  • ⚔ Instant Setup - Working in minutes, not hours

  • šŸ›”ļø Rock Solid - Proper error handling and cleanup

  • šŸ“– Great Docs - Clear guides for every skill level

  • šŸ”„ Universal - Works with any MCP-compatible AI assistant

šŸ¤ Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

šŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

šŸ™ Acknowledgments

  • Built with the Model Context Protocol

  • Uses macOS built-in caffeinate command

  • Inspired by the need for AI-controlled system management


Ready to take control of your Mac's sleep settings with AI?

⭐ Start with the installation script →

Made with ā¤ļø for the MCP community. Questions? Check the User Guide or Troubleshooting docs!

Available Tools

5 tools
get_sleep_statusA

Get current sleep prevention status and remaining time

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A4.3/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It accurately indicates a read operation without side effects. Since the tool has zero parameters and no complex behavior, the description is sufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence with no extraneous information. Every word is valuable, and it is appropriately front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no parameters, no output schema, and a straightforward read operation, the description provides all necessary context: what the tool does and what it returns. It is complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

There are no parameters, and by the rule '0 params = baseline 4', the description needs no additional parameter information. It implicitly covers all inputs by having none.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool retrieves 'current sleep prevention status and remaining time', which is a specific verb+resource. It distinguishes from sibling tools that list modes, set presets, or start/stop sleep prevention.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for checking status but does not explicitly provide guidance on when to use this tool versus siblings or any preconditions. It is adequate for a simple getter but lacks explicit context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_sleep_modesA

List all available sleep prevention modes with descriptions

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description discloses that it lists modes with descriptions, which is a simple read-only operation. No annotations are provided, but the behavior is straightforward and no side effects are implied.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence with no unnecessary words. It is concise and front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple list tool with no output schema, the description is nearly complete. It could specify return format, but 'with descriptions' implies sufficient detail. Sibling tools provide context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

There are 0 parameters, so baseline is 4. The description does not need to add parameter information.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'list' and the resource 'available sleep prevention modes', and it distinguishes from siblings like start_sleep_prevention or get_sleep_status, which perform different actions.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage (when you need to know available modes) but does not explicitly state when to use this tool versus alternatives. No exclusions or prerequisites are given.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

set_duration_presetB

Set duration using preset values (30min, 1hr, 2hr, 4hr, indefinite)

ParametersJSON Schema
NameRequiredDescriptionDefault
presetYesDuration preset

TDQS

B3.3/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided; description only says 'Set duration' implying mutation but fails to disclose whether it overwrites existing settings, side effects, or requires a session. Lacks behavioral details.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

One sentence, no fluff, front-loaded with action and values. Could be expanded slightly but remains appropriately concise for the simplicity of the tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple tool with one enum parameter, the description is mostly complete. It lacks explanation of what 'indefinite' means and has no output schema, but covers basic usage adequately.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with enums. Description lists the preset values but adds no extra meaning beyond the schema. Does not explain semantics of each preset (e.g., 'indefinite').

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states the verb 'Set' and the resource 'duration preset', listing the five preset values. Distinct from sibling tools which are sleep-related, not about setting durations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use this tool versus alternatives. Does not mention prerequisites, when not to use, or compare to sibling tools like setting a custom duration.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

start_sleep_preventionC

Start preventing system sleep with specified mode and duration

ParametersJSON Schema
NameRequiredDescriptionDefault
modeNoSleep prevention modeidle
duration_minutesNoDuration in minutes. Omit for indefinite.

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must compensate but only states 'preventing system sleep'. It does not explain behavioral details like whether modes affect different sleep states, the effect of indefinite duration, or what happens if sleep prevention is already active.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence with no redundant words. However, it could leverage the space to include more useful details without becoming lengthy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the absence of an output schema and the presence of sibling tools, the description fails to explain return values, side effects, or how this tool interacts with others (e.g., 'stop_sleep_prevention'). It is insufficient for an agent to understand the tool's full context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the schema already describes both parameters. The description adds no new meaning beyond 'specified mode and duration', which merely restates the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action (start preventing system sleep) and mentions the parameters (mode and duration). It implicitly differentiates from sibling 'stop_sleep_prevention' by verb, but does not explicitly address other siblings like 'set_duration_preset'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives (e.g., 'set_duration_preset'). There is no mention of prerequisites, typical use cases, or when not to use it.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

stop_sleep_preventionB

Stop active sleep prevention

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

B3.4/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Fails to disclose effects (e.g., error if no prevention active), permissions needed, or return value. No annotations to compensate.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Very short sentence, front-loaded, no waste. Could include more behavior context without much length.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Adequate for a no-parameter tool but missing behavioral details like side effects or return status.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

No parameters; schema coverage 100%. Description adds no extra meaning but baseline is 4 due to zero parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clear verb-action and resource: 'Stop active sleep prevention'. Distinct from sibling 'start_sleep_prevention'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when or why to use this tool versus alternatives like 'start_sleep_prevention' or 'get_sleep_status'.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

TDQS

A3.8/5.0
Disambiguation5/5

Each tool has a clearly distinct purpose: status check, listing modes, setting presets, starting, and stopping. No overlap between tools.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern (e.g., get_sleep_status, start_sleep_prevention) using snake_case throughout.

Tool Count5/5

5 tools is well-scoped for a sleep prevention utility, covering core actions without excess or deficiency.

Completeness5/5

The tool set covers the full lifecycle: start, stop, check status, list modes, and set duration. No obvious gaps in functionality.

Maintenance

ActivityInactive
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    F
    maintenance
    Enables AI assistants to automate macOS desktop tasks including mouse control, keyboard input, screenshots, window management, and UI interaction.
    14
    414
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables AI assistants to read, create, update, and delete data in macOS apps (Reminders, Calendar, Notes, Mail, Messages, Contacts) via natural language, using EventKit, JXA, and SQLite backends.
    61
    5
    MIT

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cuongnguyenta/SleepBlocker-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server