auth-preflight
Skill304 starsChanged 2 months agoMITView on GitHub
Verify Google Workspace MCP authentication at the start of any session that needs Google APIs (Docs, Slides, Drive). This skill prevents auth failures mid-workflow by testing credentials upfront. Use this skill automatically at session start when the task involves Google Docs, Google Slides, Drive uploads, or any MCP Google Workspace tool. Also trigger when users mention "Google Doc", "Google Slides", "upload to Drive", "export to Google", "share on Drive", or any Google-related output format. Apply before running any Google Workspace agents (google-slides-creator, google-slides-reviewer) or calling any mcp__google-* tool. This skill detects the actual MCP configuration, checks stored credentials in all known locations, tests tokens with a lightweight API call using create operations instead of reads, handles re-authentication if needed, and reports auth status clearly so downstream work can proceed safely or fail fast with actionable guidance.
- Reads credentials
In this repository65 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- always-compareSkill
- analysis-designSkill
- analyst-coreSkill
- archaeologySkill
- archive-analysisSkill
- businessSkill
- causalSkill
- chart-to-driveSkill
- close-the-loopSkill
- codex-reviewSkill
- compare-datasetsSkill
- connect-dataSkill
- connect-snowflakeSkill
- context-compareSkill
- context-traceSkill
- data-inspectSkill
- data-mapSkill
- data-profilingSkill
- data-quality-checkSkill
- datasetsSkill
- distribution-profilerSkill
- evalSkill
- evaluate-graderSkill
- experiment-briefSkill
- experimentSkill
- exploreSkill
- exportSkill
- forecastSkill
- google-doc-exportSkill
- google-slides-exportSkill
- guardrailsSkill
- historySkill
- improve-contextSkill
- knowledge-bootstrapSkill
- log-correctionSkill
- maintain-contextSkill
- metric-specSkill
- metricsSkill
- monitor-evalsSkill
- notion-exportSkill
- paceSkill
- patternsSkill
- question-framingSkill
- question-routerSkill
- reliabilitySkill
- resume-pipelineSkill
- run-pipelineSkill
- runsSkill
- score-analysisSkill
- session-handoffSkill
- setup-dev-contextSkill
- setup-notionSkill
- setupSkill
- setup-slackSkill
- setup-snowflakeSkill
- srm-checkSkill
- stakeholder-communicationSkill
- stress-testSkill
- switch-datasetSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
16 rules. About 0 are common, 12 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈12
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 10
Verify Google Workspace MCP authentication BEFORE beginning any Google-dependent work.
- Distinctive: line 20
Before running google-slides-creator, google-slides-reviewer, gdoc-builder, or any Google-dependent agent
- Distinctive: line 22
Critical timing: Run auth preflight as your FIRST action, before exploring data, generating charts, parsing narratives, or any other …
- Very specific: line 30
Read .mcp.json to discover which Google MCP server(s) are configured:
- Distinctive: line 36
Look for entries like:
- Very specific: line 89
Check token expiry if readable: cat {token_path} | grep expiry
- Very specific: line 117
Critical: Use the EXACT email string from the credential filename.
- Distinctive: line 145
If credentials missing or token invalid, guide user through re-authentication.
- Distinctive: line 173
Select your Google account: when prompted
- Distinctive: line 178
Add your email address
- Distinctive: line 192
After user confirms auth completed, repeat Step 3 (create test document/presentation).
- Distinctive: line 234
If you created a test document/presentation in Step 3 and it's still accessible, optionally clean it up:
- Distinctive: line 261
General troubleshooting principle: When in doubt, restart Claude Code.
- Very specific: line 287
Adaptation rule: Always detect actual config from .mcp.json and ls results rather than assuming a specific pattern.
- Distinctive: line 295
Extract email from credential filename for workspace-mcp: Don't ask the user for their email.
- Distinctive: line 297
One auth attempt, then clear explanation: If re-auth fails, provide diagnostics and actionable next steps.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Skill: Auth Preflight
Purpose
Verify Google Workspace MCP authentication BEFORE beginning any Google-dependent work. Catches auth issues in <30 seconds instead of discovering them after 5-10 minutes of chart generation, narrative writing, or deck building.
Core principle: Fail fast with clear guidance, not slow with cryptic errors mid-workflow.
When to Apply
Trigger this skill immediately when:
- The task involves Google Docs, Slides, or Drive
- Any
mcp__google-*tool will be called - The user mentions "Google Doc", "Google Slides", "upload to Drive", "create a deck", "export to Google", "share on Drive"
- Before running google-slides-creator, google-slides-reviewer, gdoc-builder, or any Google-dependent agent
Critical timing: Run auth preflight as your FIRST action, before exploring data, generating charts, parsing narratives, or any other substantive work.
Preflight Workflow
Step 1: Detect MCP Configuration
Read .mcp.json to discover which Google MCP server(s) are configured:
cat .mcp.json | grep -A3 googleLook for entries like:
google-docs→ Google Docs + Drive MCP server (most common)google-workspace→ Full workspace MCP (Docs, Slides, Drive)google-slides→ Slides-specific MCP server
Extract:
- Server name (JSON key, e.g., "google-docs")
- Command path (where the executable lives)
- Args (to identify server type)
Why this matters: Different MCP implementations store credentials in different locations. Detecting configuration first ensures you check the right paths.
If no Google MCP found: Report:
Auth: FAILED — No Google MCP server configured in .mcp.json
To use Google Docs/Slides, add a Google MCP server to .mcp.jsonStep 2: Check Stored Credentials
Based on MCP type from Step 1, check credentials in ALL possible locations (some setups use non-standard paths):
Priority 1: MCP-specific locations
# For google-docs MCP
ls ~/.claude/mcp-servers/google-docs-mcp-server/
# For google-workspace MCP
ls ~/.google_workspace_mcp/credentials/
# For google-slides MCP
ls ~/.claude/mcp-servers/google-slides-mcp-server/Priority 2: Alternative locations (check if Priority 1 empty)
# Some custom MCP installs use these
ls ~/.config/google-docs-mcp-server/
ls ~/.google_mcp/credentials/Look for:
token.json(current access/refresh token)credentials.json(OAuth client credentials)- For workspace-mcp:
{email}.jsonfiles
If no credentials found anywhere:
- Auth has never been completed
- Skip to Step 4 (Re-authenticate)
If credentials found:
- For workspace-mcp: Extract email from filename (e.g.,
user@gmail.com.json→ use exactlyuser@gmail.comin all API calls) - For other servers: Note the token.json location for diagnostics
- Check token expiry if readable:
cat {token_path} | grep expiry - Proceed to Step 3
Step 3: Test with Lightweight API Call
Make a simple API call to verify the token works. Always use CREATE operations, not READ operations to avoid permission errors on specific documents.
Best practice: Use create operations
Why create, not read? Reading a specific document can fail with 403 "Permission denied" even when auth is valid (if that doc isn't shared with the user). Creating a new document only requires valid auth, not document-specific permissions.
Test calls by MCP type:
If google-docs MCP:
mcp__google-docs__create_document(title="Auth Preflight Test - Delete Me")- Success → Extract document_id, report "Auth: OK (google-docs)", optionally clean up test doc
- Auth error (401/403) → Proceed to Step 4
- Tool not found → Report ".mcp.json has google-docs but tools not available - restart Claude Code"
If google-workspace MCP:
mcp__google-workspace__create_doc(
user_google_email="{email_from_credentials_filename}",
title="Auth Preflight Test"
)Critical: Use the EXACT email string from the credential filename. Gmail treats dots as equivalent (a.b@gmail.com = ab@gmail.com) but MCP stores tokens by exact string match.
If google-slides MCP:
mcp__google-slides__create_presentation(title="Auth Preflight Test")Interpreting results:
| Result | Meaning | Action |
| Success (doc/presentation created) | Auth is valid | Report "Auth: OK", clean up test resource, proceed |
| 401 Unauthorized | Token expired/invalid | Proceed to Step 4 (re-auth) |
| 403 Forbidden (when creating) | Quota exceeded or API disabled | Report API configuration issue |
| "Tool not found" | MCP not loaded | Recommend restarting Claude Code |
| "Address already in use" | OAuth server already running | Try actual API call (ignore this error) |
If successful:
Auth: OK ({server_type})
Token verified via create_document at {timestamp}
Ready to proceed with Google API operationsIf auth error: Proceed to Step 4.
Step 4: Re-authenticate
If credentials missing or token invalid, guide user through re-authentication.
Invoke appropriate auth tool:
For google-docs MCP:
mcp__google-docs__authorize_google_docs()For google-workspace MCP:
mcp__google-workspace__authorize()For google-slides MCP:
mcp__google-slides__authorize()Present these instructions:
When authorization URL appears:
- Copy-paste the URL into your browser
- Do NOT cmd-click or ctrl-click the URL in the terminal
- Terminal click handlers can append garbage characters that break the URL
- Manually select, copy (Cmd+C), and paste into browser
- Select your Google account when prompted
- If you see "Access blocked: This app isn't verified":
- Go to console.cloud.google.com → APIs & Services → OAuth consent screen
- Scroll to "Test users" section → Click "Add Users"
- Add your email address
- Return to the auth URL and try again
- The app will now recognize you as an authorized test user
- If authorization fails with "Address already in use":
- This means the MCP server is already running (normal state)
- The issue is that no auth URL is being displayed
- Solution: Restart Claude Code completely
- The MCP server will restart and display the auth URL on startup
- After you see "Authentication successful" in browser, tell me "done" and I'll verify
Step 5: Verify After Re-auth
After user confirms auth completed, repeat Step 3 (create test document/presentation).
If successful:
Auth: OK ({server_type})
Re-authentication successful
Proceeding with {original_task}If still failing: Check diagnostics:
# Verify new credentials appeared
ls ~/.claude/mcp-servers/google-docs-mcp-server/
# Check if token was actually written
ls -lh ~/.claude/mcp-servers/google-docs-mcp-server/token.json
# If token is 0 bytes or very old (unchanged timestamp), auth didn't completeIf credentials still missing/invalid:
Auth: FAILED — Re-authentication did not create valid credentials
Diagnostic findings:
- Credential location: {path_checked}
- Token file: {exists/missing}
- Token size: {bytes} (should be >200 bytes)
- Last modified: {timestamp}
Recommended action:
1. Restart Claude Code (closes all MCP servers cleanly)
2. Check for auth URL in Claude Code startup logs
3. Complete OAuth flow in browser
4. Verify you added your email as a test user in Google Cloud Console
5. If still failing, check Google Cloud Console → APIs & Services → Enabled APIs
- Required: Google Docs API, Google Drive API (and Google Slides API if needed)Step 6: Cleanup Test Resources (Optional)
If you created a test document/presentation in Step 3 and it's still accessible, optionally clean it up:
# For test documents
mcp__google-docs__delete_document(document_id="{test_doc_id}")
# (if delete tool exists)
# Or just leave it - user can delete manually from DriveThis is non-critical; the test resource causes no harm.
Known Issues & Solutions
| Issue | Symptom | Root Cause | Fix |
| Email mismatch (workspace-mcp) | Auth succeeds but all API calls fail with "Invalid grant" | Email parameter doesn't match credential filename exactly | Extract email from credential filename, use exact string (including/excluding dots) |
| Token expired | "Authentication needed" on every call | Token hasn't been refreshed, or refresh token invalid | Re-auth via Step 4 |
| App not verified | "Access blocked" screen after selecting Google account | User not added as test user for OAuth app | Add user's email in Google Cloud Console → OAuth consent screen → Test users |
| URL corruption | Auth URL gives 400 error | Terminal cmd-click appended control characters | Copy-paste URL manually, don't click |
| MCP server not found | "Tool not found" errors on all MCP calls | Server didn't start with Claude Code session | Restart Claude Code (MCP servers auto-start) |
| Port conflict | "Address already in use" during authorize() | OAuth callback server already bound to port | Restart Claude Code to reset server state |
| Stale token in memory | Credentials valid on disk but API calls fail | MCP server has cached invalid token | Restart Claude Code to reload credentials from disk |
| Credentials in wrong location | Token.json exists but skill can't find it | Custom MCP installation path | Check .mcp.json command/args to infer storage location |
General troubleshooting principle: When in doubt, restart Claude Code. This cleanly reloads all MCP servers with fresh credentials from disk.
Implementation Patterns by MCP Type
Pattern A: google-workspace MCP (workspace-mcp package)
- Credentials:
~/.google_workspace_mcp/credentials/{email}.json - Email required: Yes — passed to every API call as
user_google_emailparameter - Email format: EXACT string from filename (e.g.,
john.doe@gmail.com≠johndoe@gmail.com) - Test call:
create_doc()with email + title - Re-auth:
mcp__google-workspace__authorize()
Pattern B: google-docs MCP (custom Python server)
- Credentials:
~/.claude/mcp-servers/google-docs-mcp-server/token.json - Email required: No — token is user-agnostic
- Test call:
create_document(title="...")— no email param - Re-auth:
mcp__google-docs__authorize_google_docs() - Token contents: JSON with
token,refresh_token,expiry,scopes
Pattern C: google-slides MCP
- Credentials:
~/.claude/mcp-servers/google-slides-mcp-server/token.json - Email required: No
- Test call:
create_presentation(title="...") - Re-auth:
mcp__google-slides__authorize()
Adaptation rule: Always detect actual config from .mcp.json and ls results rather than assuming a specific pattern. Support all three patterns in the same skill.
Rules
- Always use CREATE for test calls, never READ. Creating a resource only requires valid auth. Reading requires auth + permissions on that specific resource.
- Extract email from credential filename for workspace-mcp. Don't ask the user for their email. The exact string in the filename is what must be passed to API calls.
- One auth attempt, then clear explanation. If re-auth fails, provide diagnostics and actionable next steps. Don't retry repeatedly.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

