Ensure accessibility in UI components including semantic HTML, ARIA attributes, keyboard navigation, and WCAG 2.2 AA compliance.
中文简介正在准备中。当前显示原文说明。
Google Workspace integration skill for Gmail, Calendar, Drive, Docs, and Sheets via Python client libraries and MCP servers
中文简介正在准备中。当前显示原文说明。
查看安装方法安装前可以查看交给 AI 代理的指令内容。
Skill({ skill: 'google-workspace' });
Use when:
Google Workspace APIs require OAuth 2.0. Use a service account for server-side automation or user OAuth for delegated access.
pip install google-auth google-auth-oauthlib google-auth-httplib2 google-api-python-client
from google.oauth2 import service_account
from googleapiclient.discovery import build
SCOPES = [
'https://www.googleapis.com/auth/gmail.readonly',
'https://www.googleapis.com/auth/calendar',
'https://www.googleapis.com/auth/drive',
]
credentials = service_account.Credentials.from_service_account_file(
'service-account.json',
scopes=SCOPES,
)
# For delegated access (act as a user):
delegated_credentials = credentials.with_subject('user@yourdomain.com')
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
from google.oauth2.credentials import Credentials
import os, pickle
def get_credentials(scopes, token_file='token.pkl', creds_file='credentials.json'):
creds = None
if os.path.exists(token_file):
with open(token_file, 'rb') as f:
creds = pickle.load(f)
if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request())
else:
flow = InstalledAppFlow.from_client_secrets_file(creds_file, scopes)
creds = flow.run_local_server(port=0)
with open(token_file, 'wb') as f:
pickle.dump(creds, f)
return creds
service = build('gmail', 'v1', credentials=credentials)
# List messages
results = service.users().messages().list(userId='me', q='is:unread').execute()
messages = results.get('messages', [])
# Read a message
msg = service.users().messages().get(userId='me', id=messages[0]['id'], format='full').execute()
subject = next(h['value'] for h in msg['payload']['headers'] if h['name'] == 'Subject')
# Send an email
import base64
from email.mime.text import MIMEText
def create_message(to, subject, body):
message = MIMEText(body)
message['to'] = to
message['subject'] = subject
raw = base64.urlsafe_b64encode(message.as_bytes()).decode()
return {'raw': raw}
msg_body = create_message('recipient@example.com', 'Hello', 'Body text here')
service.users().messages().send(userId='me', body=msg_body).execute()
service = build('calendar', 'v3', credentials=credentials)
# List upcoming events
from datetime import datetime, timezone
now = datetime.now(timezone.utc).isoformat()
events_result = service.events().list(
calendarId='primary',
timeMin=now,
maxResults=10,
singleEvents=True,
orderBy='startTime',
).execute()
events = events_result.get('items', [])
# Create an event
event = {
'summary': 'Team Standup',
'start': {'dateTime': '2026-03-15T09:00:00-07:00', 'timeZone': 'America/Los_Angeles'},
'end': {'dateTime': '2026-03-15T09:30:00-07:00', 'timeZone': 'America/Los_Angeles'},
'attendees': [{'email': 'colleague@example.com'}],
}
created = service.events().insert(calendarId='primary', body=event).execute()
from googleapiclient.http import MediaFileUpload, MediaIoBaseDownload
import io
service = build('drive', 'v3', credentials=credentials)
# List files
results = service.files().list(
pageSize=10,
fields='files(id, name, mimeType)',
q="'root' in parents and trashed = false",
).execute()
files = results.get('files', [])
# Upload a file
file_metadata = {'name': 'report.pdf', 'parents': ['<folder_id>']}
media = MediaFileUpload('report.pdf', mimetype='application/pdf')
file = service.files().create(body=file_metadata, media_body=media, fields='id').execute()
# Download a file
request = service.files().get_media(fileId='<file_id>')
fh = io.FileIO('downloaded.pdf', 'wb')
downloader = MediaIoBaseDownload(fh, request)
done = False
while not done:
status, done = downloader.next_chunk()
# Share a file
service.permissions().create(
fileId='<file_id>',
body={'type': 'user', 'role': 'reader', 'emailAddress': 'user@example.com'},
).execute()
service = build('sheets', 'v4', credentials=credentials)
sheet = service.spreadsheets()
SPREADSHEET_ID = '<your-spreadsheet-id>'
# Read values
result = sheet.values().get(spreadsheetId=SPREADSHEET_ID, range='Sheet1!A1:D10').execute()
rows = result.get('values', [])
# Write values
body = {'values': [['Name', 'Score'], ['Alice', 95], ['Bob', 87]]}
sheet.values().update(
spreadsheetId=SPREADSHEET_ID,
range='Sheet1!A1',
valueInputOption='RAW',
body=body,
).execute()
# Append rows
sheet.values().append(
spreadsheetId=SPREADSHEET_ID,
range='Sheet1!A1',
valueInputOption='USER_ENTERED',
body={'values': [['Charlie', 92]]},
).execute()
service = build('docs', 'v1', credentials=credentials)
# Read document
doc = service.documents().get(documentId='<doc_id>').execute()
title = doc.get('title')
# Extract text from body content
content = doc.get('body', {}).get('content', [])
# Insert text at end of document
requests = [{
'insertText': {
'location': {'index': 1},
'text': 'New paragraph content.\n',
}
}]
service.documents().batchUpdate(
documentId='<doc_id>',
body={'requests': requests},
).execute()
If a Google Workspace MCP server is available, prefer it over direct API calls:
// In Claude Code agent context
mcp__google_workspace__gmail_send({
to: 'user@example.com',
subject: 'Hello',
body: 'Message body',
});
mcp__google_workspace__calendar_create_event({
title: 'Meeting',
start: '2026-03-15T09:00:00Z',
end: '2026-03-15T10:00:00Z',
});
mcp__google_workspace__drive_upload({
name: 'file.pdf',
path: '/local/path/file.pdf',
});
credentials.json from Google Cloud Console; add to .gitignorepip install google-cloud-secret-manager| Service | Scope | Access Level |
|---|---|---|
| Gmail | gmail.readonly | Read-only |
| Gmail | gmail.send | Send only |
| Gmail | gmail.modify | Read/write |
| Calendar | calendar.readonly | Read-only |
| Calendar | calendar | Full access |
| Drive | drive.readonly | Read-only |
| Drive | drive.file | App-created |
| Drive | drive | Full access |
| Sheets | spreadsheets.readonly | Read-only |
| Sheets | spreadsheets | Full access |
| Docs | documents.readonly | Read-only |
| Docs | documents | Full access |
Always use the most restrictive scope that meets your requirements.
还没有评价。欢迎分享你的使用感受。
无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。
还没有评论。来写第一条吧。
Ensure accessibility in UI components including semantic HTML, ARIA attributes, keyboard navigation, and WCAG 2.2 AA compliance.
中文简介正在准备中。当前显示原文说明。
Use when you want to improve response quality through meta-cognitive reasoning. Applies 15+ reasoning methods to reconsider and refine initial outputs.
中文简介正在准备中。当前显示原文说明。
N-round opposing-stance debates for trade-off analysis. Assigns pro/con roles to agents, runs structured debate rounds with quality scoring, and produces a moderator synthesis with confidence-rated recommendation. Generalizable to architecture, technology, security, and design decisions.
中文简介正在准备中。当前显示原文说明。
Force adversarial code review stance that eliminates confirmation bias — reviewer must find issues or re-analyze
中文简介正在准备中。当前显示原文说明。
Creates specialized AI agents on-demand when no existing agent matches a request. Use when the Router cannot find a suitable agent for a task. Enables self-evolution by generating persistent agents.
中文简介正在准备中。当前显示原文说明。
LLM-as-judge evaluation framework with 5-dimension rubric (accuracy, groundedness, coherence, completeness, helpfulness) for scoring AI-generated content quality with weighted composite scores and evidence citations
中文简介正在准备中。当前显示原文说明。