import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import type { ReauthRequiredExecutionInfo } from '../../core/types'; export declare const CALL_TOOL_DESCRIPTION = "Execute an action on an external service or local resource on behalf of the user.\nThis is the PRIMARY tool \u2014 always use this to perform actions. Permission is handled automatically:\n- Read-type actions (low risk) are auto-approved and execute immediately.\n- Write-type actions that need approval will return an approval_required response. Re-call with the approval parameter to confirm or deny.\nDo NOT call aidentity_request_permission first; just call this tool directly.\n\nSupported tools and common actions:\n\n**os** \u2014 Read/write local secret files (.env, credentials, etc.)\n Actions: os.secret.read, os.secret.write\n Example: tool=\"os\", action=\"os.secret.read\", parameters={\"file_path\": \"~/projects/app/.env\"}\n\n**slack** \u2014 Post/read/update/delete messages, list channels, get user info.\n Common actions: slack.message.post, slack.message.read, slack.channel.read, slack.batch.read\n The \"channel\" parameter accepts channel ID (e.g. \"C0A159PP6QM\"), channel name (e.g. \"general\"), or #-prefixed name (e.g. \"#general\"). Responses are compact by default (essential fields only). Set compact=false for full Slack API response.\n Example: tool=\"slack\", action=\"slack.message.post\", parameters={\"channel\": \"C01ABCD2EFG\", \"text\": \"Hello!\"}\n Example: tool=\"slack\", action=\"slack.message.read\", parameters={\"channel\": \"C01ABCD2EFG\", \"limit\": 10}\n\n**github** \u2014 Create/read/update/list issues, pull requests, repositories, contents, labels, Actions workflows, stars, users, notifications and gists.\n Common actions: github.issue.create, github.issue.list, github.issue.read, github.issue.search, github.issue.comment.create, github.pr.create, github.pr.list, github.pr.read, github.pr.merge, github.repo.search, github.content.get, github.content.createOrUpdate, github.branch.list, github.branch.create, github.commit.list, github.code.search, github.repo.create, github.repo.fork, github.label.list, github.label.write, github.workflow.list, github.workflow.run, github.workflow.jobLogs.get, github.repo.starred.list, github.repo.star, github.user.me.get, github.org.teams.list, github.team.members.list, github.user.search, github.notification.list, github.notification.get, github.notification.markRead, github.notification.markAllRead, github.gist.create, github.gist.get, github.gist.list, github.gist.update\n Example: tool=\"github\", action=\"github.issue.create\", parameters={\"owner\": \"org\", \"repo\": \"repo\", \"title\": \"Bug report\", \"body\": \"Details...\"}\n Example: tool=\"github\", action=\"github.pr.create\", parameters={\"owner\": \"org\", \"repo\": \"repo\", \"title\": \"Fix bug\", \"head\": \"feature-branch\", \"base\": \"main\"}\n Example: tool=\"github\", action=\"github.content.get\", parameters={\"owner\": \"org\", \"repo\": \"repo\", \"path\": \"README.md\"}\n\n**jira** \u2014 Manage issues, projects, boards, sprints.\n Common actions: jira.issue.create, jira.issue.search, jira.project.read\n\n**gmail** \u2014 Search/read/send/draft/delete emails, list labels.\n Common actions: gmail.message.search, gmail.message.read, gmail.message.send, gmail.draft.create, gmail.label.read\n Example (new email): tool=\"gmail\", action=\"gmail.message.send\", parameters={\"to\": \"user@example.com\", \"subject\": \"Hello\", \"body\": \"Message content\"}\n Example (draft): tool=\"gmail\", action=\"gmail.draft.create\", parameters={\"to\": \"user@example.com\", \"subject\": \"Draft subject\", \"body\": \"Draft content\"}\n Example (search): tool=\"gmail\", action=\"gmail.message.search\", parameters={\"query\": \"from:boss subject:urgent\"}\n **Replying to emails**: When replying, you MUST include threading parameters to ensure the reply is properly threaded:\n 1. First read the original message with gmail.message.read to get its threadId and Message-ID header (look for {name: \"Message-ID\", value: \"...\"} in the payload.headers array).\n 2. Then send with: threadId (from the read response top-level field), inReplyTo (the Message-ID header value), references (space-separated Message-IDs for the full thread chain; for a first reply, just the single Message-ID).\n Example (reply): tool=\"gmail\", action=\"gmail.message.send\", parameters={\"to\": \"sender@example.com\", \"subject\": \"Re: Original Subject\", \"body\": \"Reply content\", \"threadId\": \"18e1234abcd\", \"inReplyTo\": \"\", \"references\": \"\"}\n\n**outlook** \u2014 Search/read/send/draft Outlook (Microsoft 365) email, list mail folders, trash or permanently delete messages. This is a SEPARATE tool from gmail \u2014 for a user connected via Microsoft, use tool=\"outlook\" with outlook.* actions; do not send gmail.* actions to it.\n Common actions: outlook.message.search, outlook.message.read, outlook.message.send, outlook.draft.create, outlook.folder.read, outlook.message.trash, outlook.message.delete, outlook.batch.read\n Example (new email): tool=\"outlook\", action=\"outlook.message.send\", parameters={\"to\": \"user@example.com\", \"subject\": \"Hello\", \"body\": \"Message content\"}\n Example (search): tool=\"outlook\", action=\"outlook.message.search\", parameters={\"query\": \"from:boss subject:urgent\"}\n Example (read): tool=\"outlook\", action=\"outlook.message.read\", parameters={\"messageId\": \"\"}\n Example (draft): tool=\"outlook\", action=\"outlook.draft.create\", parameters={\"to\": \"user@example.com\", \"subject\": \"Draft subject\", \"body\": \"Draft content\"}\n Recipients (to/cc/bcc) are comma-separated address strings. The body is plain text. Read/search results are compacted (decoded body text, key headers, flags \u2014 no attachment binaries). Use outlook.message.trash to move a message to Deleted Items (recoverable) and outlook.message.delete only for a permanent, irreversible delete.\n\n**calendar** \u2014 List/create/update/delete calendar events. Works with whichever calendar the user connected \u2014 Google Calendar or Microsoft Outlook; the actions, parameters and response shape are identical for both, so never assume a provider.\n Common actions: calendar.event.list, calendar.event.create\n IMPORTANT: start and end MUST be objects with dateTime property, not flat strings.\n Example: tool=\"calendar\", action=\"calendar.event.create\", parameters={\"summary\": \"Meeting\", \"start\": {\"dateTime\": \"2026-07-15T10:00:00\", \"timeZone\": \"Asia/Tokyo\"}, \"end\": {\"dateTime\": \"2026-07-15T11:00:00\", \"timeZone\": \"Asia/Tokyo\"}}\n Example (with an online meeting): tool=\"calendar\", action=\"calendar.event.create\", parameters={\"summary\": \"Sync\", \"start\": {\"dateTime\": \"2026-07-15T10:00:00\", \"timeZone\": \"Asia/Tokyo\"}, \"end\": {\"dateTime\": \"2026-07-15T10:30:00\", \"timeZone\": \"Asia/Tokyo\"}, \"attendees\": [{\"email\": \"them@example.com\"}], \"addMeet\": true, \"meetRequestId\": \"\"}\n To attach an online meeting link, use addMeet/meetRequestId \u2014 the provider mints it (Google Meet on Google, Teams on Outlook). Raw conferenceData/conferenceDataVersion parameters are NOT supported and will be ignored.\n Events come back in one provider-neutral shape: id, summary, start/end, attendees, location, conferenceUrl (the meeting join URL), htmlLink. Read the join URL from conferenceUrl \u2014 provider-specific fields such as hangoutLink are not returned.\n\n**hubspot** \u2014 Read/search/create CRM objects (contacts, companies, deals), properties, associations, engagements.\n Common actions: hubspot.crm.objects.search, hubspot.crm.objects.list, hubspot.crm.objects.batchCreate, hubspot.crm.properties.list, hubspot.crm.engagements.create, hubspot.crm.associations.list, hubspot.account.userDetails.get\n Most CRM actions require an \"objectType\" parameter (e.g. \"contacts\", \"companies\", \"deals\", or a custom object type ID).\n Example (search): tool=\"hubspot\", action=\"hubspot.crm.objects.search\", parameters={\"objectType\": \"contacts\", \"query\": \"acme\"}\n Example (create): tool=\"hubspot\", action=\"hubspot.crm.objects.batchCreate\", parameters={\"objectType\": \"contacts\", \"inputs\": [{\"properties\": {\"email\": \"jane@example.com\", \"firstname\": \"Jane\"}}]}\n For hubspot.crm.engagements.create use parameter key \"type\" (not \"engagementType\"); values \"NOTE\"/\"TASK\". ownerId comes from hubspot.account.userDetails.get.\n\n**linear** \u2014 Linear issue tracker with full CRUD for issues, comments, projects, and more.\n Issue operations: linear.issue.list, linear.issue.read, linear.issue.search, linear.issue.create, linear.issue.update, linear.issue.archive, linear.issue.unarchive, linear.issue.delete, linear.issue.addLabel, linear.issue.removeLabel, linear.issue.subscribe\n Comment management: linear.comment.create, linear.comment.list, linear.comment.update, linear.comment.delete, linear.comment.resolve, linear.comment.unresolve\n Issue relations: linear.issueRelation.create, linear.issueRelation.list, linear.issueRelation.delete\n Cycles/Sprints: linear.cycle.list, linear.cycle.read, linear.cycle.create, linear.cycle.update\n Labels: linear.label.list, linear.label.create, linear.label.update\n Attachments: linear.attachment.create, linear.attachment.list, linear.attachment.delete\n Projects: linear.project.list, linear.project.read, linear.project.create, linear.project.update\n Other: linear.team.list, linear.workflowState.list, linear.viewer.read, linear.user.list\n Example: { \"tool\": \"linear\", \"action\": \"linear.issue.list\", \"parameters\": { \"teamId\": \"\", \"limit\": 20 } }\n Example (create): { \"tool\": \"linear\", \"action\": \"linear.issue.create\", \"parameters\": { \"teamId\": \"\", \"title\": \"Bug report\" } }\n Use linear.team.list to discover teamIds, and linear.workflowState.list to find valid state IDs.\n\n\n**scheduling / inbox** \u2014 Meeting-time negotiation and task requests between users (signed as verifiable credentials).\n Common actions: scheduling.request, scheduling.session.create, inbox.check, inbox.respond, inbox.complete, inbox.send\n Scheduling routing: if the user gives a specific agreed meeting time, create the calendar\n event directly (calendar.event.create). If the time is NOT yet agreed and needs coordination,\n do NOT create the event \u2014 compute candidate slots from calendar.event.list first, then\n COUNT THE OTHER PEOPLE:\n - ONE counterpart (\"X\u3055\u3093\u3068\u65E5\u7A0B\u8ABF\u6574\", \"find a time with X\") -> scheduling.request.\n - TWO OR MORE counterparts (\"A \u3068 B \u3068 \u6253\u3061\u5408\u308F\u305B\", \"the four of us\", several addresses\n in one ask) -> scheduling.session.create, then scheduling.coordinate with the candidate\n slots. The 'to' on scheduling.request is a SINGLE address, so calling it once per person\n is NOT the multi-person path: that creates independent negotiations that can settle on\n DIFFERENT times, with no slot everyone shares and no single confirmation step.\n scheduling.coordinate folds every reply into the slots EVERYONE can make, and\n scheduling.finalize books it once. scheduling.coordinate also returns an inviteUrl per\n participant \u2014 show them to the user, since the notification email may not arrive. scheduling.coordinate also returns an\n expiresAt: the answer window CLOSES then, defaults to 48h, and can land BEFORE the\n proposed dates \u2014 tell the user that date, and pass an explicit 'deadline' to\n scheduling.session.create when the meeting is further out. Before scheduling.finalize,\n call scheduling.session.status to see whether people actually answered (counts and the\n common slots, never who said what); finalizing without it is a guess.\n\n There are TWO roles \u2014 act according to which side you are on:\n - Requester flow (you initiate): scheduling.request sends candidate slots. The counterpart's\n human-approved response arrives in YOUR inbox.check as an item with role: \"sent\". BRANCH ON status\n \u2014 but what a status MEANS depends on its taskType, so read the item's taskType first.\n For a SCHEDULING item (taskType \"scheduling\"):\n \u2022 status \"completed\": the meeting was ALREADY auto-confirmed and booked server-side \u2014 the item\n carries a calendarEventId and htmlLink (plus the online-meeting link). You are DONE: do NOT call\n calendar.event.create (it would create a duplicate). Just tell the user the confirmed date/time\n and the meeting link. (When the sender's delegation policy authorizes it, the server confirms and\n books automatically the moment the counterpart approves; otherwise the item stays \"processing\".)\n \u2022 status \"processing\": awaiting manual confirmation \u2014 confirm the chosen slot with the user, create\n the calendar event with calendar.event.create (add the counterpart to attendees so the calendar\n invite goes out), then call inbox.complete. Set addMeet: true and meetRequestId to the inbox item id\n (idempotent \u2014 retries won't mint duplicate meetings) for the online-meeting link \u2014 Google Meet on a\n Google connection, Microsoft Teams on an Outlook one. A \"processing\" item can be\n auto-confirmed right after you observe it, so re-check before booking and never race ahead.\n \u2022 status \"declined\": inform the user and do not book \u2014 the negotiation is over.\n For any NON-scheduling item (e.g. taskType \"doc_review\"):\n \u2022 status \"completed\": the recipient delivered the result and the task is FINISHED. The result is in\n the item's responseData \u2014 report THAT. There is no calendar event, no confirmed time and no Meet\n link on such an item, so do not look for or invent a calendarEventId, a confirmed time, or a\n Meet link (none exists), and do not call calendar.event.create.\n \u2022 status \"declined\": the recipient did not carry out the task \u2014 inform the user.\n - Recipient flow (someone sent YOU a request): it appears in inbox.check with role: \"received\" \u2192\n confirm with the user \u2192 reply with inbox.respond. That is the end of your job.\n Do NOT create a calendar event when you are the recipient \u2014 the sender books it (or the server\n auto-confirms it under the sender's delegation) and you will receive a calendar invite.\n When a received scheduling request surfaces, do not just list the candidates \u2014 in the same turn,\n check the user's calendar (calendar.event.list over the candidate windows), determine which\n candidates are free, and present: the request summary, which slots are open, your recommended\n slot, and a confirmation question. Only call inbox.respond after the user confirms.\n\n inbox.check results are point-in-time \u2014 when the user asks about responses or new requests,\n ALWAYS call inbox.check again; never answer from a previous check result.\n\n Example: tool=\"scheduling\", action=\"scheduling.request\", parameters={\"to\": \"them@example.com\", \"topic\": \"sync\", \"durationMinutes\": 30, \"candidates\": [{\"start\": \"2026-06-12T10:00:00+09:00\", \"end\": \"2026-06-12T10:30:00+09:00\"}]}\n The response includes a schedulingUrl \u2014 always show it to the user so it can be shared via another channel if needed (the notification email is sent automatically but may not arrive).\n inbox.send is the low-level primitive for other task types.\n Example: tool=\"inbox\", action=\"inbox.check\", parameters={}\n Example (recipient responds to a request): tool=\"inbox\", action=\"inbox.respond\", parameters={\"id\": \"\", \"action\": \"accept\", \"data\": {\"selectedSlot\": {\"start\": \"2026-06-18T14:00:00+09:00\", \"end\": \"2026-06-18T15:00:00+09:00\"}}}\n Example (requester completes after booking): tool=\"inbox\", action=\"inbox.complete\", parameters={\"id\": \"\", \"result\": {\"calendarEventId\": \"...\", \"meetUrl\": \"...\"}}\n\nCall aidentity_list_available_tools for detailed parameter schemas of each action."; export declare const SERVER_INSTRUCTIONS = "This server provides identity-verified tool execution (VESS AIDENTITY).\nScheduling: if the user gives a specific agreed time, create the calendar event\ndirectly. If the time is not yet agreed (\"\u65E5\u7A0B\u8ABF\u6574\", \"find a time\"), compute candidate\nslots from the user's calendar \u2014 then count the other people. ONE counterpart:\nscheduling.request, then wait for the response. TWO OR MORE: scheduling.session.create\nfollowed by scheduling.coordinate (scheduling.request takes a single 'to', so sending it\nonce per person makes separate negotiations that can settle on different times).\nCheck progress with scheduling.session.status before scheduling.finalize, and tell the\nuser the expiresAt that coordinate returns (the answer window defaults to 48h).\nSize candidateWindow to the user's intent. candidateWindow is a { start, end } range OR an array of\nranges (max 5, total span \u2264 62 days); the server searches each range independently and spreads\ncandidates across them. A specific named day \u2192 one range for that day. A per-day time band\n(\"\u5E73\u65E5\u5348\u5F8C\") \u2192 one range PER business day ([{Mon 13-18}, {Tue 13-18}, \u2026]) so the band is honored\nevery day. Distinct bands (\"\u6708\u66DC\u5348\u524D or \u6728\u66DC\u5348\u5F8C\") \u2192 one range each. A single open stretch\n(\"next week\", \"\u5E73\u65E5\u3067\") \u2192 one wide range spanning the business days.\nAt session start, call inbox.check once to surface pending task requests (role \"received\") AND\nresponses to your own requests (role \"sent\"). As the requester, branch on the sent item's status \u2014\nwhat a status means depends on its taskType, so read the item's taskType first.\nFor a SCHEDULING item: \"completed\" means the server already auto-confirmed and booked it\n(calendarEventId + Meet link present) \u2014 do NOT create the event again, just tell the user the\nconfirmed time and Meet link; \"processing\" means confirm with the user, then create the event\n(adding the counterpart to attendees) and call inbox.complete; \"declined\" means inform the user and\ndo not book. For any NON-scheduling item (e.g. taskType \"doc_review\"): \"completed\" means the\nrecipient delivered the result and the task is finished \u2014 the result is in the item's responseData,\nso report THAT and do not look for or invent a calendar event, a confirmed time, or a Meet link\n(none exists); \"declined\" means the recipient did not carry out the task \u2014 inform the user.\nAs the recipient, reply with inbox.respond and stop \u2014\ndo not create the calendar event; the sender books it (or the server auto-confirms it under the\nsender's delegation) and you will receive a calendar invite.\nAs the recipient, do not just list the candidates \u2014 in the same turn check the user's calendar over\nthe candidate windows, determine which slots are free, and present the request summary, the open slots,\nyour recommended slot, and a confirmation question; only call inbox.respond after the user confirms.\ninbox.check results are point-in-time \u2014 when the user asks about responses or new requests,\nALWAYS call inbox.check again; never answer from a previous check result.\nTask requests/responses are signed as verifiable credentials."; export interface MCPToolHandler { callTool(args: { tool: string; action: string; parameters?: Record; approval?: { token: string; choice: string; vcTTLMinutes?: number; request_id?: string; outcome_id?: string; granted?: boolean; granted_at?: string; granted_by?: string; }; pendingRequestId?: string; }): Promise<{ success: boolean; data?: any; error?: string; approvalRequired?: any; waitingForApproval?: any; reauthRequired?: ReauthRequiredExecutionInfo; }>; issueToolPermission(args: { tool: string; actions: string[]; }): Promise<{ success: boolean; data?: any; error?: string; }>; listAvailableTools(): Promise<{ success: boolean; data?: any; error?: string; }>; } export declare function createMcpServer(handler: MCPToolHandler): McpServer; //# sourceMappingURL=mcp-server.factory.d.ts.map