Secure Calendar Automation for Enterprise Teams: Enforcing Per-User Access in an MCP Scheduling Assistant

Sharvari Raut
Sharvari Raut
Secure Calendar Automation for Enterprise Teams: Enforcing Per-User Access in an MCP Scheduling Assistant

How a professional-services firm can let an AI assistant manage calendars on behalf of each employee, with permissions verified by the server on every tool call.

The business problem

A 200-person consulting firm wants an AI assistant that handles scheduling: finding time across partners, booking client workshops, rescheduling when priorities shift. Employees, executive assistants and a rotating group of external contractors will all use it.

The fastest way to build it is a single service account. One API key sits in an environment variable, the MCP server uses it for every request, and anyone who can reach the assistant can act on the whole organization's calendar. That works in a pilot. In production it creates three problems:

  • No least privilege. A contractor asks the assistant to “clear Friday” and the assistant, holding full write access, complies. The client steering committee meeting disappears.

  • No attribution. Every change is made by the service account, so the audit log cannot say who requested it.

  • One credential, large blast radius. If the key leaks, every calendar is exposed and every user is affected.

This use case describes the alternative: each person signs in as themselves, the server issues and stores separate credentials per user, and what a person can do is decided by the scopes on their token, not by who happens to be typing.

Requirements

  • Individual identity. Every request is tied to a verified user, never to a shared credential.

  • Least privilege. Read and write access are granted separately, per role.

  • Enforcement at the tool boundary. A missing permission check must be structurally impossible, not just unlikely.

  • Session resilience. Short-lived tokens must renew without signing users out, even under concurrent requests.

  • Auditability. Every action can be attributed to a named account.

Roles and scopes

The permission model is intentionally small: two scopes and three roles. A model you can state in one sentence is one you can test exhaustively.

RoleScopes on tokenEffective access
Engagement Managercalendar:read, calendar:writeViews availability and creates, edits and cancels events
Executive Assistantcalendar:read, calendar:writeSame as above, on behalf of the executives they support
External Contractorcalendar:readViews schedules and finds shared free time. Cannot change anything

Tool-level enforcement

The server exposes six tools. Each is registered together with the scope it requires, and a tool that does not declare a scope does not register at all. Developers cannot forget a check inside a handler, because the handler is never reached without one.

ToolScope requiredFunction
list_eventscalendar:readEvents in a date range, for one person or a team
get_eventcalendar:readFull details of a single event
find_free_timecalendar:readSlots where all selected attendees are available
add_eventcalendar:writeCreates an event and invites attendees
update_eventcalendar:writeMoves or edits an event
cancel_eventcalendar:writeRemoves an event

When a contractor's assistant attempts add_event, the server returns 403 insufficient_scope and names the missing scope. The server deliberately separates two failure modes: 401 means the caller is not authenticated and must sign in; 403 means the caller is known and the action is not permitted. On a 403 the assistant should explain the limit to the user in plain language and not retry.

The scope check runs before any application code. If a tool has no declared scope, the server refuses to start.

Token architecture

Two distinct sets of credentials are involved, and keeping them separate is central to the design.

  • The assistant's token. Presented to the MCP server on each request. The server verifies the signature, audience and expiry, then reads the scopes from it. It never trusts a user identifier supplied in a request body.

  • The calendar provider's token. When the server must reach the underlying calendar, it uses that person's own grant, stored one row per user and keyed by stable account ID, never by session. Refresh tokens are encrypted at rest with AES-256-GCM. Access tokens are held in memory only and carry their own expiry. Nothing sensitive is written to logs.

The provider grant is also requested with the narrowest scope available. A contractor's sign-in asks the provider for read-only access only, so even a defect in the MCP server could not produce a write: the upstream token cannot perform one. This is defense in depth, with two independent controls on the same action.

Handling token refresh under concurrency

Access tokens are short-lived, fifteen minutes in this build. This is a security benefit until two tool calls from the same user arrive together, both find the token expired, and both attempt a refresh. When the provider rotates refresh tokens, the second request presents a token the first has already consumed. The provider treats this as token reuse and revokes the entire grant, signing out a legitimate user.

The remedy is a single in-flight refresh per user. The second caller waits for the first and reuses its result, while different users never block one another. The full request path looks like this:

python
call(tool, bearer)
  claims = verify(bearer)              # signature, audience, expiry
  need   = TOOL_SCOPES[tool]           # no entry, no registration
  if need not in claims.scopes:        # 403 insufficient_scope
      deny(need)
  creds  = vault.get(claims.sub)       # decrypt this user's refresh token
  token  = refresh_once(claims.sub)    # single flight per user
  return handler(user=claims.sub, token=token, args)

Failure handling matters as much. If the provider returns invalid_grant, the user has revoked access or the grant has expired, and retrying cannot help. The server flags that user as needing to reconnect and returns an actionable error so the assistant can prompt for re-authorization. There are no retry loops and no stack traces exposed to end users.

Scenario walkthrough

The behavior can be demonstrated in three steps, with the server running in NitroStudio so each call and response is visible.

  • Authorized write. An engagement manager asks the assistant to book “client workshop, Thursday 5 pm.” The event is created and the tool result returns its ID.

  • Denied write, permitted read. A contractor attempts the same request and receives insufficient_scope, which the assistant explains in one sentence. The contractor then asks what is scheduled on Thursday and sees the workshop.

  • Transparent renewal. The manager's access token expires mid-session. The next call refreshes in the background and succeeds without any sign-in prompt.

NitroStudio's Tools tab can run any tool as any role and display the exact response, which makes the full permission matrix easy to walk through. Generated test cases covered scenarios that are easy to miss by hand, such as a read-only user calling a write tool with an otherwise valid payload.

Outcomes

  • Contained access. A contractor's session cannot modify client-facing schedules, regardless of what the assistant is asked to do.

  • Attributable actions. Every change maps to a named account, supporting internal audit and client reviews.

  • Reduced exposure. No single shared key, and per-user credentials that are encrypted at rest and independently revocable.

  • Stable sessions. Refresh logic that holds up under concurrent requests keeps users signed in.

Why this matters

The value of an assistant with tools is not that it can act, but that it acts on behalf of a specific person, within that person's authority. A server that cannot distinguish a partner from a contractor is not ready for a firm, whatever its demo looks like. Per-user tokens, scopes enforced at the tool boundary and concurrency-safe refresh are what move an assistant from prototype to something an organization can deploy and trust.

Next: per-event visibility, so confidential engagements can appear on a calendar as “busy” to those without clearance while remaining fully visible to the team involved.

Sharvari Raut

Sharvari Raut

Author

A blog poet ✍🏻

Popular tags