工具:create_event
在指定日曆中建立活動。
下列範例示範如何使用 curl 叫用 create_event MCP 工具。
| Curl 要求 |
|---|
curl --location 'https://calendarmcp.googleapis.com/mcp/v1' \ --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \ --header 'content-type: application/json' \ --header 'accept: application/json, text/event-stream' \ --data '{ "method": "tools/call", "params": { "name": "create_event", "arguments": { // provide these details according to the tool MCP specification } }, "jsonrpc": "2.0", "id": 1 }' |
輸入內容的結構定義
CreateEvent 的要求訊息。
CreateEventRequest
| JSON 表示法 |
|---|
{ "summary": string, "startTime": string, "endTime": string, "attendeeEmails": [ string ], "attendees": [ { object ( |
| 欄位 | |
|---|---|
summary |
必填。標題。 |
startTime |
必填。開始時間 (ISO 8601,例如 |
endTime |
必填。結束時間 (ISO 8601,例如 |
attendeeEmails[] |
(選用步驟) 已淘汰:請改用 |
attendees[] |
(選用步驟) 活動與會者。如果使用者在主要日曆中建立活動,且至少有一位其他參與者,系統會自動將目前使用者新增為參與者 (如果尚未加入)。 |
recurrenceData[] |
(選用步驟) 重複規則,格式為 |
overrideReminders[] |
(選用步驟) 提醒事項會覆寫日曆預設設定。 |
attachments[] |
(選用步驟) 檔案附件。 |
聯集欄位
|
|
calendarId |
(選用步驟) 要在哪個日曆中建立活動。電子郵件地址 - 可使用 |
聯集欄位
|
|
description |
(選用步驟) 說明。可包含 HTML。 |
聯集欄位
|
|
location |
(選用步驟) 。 |
聯集欄位
|
|
allDay |
(選用步驟) 活動是否為全天活動。如為 true,系統會將開始/結束時間視為午夜。 |
聯集欄位
|
|
timeZone |
(選用步驟) IANA 時區資料庫名稱 (例如 |
聯集欄位
|
|
notificationLevel |
(選用步驟) 這項活動更新應傳送哪種電子郵件通知。 |
聯集欄位
|
|
addGoogleMeetUrl |
(選用步驟) 建立並新增 Google Meet 網址。預設: |
聯集欄位
|
|
visibility |
(選用步驟) 活動的顯示設定。可能的值為:
|
聯集欄位
|
|
colorId |
(選用步驟) 活動的顏色。如需顏色 ID 清單,請參閱 Event 資源的說明文件。 |
聯集欄位
|
|
googleMeetUrl |
(選用步驟) 特定 Google Meet 網址或會議 ID。這會覆寫 |
聯集欄位
|
|
guestPermissions |
(選用步驟) 邀請對象權限。 |
聯集欄位
|
|
availability |
(選用步驟) 線上狀態設定。 |
聯集欄位
|
|
eventType |
(選用步驟) 活動類型。 |
聯集欄位
|
|
workingLocationProperties |
(選用步驟) 工作地點屬性 (如果 |
參與者
| JSON 表示法 |
|---|
{ "id": string "email": string "displayName": string "organizer": boolean "self": boolean "resource": boolean "optionalAttendee": boolean "responseStatus": string "comment": string "additionalGuests": integer } |
| 欄位 | |
|---|---|
聯集欄位
|
|
id |
僅供輸出。商家檔案 ID。 |
聯集欄位
|
|
email |
必填。出席者的電子郵件地址。 |
聯集欄位
|
|
displayName |
(選用步驟) 名稱。 |
聯集欄位
|
|
organizer |
僅供輸出。參與者是否為主辦者。預設: |
聯集欄位
|
|
self |
僅供輸出。這個項目是否代表顯示活動副本的日曆。預設: |
聯集欄位
|
|
resource |
(選用步驟) 出席者是否為資源 (例如會議室)。不可變更,只能在最初新增出席者時設定。預設: |
聯集欄位
|
|
optionalAttendee |
(選用步驟) 列席者是否為選填項目。預設: |
聯集欄位
|
|
responseStatus |
(選用步驟) 回應狀態。可能的值為:
|
聯集欄位
|
|
comment |
僅供輸出。回覆留言。 |
聯集欄位
|
|
additionalGuests |
(選用步驟) 額外房客人數。預設: |
提醒
| JSON 表示法 |
|---|
{ "method": string "minutes": integer } |
| 欄位 | |
|---|---|
聯集欄位
|
|
method |
必填。放送方式。可能的值為:
|
聯集欄位
|
|
minutes |
必填。提醒觸發時間提前幾分鐘。 |
GuestPermissions
| JSON 表示法 |
|---|
{ "guestsCanInviteOthers": boolean "guestsCanModify": boolean "guestsCanSeeGuests": boolean } |
| 欄位 | |
|---|---|
聯集欄位
|
|
guestsCanInviteOthers |
(選用步驟) 邀請對象是否可以邀請其他人。 |
聯集欄位
|
|
guestsCanModify |
(選用步驟) 邀請對象是否可以修改活動。 |
聯集欄位
|
|
guestsCanSeeGuests |
(選用步驟) 邀請對象是否能查看其他邀請對象。 |
附件
| JSON 表示法 |
|---|
{ "fileUrl": string "title": string } |
| 欄位 | |
|---|---|
聯集欄位
|
|
fileUrl |
必填。附件的網址連結。 |
聯集欄位
|
|
title |
(選用步驟) 附件名稱。 |
WorkingLocationProperties
| JSON 表示法 |
|---|
{
"type": enum ( |
| 欄位 | |
|---|---|
聯集欄位
|
|
type |
(選用步驟) 工作地點類型。 |
聯集欄位
|
|
customLocationLabel |
(選用步驟) 自訂位置的標籤。如果類型為 |
NotificationLevel
接收最新消息的電子郵件通知層級。
| 列舉 | |
|---|---|
NOTIFICATION_LEVEL_UNSPECIFIED |
預設。視為 ALL。 |
NONE |
沒有通知。 |
EXTERNAL_ONLY |
僅限外部出席者。 |
ALL |
所有與會者。 |
可用性
活動的供應情形設定。
| 列舉 | |
|---|---|
AVAILABILITY_UNSPECIFIED |
預設。視為 BUSY。 |
AVAILABILITY_BUSY |
在日曆上封鎖時間。 |
AVAILABILITY_FREE |
不會封鎖時間。 |
EventType
事件類型。建立後即無法變更。
| 列舉 | |
|---|---|
EVENT_TYPE_UNSPECIFIED |
視為 DEFAULT。 |
DEFAULT |
定期活動。預設值。 |
OUT_OF_OFFICE |
不在辦公室的活動。 |
FOCUS_TIME |
專注時間活動。 |
WORKING_LOCATION |
工作地點活動。 |
BIRTHDAY |
每年舉辦的全天特別活動。 |
FROM_GMAIL |
Gmail 中的活動。無法建立這類活動。 |
WorkingLocationType
工作地點類型。
| 列舉 | |
|---|---|
WORKING_LOCATION_TYPE_UNSPECIFIED |
未指定工作地點類型。系統會將其視為 HOME_OFFICE。 |
HOME_OFFICE |
居家辦公室。 |
CUSTOM_LOCATION |
自訂位置。 |
輸出內容的結構定義
事件
| JSON 表示法 |
|---|
{ "id": string, "status": string, "htmlLink": string, "created": string, "updated": string, "summary": string, "description": string, "location": string, "creator": { object ( |
| 欄位 | |
|---|---|
id |
專屬 ID。 |
status |
(選用步驟) 狀態,可能的值為:
|
htmlLink |
僅供輸出。Google 日曆網頁版使用者介面中,這個活動的絕對連結。 |
created |
僅供輸出。建立時間 (ISO 8601)。 |
updated |
僅供輸出。上次修改時間 (ISO 8601)。 |
summary |
標題。 |
description |
(選用步驟) 說明。可包含 HTML。 |
location |
(選用步驟) 。 |
creator |
僅供輸出。創作者。 |
organizer |
僅供輸出。主辦人。如果出席活動,也會列在與會者名單中。 |
start |
開始時間 (含)。如果是週期性活動,系統會使用第一個執行個體。 |
end |
結束時間 (不含)。如果是週期性活動,系統會使用第一個例項。 |
recurrence[] |
重複規則,格式為 |
recurringEventId |
週期性活動例項的父項週期性活動 ID。 |
originalStartTime |
週期性執行個體的原始開始時間。這是根據週期性資料,這個執行個體應開始的時間。 |
transparency |
(選用步驟) 已淘汰:請改用 |
visibility |
(選用步驟) 活動的顯示設定。可能的值為:
|
attendees[] |
與會者。 |
conferenceUrl |
視訊會議連結。 |
colorId |
活動的顏色。只會影響你的日曆檢視畫面。這是指日曆調色盤中的項目 ID (字串
|
overrideReminders[] |
提醒。如未設定,系統會恢復為日曆預設值。 |
attachments[] |
檔案附件。 |
guestPermissions |
邀請對象權限。 |
eventType |
這是指活動類型。 |
workingLocationProperties |
工作地點屬性。只有在 |
availability |
(選用步驟) 線上狀態設定。 |
主體
| JSON 表示法 |
|---|
{ "email": string, "displayName": string, "self": boolean } |
| 欄位 | |
|---|---|
email |
電子郵件、 |
displayName |
名稱。 |
self |
僅供輸出。這個主體是否對應於顯示這個活動副本的日曆。預設: |
DateOrDateTime
| JSON 表示法 |
|---|
{ "date": string, "dateTime": string, "timeZone": string } |
| 欄位 | |
|---|---|
date |
UTC 午夜的 ISO 8601 日期 (例如 |
dateTime |
ISO 8601 時間戳記 (例如 |
timeZone |
TZDB 時區名稱。 |
參與者
| JSON 表示法 |
|---|
{ "id": string "email": string "displayName": string "organizer": boolean "self": boolean "resource": boolean "optionalAttendee": boolean "responseStatus": string "comment": string "additionalGuests": integer } |
| 欄位 | |
|---|---|
聯集欄位
|
|
id |
僅供輸出。商家檔案 ID。 |
聯集欄位
|
|
email |
必填。出席者的電子郵件地址。 |
聯集欄位
|
|
displayName |
(選用步驟) 名稱。 |
聯集欄位
|
|
organizer |
僅供輸出。參與者是否為主辦者。預設: |
聯集欄位
|
|
self |
僅供輸出。這個項目是否代表顯示活動副本的日曆。預設: |
聯集欄位
|
|
resource |
(選用步驟) 出席者是否為資源 (例如會議室)。不可變更,只能在最初新增出席者時設定。預設: |
聯集欄位
|
|
optionalAttendee |
(選用步驟) 列席者是否為選填項目。預設: |
聯集欄位
|
|
responseStatus |
(選用步驟) 回應狀態。可能的值為:
|
聯集欄位
|
|
comment |
僅供輸出。回覆留言。 |
聯集欄位
|
|
additionalGuests |
(選用步驟) 額外房客人數。預設: |
提醒
| JSON 表示法 |
|---|
{ "method": string "minutes": integer } |
| 欄位 | |
|---|---|
聯集欄位
|
|
method |
必填。放送方式。可能的值為:
|
聯集欄位
|
|
minutes |
必填。提醒觸發時間提前幾分鐘。 |
附件
| JSON 表示法 |
|---|
{ "fileUrl": string "title": string } |
| 欄位 | |
|---|---|
聯集欄位
|
|
fileUrl |
必填。附件的網址連結。 |
聯集欄位
|
|
title |
(選用步驟) 附件名稱。 |
GuestPermissions
| JSON 表示法 |
|---|
{ "guestsCanInviteOthers": boolean "guestsCanModify": boolean "guestsCanSeeGuests": boolean } |
| 欄位 | |
|---|---|
聯集欄位
|
|
guestsCanInviteOthers |
(選用步驟) 邀請對象是否可以邀請其他人。 |
聯集欄位
|
|
guestsCanModify |
(選用步驟) 邀請對象是否可以修改活動。 |
聯集欄位
|
|
guestsCanSeeGuests |
(選用步驟) 邀請對象是否能查看其他邀請對象。 |
WorkingLocationProperties
| JSON 表示法 |
|---|
{
"type": enum ( |
| 欄位 | |
|---|---|
聯集欄位
|
|
type |
(選用步驟) 工作地點類型。 |
聯集欄位
|
|
customLocationLabel |
(選用步驟) 自訂位置的標籤。如果類型為 |
EventType
事件類型。建立後即無法變更。
| 列舉 | |
|---|---|
EVENT_TYPE_UNSPECIFIED |
視為 DEFAULT。 |
DEFAULT |
定期活動。預設值。 |
OUT_OF_OFFICE |
不在辦公室的活動。 |
FOCUS_TIME |
專注時間活動。 |
WORKING_LOCATION |
工作地點活動。 |
BIRTHDAY |
每年舉辦的全天特別活動。 |
FROM_GMAIL |
Gmail 中的活動。無法建立這類活動。 |
WorkingLocationType
工作地點類型。
| 列舉 | |
|---|---|
WORKING_LOCATION_TYPE_UNSPECIFIED |
未指定工作地點類型。系統會將其視為 HOME_OFFICE。 |
HOME_OFFICE |
居家辦公室。 |
CUSTOM_LOCATION |
自訂位置。 |
可用性
活動的供應情形設定。
| 列舉 | |
|---|---|
AVAILABILITY_UNSPECIFIED |
預設。視為 BUSY。 |
AVAILABILITY_BUSY |
在日曆上封鎖時間。 |
AVAILABILITY_FREE |
不會封鎖時間。 |
工具註解
破壞性提示:❌ | 等冪提示:❌ | 唯讀提示:❌ | 開放世界提示:❌
授權範圍
需要下列其中一種 OAuth 範圍:
https://www.googleapis.com/auth/calendarhttps://www.googleapis.com/auth/calendar.events