This directory contains code examples for the v4 architecture, which exposes exactly two MCP tools: search and execute. You discover operations via search, then run code via execute using the sdk object.
| Tool | Purpose |
|---|---|
| search | Discover available operations. Call with service and optionally operation to get signatures, params, and examples. |
| execute | Run JavaScript code in a sandbox. The sdk object is available globally. Use sdk.drive.search(), sdk.sheets.addConditionalFormat(), etc. |
Workflow: 1) Call search to find the operation you need. 2) Call execute with code that uses sdk.* to perform the operation.
- Natural Language Search - Basic Drive search via
sdk.drive.search() - Enhanced Search - Advanced filtering via
sdk.drive.enhancedSearch()
- Conditional Formatting - Apply conditional formatting via
sdk.sheets.addConditionalFormat()
Before running these examples, ensure you have:
-
Authenticated with Google Drive:
node ./dist/index.js auth
-
Set up your environment with required variables:
export GDRIVE_TOKEN_ENCRYPTION_KEY="your-base64-key" export REDIS_URL="redis://localhost:6379" # Optional
-
Started the MCP server or configured it with Claude Desktop
Each example follows this structure:
- Overview - What the example demonstrates
- Prerequisites - Required setup and permissions
- Code Examples - Complete, runnable code snippets
- Explanation - Detailed breakdown of the code
- Use Cases - Real-world applications
- Error Handling - Common issues and solutions
- Performance Tips - Optimization recommendations
If the server is configured with Claude Desktop, use the search tool to discover operations, then the execute tool with the example code.
Step 1 — Discover Drive search:
{ "name": "search", "arguments": { "service": "drive", "operation": "search" } }Step 2 — Execute code:
{
"name": "execute",
"arguments": {
"code": "const results = await sdk.drive.search({ query: 'budget', pageSize: 10 }); return results.files.map(f => ({ id: f.id, name: f.name }));"
}
}We welcome additional examples! When contributing:
- Follow the established format with clear explanations
- Use v4 architecture —
searchfor discovery,executewithsdk.*for operations - Include error handling and edge cases
- Test your examples before submitting
- Update this README with your new example
- Main README - Complete server documentation
- Authentication Guide - Setup and security best practices
- Architecture - Server architecture and design
Need help? Open an issue or check the troubleshooting section in the main README.