agentleFS
tre-systemstre-systems/office-assistant/CLAUDE.md

office-assistant

CLAUDE.md1 starsChanged 9 months agoMITView on GitHub

Office 365 calendar assistant powered by Claude Code and Microsoft Graph API. The office-assistant MCP server is registered with Claude Code and provides calendar tools. Always call these tools directly using the mcp__office-assistant__<tool_name> functions in your tool list. Never use Bash, Python scripts, or subprocess workarounds to invoke them. Available tools: get_my_profile, list_events, create_event, update_event, cancel_event, respond_to_event, list_calendars, get_free_busy, find_meeting_times, list_rooms. Everything you need — tools, skills, source code, tests — is inside this project. You do not need to…

  • Reads credentials

The file

We split this CLAUDE.md into the rules it gives an agent

5 rules. About 0 are common, 0 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    All Graph API errors are normalized to GraphApiError dataclass with status_code, code, message, request_id

    line 59
  2. Very specific:

    Add the function to the appropriate module in src/office_assistant/tools/

    line 71
  3. Very specific:

    Use get_graph(ctx) to get the GraphClient

    line 73
  4. Very specific:

    Add tests in tests/test_<module>.py

    line 75
  5. Very specific:

    "CLIENT_ID and TENANT_ID must be set": Run /calendar-setup or check .env file

    line 80

≈ “Common” is an estimate: at least 1 in 5 of the 27,641 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

Office Assistant

Office 365 calendar assistant powered by Claude Code and Microsoft Graph API.

Using the MCP tools

The office-assistant MCP server is registered with Claude Code and provides calendar tools. Always call these tools directly using the mcp__office-assistant__<tool_name> functions in your tool list. Never use Bash, Python scripts, or subprocess workarounds to invoke them.

Available tools: get_my_profile, list_events, create_event, update_event, cancel_event, respond_to_event, list_calendars, get_free_busy, find_meeting_times, list_rooms.

Everything you need — tools, skills, source code, tests — is inside this project. You do not need to search outside the repo.

Architecture

  • MCP server (src/office_assistant/server.py): FastMCP over stdio, provides calendar tools
  • App context (src/office_assistant/app.py): Shared mcp instance + lifespan that manages the GraphClient
  • Graph client (src/office_assistant/graph_client.py): Async HTTP client with retry, pagination, and error normalization
  • Auth (src/office_assistant/auth.py): MSAL device code flow, tokens cached at ~/.office-assistant/
  • Tools (src/office_assistant/tools/): MCP tool modules — events.py, calendars.py, rooms.py, availability.py
  • Helpers (src/office_assistant/tools/_helpers.py): Shared validation (emails, datetimes, timezones) and error response formatting
  • Skills (.claude/skills/): User-facing /slash-commands that map to tool calls

Commands

  • /calendar - Natural language calendar queries (auto-invoked)
  • /schedule-meeting - Create meetings
  • /find-time - Find available slots across people
  • /check-availability - Free/busy lookup
  • /calendar-setup - Authentication setup

Development

  • Python 3.11+, managed with uv, dependencies in pyproject.toml
  • Setup: ./setup.sh
  • Install deps: uv sync --extra dev
  • Tests: uv run pytest
  • Lint: uv run ruff check src/ tests/
  • Format: uv run ruff format src/ tests/
  • Type check: uv run mypy src/
  • All checks: uv run pytest -q --cov && uv run ruff check . && uv run ruff format --check . && uv run mypy src/
  • MCP server directly: uv run python -m office_assistant

Testing

  • Unit tests mock GraphClient methods (get, get_all, post, patch, delete) via conftest.py
  • Integration tests use respx to mock HTTP responses with the real GraphClient
  • List endpoints (list_events, list_rooms, list_calendars) use mock_graph.get_all (paginated)
  • Single-resource endpoints (update_event fetch) use mock_graph.get
  • Coverage minimum: 80% (enforced in CI), currently ~95%

Key patterns

  • All Graph API errors are normalized to GraphApiError dataclass with status_code, code, message, request_id
  • Tool error responses use graph_error_response() for consistent shape: {error, errorType, statusCode, ...}
  • Transient errors (429, 503, 504) are retried with exponential backoff (max 3 attempts)
  • Auth retry on 401 (always) or 403 + InvalidAuthenticationToken only — other 403 codes (e.g. ErrorAccessDenied) are real permission errors and do NOT trigger re-auth
  • Pagination via graph.get_all() follows @odata.nextLink automatically
  • Delegate calendar access uses /users/{email} path prefix instead of /me
  • Personal vs org accounts: TENANT_ID=consumers for personal, org tenant GUID for work/school
  • is_online_meeting defaults to False (safe for personal accounts); skills set it to True for work/school accounts
  • Org-only tools (get_free_busy, find_meeting_times, list_rooms) return clear personal-account-specific error messages on 400/401/403

Adding a new tool

  1. Add the function to the appropriate module in src/office_assistant/tools/
  2. Decorate with @mcp.tool() (import mcp from office_assistant.app)
  3. Use get_graph(ctx) to get the GraphClient
  4. Wrap Graph calls in try/except GraphApiError and return graph_error_response(exc)
  5. Add tests in tests/test_<module>.py
  6. The tool is auto-registered — no need to update server.py

Common issues

  • "CLIENT_ID and TENANT_ID must be set": Run /calendar-setup or check .env file
  • 403 on rooms/free-busy/delegate: These require a work/school account with appropriate permissions
  • Token expired: Refresh tokens last ~90 days; after that, re-run /calendar-setup
  • Tests fail on mock_graph.get vs get_all: List endpoints use get_all (paginated), single-resource fetches use get

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.