Skip to main content
Glama

UNC LibCal MCP

Claude、Cursor、Codex、または任意のMCPクライアントからUNC Davis Libraryの学習スペースを予約するためのMCPサーバー — Apple Calendar連携オプション付き。

有効なOnyenを持つUNCの学生、教員、スタッフ向けに構築されています。UNC Librariesとは提携しておらず、その承認も受けていません。

機能

エージェントに依頼:

明日の午後2時にDavis cubeを予約して

サーバーは次のことを行います:

  1. LibCalの空き状況を確認(公開API — ログイン不要)

  2. ランク付けされた候補を提案(libcal_suggest)、または確認した枠を予約(libcal_book)

  3. ブラウザセッションで予約を完了(Playwright + 保存済みのOnyenログイン)

  4. オプションでApple Calendarにイベントを追加(macOSのみ)

Related MCP server: @aiwerk/mcp-server-cal

要件

  • Node.js 20以上

  • UNC Onyen(予約用。空き状況の確認はログインなしで動作)

  • macOS(Apple Calendar同期用。オプション)

  • Chromium(Playwrightにより自動インストール)

クイックスタート

1. クローンしてインストール

git clone https://github.com/Thespaceblade/unc-libcal-mcp.git
cd unc-libcal-mcp
npm install
npx playwright install chromium
npm run build
npm test

2. LibCalにログイン

npm run login

ブラウザが開く → Onyenでサインイン(プロンプトが表示されたら+ Duo)→ Davis LibCalページが読み込まれたら、ターミナルでEnterを押します。

セッションは~/.unc-libcal/storage-state.jsonに保存されます(このファイルは決してコミットしないでください)。

3. 設定(オプション)

初回実行時に、~/.unc-libcal/config.jsonがデフォルト値で作成されます:

{
  "defaultCategory": "davis-cubes",
  "calendarName": "Calendar",
  "preferSameDay": true,
  "minLeadMinutes": 30,
  "searchHorizonDays": 7,
  "bookingPurpose": "Study session"
}

エージェントにlibcal_list_calendarsを実行するよう依頼し、calendarNameを希望するApple Calendarに設定します。macOSのプロンプトが表示されたらAutomation権限を許可します(TerminalまたはCursor → Calendar)。

4. MCPクライアントを接続

すべてのクライアントで、dist/index.jsへの絶対パスが必要です。リポジトリ内から:

pwd   # e.g. /Users/you/projects/unc-libcal-mcp
# Use: <that-path>/dist/index.js

またはワンライナー:

node -e "const p=require('path'); console.log(p.join(process.cwd(),'dist/index.js'))"

以下のすべてのクライアントは同じstdioサーバーを実行します:

{
  "command": "node",
  "args": ["/absolute/path/to/unc-libcal-mcp/dist/index.js"]
}

設定を編集した後はクライアントを再起動してください。

Claude Desktop

ファイル:~/Library/Application Support/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "unc-libcal": {
      "command": "node",
      "args": ["/absolute/path/to/unc-libcal-mcp/dist/index.js"]
    }
  }
}

Claude Desktopを完全に終了してから開き直します。

Cursor

オプションA — UI: 設定 → MCP → サーバーを追加 → 上記のJSONブロックを貼り付けます。

オプションB — プロジェクトファイル: このリポジトリ内の.cursor/mcp.json(チームメイトと共有するのに便利):

{
  "mcpServers": {
    "unc-libcal": {
      "command": "node",
      "args": ["./dist/index.js"]
    }
  }
}

./dist/index.jsを使用するのは、CursorのMCPのcwdがプロジェクトルートの場合のみです。それ以外の場合は絶対パスを使用してください。

OpenAI Codex (CLI)

CodexはJSONではなくTOMLを使用します。ファイル:~/.codex/config.toml(または信頼されたプロジェクト内の.codex/config.toml)。

[mcp_servers.unc-libcal]
command = "node"
args = ["/absolute/path/to/unc-libcal-mcp/dist/index.js"]

またはCLI経由:

codex mcp add unc-libcal -- node /absolute/path/to/unc-libcal-mcp/dist/index.js
codex mcp list   # verify it appears

サーバーが表示されない場合、プロジェクトローカルの.codex/config.tomlを使用するときは、プロジェクトが信頼済みであることを確認してください(リポジトリ内でcodex trustを実行)。

Claude Code (CLI)

ファイル:~/.claude.json(グローバル)またはプロジェクト内の.mcp.json:

{
  "mcpServers": {
    "unc-libcal": {
      "command": "node",
      "args": ["/absolute/path/to/unc-libcal-mcp/dist/index.js"]
    }
  }
}

Claude Codeセッションで/mcpを実行し、ツールが読み込まれていることを確認します。

その他のMCPクライアント

stdio MCPをサポートするクライアントは、同じcommand + argsを使用できます。npm run buildの後にdist/index.jsを指定してください。

5. 動作確認

エージェントで次を試してください:

Check libcal auth status

次に:

Suggest Davis cubes for 2 hours tomorrow

サーバーが接続されると、libcal_auth_status、libcal_suggest、libcal_check_availability、libcal_book、libcal_list_calendarsが利用可能になるはずです。

MCPツール

ツール

ログイン必要

目的

libcal_suggest

いいえ

ランク付けされた予約オプション。日付を指定しない限り当日優先

libcal_check_availability

いいえ

特定の日付の空き枠

libcal_book

はい

確認済みの枠を予約 + オプションのApple Calendarイベント

libcal_auth_status

はい

保存されたセッションがまだ有効かどうかを確認

libcal_list_calendars

いいえ

Apple Calendarの名前を一覧表示(macOS)

予約の流れ

  1. 自由形式のリクエスト(「cubeを予約」「最大時間」)の場合 → エージェントは最初に**libcal_suggest**を呼び出します

  2. エージェントが番号付きのオプションを表示し、1つ選択します

  3. エージェントは**libcal_book**をuser_confirmed: trueと選択した日時で呼び出します

libcal_bookは明示的な確認なしでは実行されません。

スペースカテゴリ

ID

説明

davis-cubes

Davis Collaboration Cubes(デフォルト)

davis-study-rooms

Davisグループ学習室

davis-computers

Data Servicesラボのコンピュータ

プロンプト例

Book me a study room for as long as possible
→ libcal_suggest shows TODAY vs later; you pick; then libcal_book

Book me a Davis cube tomorrow 11am–1pm
→ libcal_suggest or direct libcal_book with your exact time

Any study rooms free Friday afternoon?
→ libcal_check_availability or libcal_suggest

仕組み

  • 空き状況 — LibCalのグリッドAPIをリバースエンジニアリング(/spaces/availability/grid)

  • 予約 — Playwrightが実際のLibCal UIを操作:スロット選択 → 時間を送信 → /spaces/authチェックアウト → フォーム確認

  • カレンダー — AppleScript → Calendar.app(macOSのAutomation権限が必要)

セッションは定期的に期限切れになります。libcal_auth_statusが期限切れを報告したら、npm run loginを再度実行してください。

CLIスクリプト

# Refresh Onyen session
npm run login

# Run unit tests (38 tests)
npm test

# Book via CLI (uses saved session)
node dist/scripts/run-task.js --date 2026-09-01 --start 14:00 --duration 120

# Check public bookings page / cancel-link availability
node dist/scripts/list-bookings.js

予約のキャンセル

UNC LibCalのWeb UIには「マイ予約」のキャンセルページはありません。alerts@mail.libcal.comからの確認メールに記載されたリンクからキャンセルしてください。

LibCalの制限(UNC Davis)

  • 1日最大3時間まで、30分 / 1時間単位

  • 人気の枠はsuggestとbookの間に取られる可能性があります

  • キューブではチェックアウトフォームに「コース名またはグループ名」が必要な場合があります(configのbookingPurposeがデフォルト)

開発

npm run build    # compile TypeScript → dist/
npm test         # unit + integration tests
npm run dev      # build and start MCP server on stdio

注意事項

  • 個人向け自動化ツール — 責任を持って使用し、UNC Libraryのポリシーに従ってください

  • calendar.lib.unc.edu(UNC Chapel Hill)でのみテスト済み

  • 他のLibCal機関では、src/libcal/constants.tsのlid/gid定数を変更する必要があります

ライセンス

MIT — LICENSEを参照してください。

Available Tools

5 tools
libcal_auth_statusA

Check whether your saved UNC LibCal login session is still valid. Run npm run login in the unc-libcal-mcp project if expired.

NameRequiredDescriptionDefault

No parameters

TDQS

A4.2/5.0
Behavior3/5

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

No annotations are present, so the description carries the burden. It states the tool checks a saved session and provides remediation if expired, but does not disclose the return format, whether any network call is made, or what happens with no saved session. The behavior is generally self-evident for a status check, but richer context would help.

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?

Two short sentences with no filler. The core purpose is stated first, and the actionable recovery command follows immediately. Every word earns its place.

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 zero-parameter, no-output-schema tool, the description is largely complete: it states what is checked and what to do if the session is expired. A minor gap is not describing what the tool returns, but the purpose sentence implies a validity result, and the recovery step covers the main downstream need.

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?

The tool has zero parameters, so parameter semantics are trivially satisfied. The description adds no parameter details, but none are needed. Baseline 4 applies for a no-parameter tool.

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?

Description uses a specific verb ('Check whether') and a precise resource ('saved UNC LibCal login session') with an explicit outcome (valid vs expired). The name and description together clearly distinguish this auth-status tool from the sibling booking/availability tools.

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

Usage Guidelines4/5

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

Clearly indicates when to use the tool: to verify saved session validity. It also gives an actionable alternative by telling the user to run 'npm run login' if expired. It doesn't enumerate when not to use it, but no sibling competes with this auth check, so the guidance is sufficient.

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

libcal_bookA

Book a specific UNC LibCal slot. BOOKING WORKFLOW (required):

  1. For open-ended requests ("book a room", "max hours", "soonest available") → call libcal_suggest FIRST.

  2. Present numbered options to the user. Explain the recommended option (usually same-day if available).

  3. Only call libcal_book after the user picks an option (or gives explicit date+time).

  4. Never auto-book a far-future date when sooner options exist. Requires user_confirmed=true. Categories: davis-cubes, davis-study-rooms, davis-computers

NameRequiredDescriptionDefault
dateYesBooking date YYYY-MM-DD (from user choice or libcal_suggest option)
categoryNoSpace category id (default: davis-cubes)
space_idNoLibCal item/space id (from libcal_suggest option if available)
start_timeYesStart time HH:MM (from user choice or libcal_suggest option)
user_confirmedYesMust be true — confirms the user explicitly chose this slot
add_to_calendarNoAdd to Apple Calendar after booking (default true)
duration_minutesYesBooking length in minutes

TDQS

A4.6/5.0
Behavior4/5

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

With no annotations, the description carries the burden of behavioral disclosure. It clearly states the user_confirmed=true requirement, the category restrictions, and the anti-far-future-booking guardrail. It could additionally mention side effects like calendar creation or failure behavior, but the key behavioral constraints are well covered.

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 tightly structured with a numbered workflow and no filler. Each sentence contributes necessary operational guidance, and key constraints are front-loaded before the raw category list.

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?

The description covers the critical workflow context: prerequisites, confirmation requirement, category options, and when invocation is appropriate. It leaves some operational details to the schema (duration bounds, optional parameters) and doesn't describe error/return behavior, but for a booking action the core invocation context 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?

Schema coverage is 100%, so the baseline is 3. The description adds value by clarifying that date and start_time come from user choice or libcal_suggest options, that user_confirmed must be true, and by listing valid categories. This goes beyond the schema's basic descriptions.

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?

Description clearly states the tool's function: 'Book a specific UNC LibCal slot.' It distinguishes itself from siblings by describing the required prerequisite workflow with libcal_suggest and by limiting scope to confirmed, specific bookings.

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

Usage Guidelines5/5

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

Provides explicit, step-by-step usage guidance: call libcal_suggest first for open-ended requests, present options, only call after user picks an option or gives explicit date/time, and never auto-book a far-future date when sooner options exist. This is strong, actionable routing guidance.

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

libcal_check_availabilityA

Check open slots on ONE specific date. For smart ranked search across days, use libcal_suggest instead. Categories: davis-cubes, davis-study-rooms, davis-computers

NameRequiredDescriptionDefault
dateYesDate to check, YYYY-MM-DD
categoryNoSpace category id (default: davis-cubes)
after_timeNoOnly show slots at or after this time, HH:MM (24h)
duration_minutesNoDesired booking length in minutes (default 60)

TDQS

A4.4/5.0
Behavior3/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. The verb 'Check' implies a non-destructive read operation, and the date-specific scope is clear. However, it does not explicitly confirm that no booking is made, nor does it mention authentication requirements or output characteristics. These gaps are notable but not severe for an availability-check tool.

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 two compact sentences plus a short category list. The core purpose is front-loaded, the differentiation is in the second sentence, and there is no wasted wording.

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 tool with 4 documented parameters and a clear purpose, the description is largely complete. The category list and date-scope note cover the key details. The main omission is the response shape (what an 'open slot' looks like), which matters more because there is no output schema, but the operation is simple enough that this is a minor gap.

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?

Schema coverage is 100%, giving a baseline of 3. The description adds concrete valid category values ('davis-cubes, davis-study-rooms, davis-computers'), which is not in the schema's generic 'Space category id' description. This gives the agent actionable parameter knowledge beyond the schema.

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 states a specific verb and resource: 'Check open slots on ONE specific date.' It also explicitly distinguishes itself from the sibling libcal_suggest, which is the cross-day ranked search, so an agent can clearly tell them apart.

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

Usage Guidelines5/5

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

The description gives explicit when-to-use context ('on ONE specific date') and names the alternative for a different case ('For smart ranked search across days, use libcal_suggest instead'). This directly routes the agent to the correct sibling without leaving it to inference.

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

libcal_list_calendarsA

List Apple Calendar calendar names (use one in ~/.unc-libcal/config.json as calendarName).

NameRequiredDescriptionDefault

No parameters

TDQS

A4.3/5.0
Behavior4/5

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

With no annotations provided, the description carries the behavioral burden. The verb 'List' clearly indicates a read-only operation with no destructive side effects, and the config.json reference provides useful context about where the result is consumed. It does not spell out authentication requirements, but for a simple listing tool the implied read-only nature 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, efficient sentence that front-loads the action and resource, then appends the one essential usage hint. There is no filler or redundancy.

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?

For a zero-parameter, no-output-schema tool, the description fully covers what the tool does and why the agent would call it. It tells the agent the output (calendar names) and how to use it, making it complete enough for correct invocation.

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?

The tool has zero parameters, so parameter semantics are largely not applicable; the baseline for zero parameters is 4. The description adds value by explaining how the output relates to config.json, which is more than the empty schema provides.

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 states a clear, specific action ('List') and resource ('Apple Calendar calendar names'), which is immediately distinct from the sibling tools that check availability, book, authenticate, or suggest. It also tells the agent the practical outcome, selecting a name for config.json, so the purpose is unambiguous.

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 parenthetical 'use one in ~/.unc-libcal/config.json as calendarName' implies when the tool is needed (before configuring a calendar) and how its output should be used. However, it does not explicitly state when to use this tool instead of a sibling, nor does it provide exclusions or prerequisites.

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

libcal_suggestA

Find ranked booking options with same-day priority. Use BEFORE booking when the user has not given an exact date+time. BOOKING WORKFLOW (required):

  1. For open-ended requests ("book a room", "max hours", "soonest available") → call libcal_suggest FIRST.

  2. Present numbered options to the user. Explain the recommended option (usually same-day if available).

  3. Only call libcal_book after the user picks an option (or gives explicit date+time).

  4. Never auto-book a far-future date when sooner options exist. Categories: davis-cubes, davis-study-rooms, davis-computers

NameRequiredDescriptionDefault
categoryNoSpace category id (default: davis-cubes)
max_optionsNoHow many options to return (default 5)
preferred_dateNoUser's preferred date YYYY-MM-DD (optional, boosts ranking)
prefer_same_dayNoPrioritize today if slots exist (default true)
duration_minutesNoDesired length in minutes (default 60; use 180 for max/LibCal limit)
preferred_start_timeNoUser's preferred start HH:MM (optional, boosts ranking)

TDQS

A4.5/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 discloses ranking behavior, same-day priority, numbered option output, and the recommended-option explanation. It does not detail return format or error/no-result behavior, but for a non-destructive suggestion tool the disclosed workflow is reasonably transparent.

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 front-loaded with the core purpose and then gives a structured, actionable workflow. There is minor redundancy between the opening 'Use BEFORE booking...' and step 1, but the numbered format and categories list keep it scannable and useful.

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 tool with six optional parameters, no output schema, and no annotations, the description plus detailed input schema covers invocation behavior, defaults, categories, and the follow-up booking step. It does not cover the exact-date+time path to libcal_check_availability or what to do when no options are found, so it is not fully 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?

Schema coverage is 100%, so the baseline is 3. The description adds practical meaning beyond the schema by listing exact category values (davis-cubes, davis-study-rooms, davis-computers), clarifying duration semantics with 'use 180 for max/LibCal limit', and explaining preferred_date/preferred_start_time as ranking boosts.

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 states a specific action ('Find ranked booking options') on a specific resource with a clear behavioral qualifier ('same-day priority'). It also positions the tool in the booking workflow relative to libcal_book, so an agent can distinguish when this tool is intended.

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

Usage Guidelines5/5

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

It explicitly says to use this tool BEFORE booking when the user has not given an exact date+time, provides a required numbered workflow, and names the condition for calling libcal_book instead. It also instructs the agent never to auto-book far-future dates when sooner options exist.

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

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 5 tool updatesv0.3.0
    • First observedlibcal_auth_status
    • First observedlibcal_book
    • First observedlibcal_check_availability
    • First observedlibcal_list_calendars
    • First observedlibcal_suggest

TDQS

A4.1/5.0

Scored across 5 tools

Disambiguation4/5

The core booking tools are clearly separated: check_availability is for a single date, suggest is for ranked multi-day searching, and book handles the actual reservation. Support tools like auth_status and list_calendars are distinct, though check_availability and suggest could still cause minor confusion without their descriptions.

Naming Consistency3/5

All tools share the libcal_ prefix and snake_case, but the patterns are mixed: some are verb_noun (check_availability, list_calendars), some are bare verbs (book, suggest), and one is noun_noun (auth_status). This is readable but not fully consistent.

Tool Count5/5

Five tools is a well-scoped set for a library booking server. Each tool serves a distinct role: availability checking, ranked suggestions, booking, authentication status, and calendar configuration.

Completeness2/5

The server covers finding and booking slots but lacks obvious lifecycle operations like listing existing bookings or cancelling a booking. Users or agents needing to modify or cancel a reservation would hit a dead end, which is a significant gap for a booking-focused server.

Maintenance

ActivitySlowing
ResponsivenessUnresponsive

Related MCP Connectors

Related MCP Servers