Skip to main content

CLI & MCP tool to automatically search and book UCSD study rooms via EMS

Project description

ucsd-study-room

Python 3.11+ License: MIT

A CLI tool and MCP server that automatically searches and books UCSD Price Center study rooms (Rooms 1--8) through the EMS Cloud booking system.

Features

  • Headless browser automation -- Searches and books rooms using Playwright with real Chrome, no browser window required
  • UCSD SSO + Duo Push authentication -- Handles SAML-based single sign-on and Duo two-factor authentication
  • Session persistence -- Saves browser sessions (cookies + localStorage) for reuse; credentials stored securely in macOS Keychain
  • Automatic re-authentication -- When SSO expires, opens a headed browser for Duo Push re-verification without requiring you to re-enter credentials
  • CLI interface -- Simple study-room command for searching and booking from the terminal
  • MCP server -- Integrates with Claude Code so you can book rooms using natural language

Requirements

  • Python 3.11 or later
  • Google Chrome installed
  • UCSD account with Duo Push enabled
  • macOS (uses Keychain for credential storage)

Installation

pip install ucsd-study-room
playwright install chromium

Quick Start

1. Log in with your UCSD credentials (first time only):

study-room login

A Chrome window will open. Enter your UCSD SSO credentials when prompted, then approve the Duo Push notification on your phone. Your session and credentials are saved for future use.

2. Search for available rooms:

study-room search --date 2026-03-11 --start 15:00 --end 17:00

3. Search and book interactively:

study-room search --date 2026-03-11 --start 15:00 --end 17:00 --book

CLI Commands

Command Description
study-room login SSO login with Duo Push (opens browser for first-time auth)
study-room search Search available rooms with --date, --start, --end options
study-room search --book Search and book a room interactively
study-room config View or set user info (--name, --email, --attendees)
study-room status Check whether the current session is valid

Examples

# Set your contact info (required before booking)
study-room config --name "Your Name" --email "you@ucsd.edu"

# Search for rooms on a specific date and time
study-room search --date 2026-03-11 --start 14:00 --end 16:00

# Search and book in one step
study-room search --date 2026-03-11 --start 14:00 --end 16:00 --book

# Check if your session is still active
study-room status

MCP Server (Claude Code Integration)

The MCP server lets you search and book study rooms using natural language through Claude Code.

Setup

Add the following to your .claude/settings.json:

{
  "mcpServers": {
    "study-room": {
      "command": "python",
      "args": ["-m", "study_room.mcp_server"]
    }
  }
}

Usage

Once configured, you can use natural language in Claude Code:

  • "Search for available study rooms tomorrow from 2pm to 4pm"
  • "Book Price Center Study Room 3 on March 11 from 3pm to 5pm"
  • "Are there any rooms open this Friday afternoon?"

Available MCP Tools

Tool Description
search_rooms Search for available rooms by date and time range
book_room Book a specific room (use after search_rooms)
login Authenticate via UCSD SSO + Duo Push

How It Works

  1. Browser automation -- Uses Playwright with real Chrome (channel="chrome") in headless mode to interact with the EMS Cloud booking system.
  2. Authentication -- Navigates to the UCSD SAML SSO page, submits credentials, and waits for Duo Push approval. On first login, a headed browser window opens for the Duo flow.
  3. Session management -- After authentication, cookies and browser storage state are saved to ~/.study-room/. Credentials are stored in macOS Keychain via the keyring library. Sessions are valid for 7 days.
  4. Auto re-login -- When a session expires during a search or booking operation, the tool automatically opens a headed browser, loads credentials from Keychain, and re-authenticates with Duo Push.
  5. Room search -- Navigates to the EMS booking page, fills in date and time fields, and parses available rooms by inspecting the DOM for booking buttons.
  6. Booking -- Clicks the add-to-cart button for the selected room, fills in the reservation form (name, email, terms), and submits the reservation.

Configuration

Configuration is stored in ~/.study-room/config.yaml. Default target rooms are Price Center Study Room 1 through 8.

name: "Your Name"
email: "you@ucsd.edu"
default_attendees: 1
rooms:
  - Price Center Study Room 1
  - Price Center Study Room 2
  - Price Center Study Room 3
  - Price Center Study Room 4
  - Price Center Study Room 5
  - Price Center Study Room 6
  - Price Center Study Room 7
  - Price Center Study Room 8

Contributing

Contributions are welcome. To contribute:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/your-feature)
  3. Commit your changes
  4. Push to the branch and open a pull request

Please make sure existing tests pass before submitting.

License

This project is licensed under the MIT License. See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ucsd_study_room-0.1.0.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ucsd_study_room-0.1.0-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file ucsd_study_room-0.1.0.tar.gz.

File metadata

  • Download URL: ucsd_study_room-0.1.0.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for ucsd_study_room-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8fbf49c5ef9f19c43ac3ff4d3bb0af975bd7d0f33a901fb46cc50610711c4d7f
MD5 31e45e5400cf7a168b9886f69afecfd5
BLAKE2b-256 095222abec161905428f7661210120741b6a88875908654830e23f9f55be524c

See more details on using hashes here.

File details

Details for the file ucsd_study_room-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ucsd_study_room-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8c638425341f59d79006e0c5d5ce72204da5ce987454e8451d0e8dcea31b3c62
MD5 caa4ce09edac8a791ffbfe2c9e79681e
BLAKE2b-256 d3507a9ef5a8eb38db4208fad18b8ce78c2228910ea8906ba1d5305045653470

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page