Agent chat
Corsair MCP agent with typed tools and human-in-the-loop approval
The agent chat panel lets you perform multi-step Gmail and Calendar operations in natural language. Corsair MCP discovery tools and typed workflow tools run in the Next.js server — no separate MCP server required for in-app chat.
Toggle the panel from the inbox header.
What the agent can do
Discovery (read-only)
| Tool | Purpose |
|---|---|
list_operations | Discover available Gmail/Calendar operations |
get_schema | Inspect operation input schemas |
Typed workflow tools
| Tool | Purpose | Approval required |
|---|---|---|
send_email | Send mail with optional attachments | Yes |
schedule_send | Queue mail for later | Yes |
create_calendar_invite | Create event with Google Meet link | Yes |
reschedule_calendar_event | Move an existing event | Yes |
cancel_calendar_event | Cancel an event | Yes |
stage_thread_attachment | Stage a thread attachment for a later send | No |
search_threads | Search Gmail by query and optional lane | No |
list_calendar_events | List events in a date range | No |
Write operations use typed tools with rich approval cards — not raw run_script. The agent may also call curated Corsair discovery operations for reads.
Example prompts
Schedule + draft (hackathon demo prompt):
Send a calendar invite to friend@corsair.dev at 9 AM next Thursday and draft a confirmation reply.
Search threads:
Find threads from alice@company.com in the schedule lane.
Calendar check:
What meetings do I have tomorrow afternoon?
Approval flow
When the agent calls a tool with needsApproval (e.g. send_email, create_calendar_invite):
- Stream pauses with an approval card showing recipients, subject, time, or Meet link
- You Approve or Deny
- On approve, the action runs against your Corsair tenant
- Results stream back into the chat
Never approve actions you do not understand — they run with your Google OAuth credentials.
Provider selection
The agent uses the same AI provider switcher as drafts and classification (OpenAI or Gemini). Provider is sent with each chat request.
Streaming
Responses stream token-by-token using the Vercel AI SDK UI message format. Tool calls appear as structured parts in the transcript.
Maximum request duration: 60 seconds.
Requirements
- Gmail + Calendar fully connected
- At least one AI API key configured server-side
- Phase 2 env (
assertPhase2Env)
Limitations
- Agent operates on your tenant only — no cross-user access
- Complex multi-day workflows may hit the 60s timeout
- If both AI providers are quota-exhausted, chat fails with an error (no template fallback for chat)
API
POST /api/agent/chat — see API routes and Corsair MCP tools.
Related
- Schedule a meeting — faster for simple invite-from-thread cases
- Architecture — Agent chat flow