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
In this repository5 other files it gives its agents.
- calendar-setupSkill
- calendarSkill
- check-availabilitySkill
- find-timeSkill
- schedule-meetingSkill
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
- Very specific: line 59
All Graph API errors are normalized to GraphApiError dataclass with status_code, code, message, request_id
- Very specific: line 71
Add the function to the appropriate module in src/office_assistant/tools/
- Very specific: line 73
Use get_graph(ctx) to get the GraphClient
- Very specific: line 75
Add tests in tests/test_<module>.py
- Very specific: line 80
"CLIENT_ID and TENANT_ID must be set": Run /calendar-setup or check .env file
≈ “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.
Files
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): Sharedmcpinstance + lifespan that manages theGraphClient - 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-commandsthat 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
GraphClientmethods (get,get_all,post,patch,delete) viaconftest.py - Integration tests use
respxto mock HTTP responses with the realGraphClient - List endpoints (
list_events,list_rooms,list_calendars) usemock_graph.get_all(paginated) - Single-resource endpoints (
update_eventfetch) usemock_graph.get - Coverage minimum: 80% (enforced in CI), currently ~95%
Key patterns
- All Graph API errors are normalized to
GraphApiErrordataclass withstatus_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 +
InvalidAuthenticationTokenonly — other 403 codes (e.g.ErrorAccessDenied) are real permission errors and do NOT trigger re-auth - Pagination via
graph.get_all()follows@odata.nextLinkautomatically - Delegate calendar access uses
/users/{email}path prefix instead of/me - Personal vs org accounts:
TENANT_ID=consumersfor personal, org tenant GUID for work/school is_online_meetingdefaults toFalse(safe for personal accounts); skills set it toTruefor 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
- Add the function to the appropriate module in
src/office_assistant/tools/ - Decorate with
@mcp.tool()(importmcpfromoffice_assistant.app) - Use
get_graph(ctx)to get theGraphClient - Wrap Graph calls in
try/except GraphApiErrorand returngraph_error_response(exc) - Add tests in
tests/test_<module>.py - The tool is auto-registered — no need to update
server.py
Common issues
- "CLIENT_ID and TENANT_ID must be set": Run
/calendar-setupor check.envfile - 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.getvsget_all: List endpoints useget_all(paginated), single-resource fetches useget
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
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.

