Google Docs
The GoogleDocs molecule provides MCP (Model Context Protocol) tools for creating and displaying Google Docs in the SixDegree discovery service.
- Create Google Docs: Create new Google Documents from text, Markdown, or HTML content
- Display Docs: Embed Google Docs with view/edit controls in widgets
- OAuth Authentication: Uses Google OAuth tokens for secure API access
- Widget Support: Renders embedded Google Doc iframes with interactive controls
- MCP Tools: Exposes Google Docs creation capabilities via the MCP protocol
This molecule is MCP-only - it does not provide entity or relation discovery. It focuses on providing tools for document creation and display through the Model Context Protocol.
-
✅ MCP: Full support for MCP tools (create_doc, show_doc, create_doc_with_markdown)
-
❌ Discovery: Not supported (no entity/relation discovery)
-
✅ Widgets: Display widget for embedding Google Docs
-
Go 1.25+
-
Google Docs and Drive API access
-
OAuth token with required scopes
cd molecules
make dev
Output: ./bin/googledocs
make build
Create a config.yaml file:
mcp:
enabled: true
settings:
oauth_token: "YOUR_GOOGLE_OAUTH_TOKEN_HERE"
-
Via Google OAuth 2.0 Playground (easiest for testing):
- Visit: https://developers.google.com/oauthplayground/
- Select "Google Docs API v1" and "Google Drive API v3"
- Click "Authorize APIs"
- Grant permissions
- Copy the access token from "Step 2" and use it in your config
-
Via your own OAuth flow:
- Configure a Google Cloud project with Docs and Drive APIs enabled
- Implement OAuth 2.0 authentication
- Obtain an access token with required scopes
https://www.googleapis.com/auth/documents # Google Docs API
https://www.googleapis.com/auth/drive.file # Google Drive API (file creation)
Run the molecule as an MCP server:
./bin/googledocs -mcp --config example-config.yaml
The server accepts JSON-RPC 2.0 requests over stdin and outputs responses to stdout.
Create a new Google Doc from content.
Request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "create_doc",
"arguments": {
"title": "My Document",
"content": "Document content here",
"content_type": "text/plain"
}
}
}
Parameters:
title(string, required): Document titlecontent(string, required): Document contentcontent_type(string, optional): "text/plain" (default), "text/markdown", or "text/html"
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"success": true,
"result": {
"created": true,
"doc_id": "1BxiMVs0XRA5nFMwSqWObJJW6IH-QyWsF1479kxQaPAU",
"title": "My Document",
"view_link": "https://docs.google.com/document/d/1BxiMVs0.../view",
"edit_link": "https://docs.google.com/document/d/1BxiMVs0.../edit",
"embed_url": "https://docs.google.com/document/d/1BxiMVs0.../preview?embedded=true&rm=minimal",
"_meta": {
"type": "googledoc-embed",
"data": { ... }
}
}
}
}
Display an embedded Google Doc widget.
Request:
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "show_doc",
"arguments": {
"document_id": "1BxiMVs0XRA5nFMwSqWObJJW6IH-QyWsF1479kxQaPAU",
"title": "My Presentation",
"mode": "view",
"width": "100%",
"height": "600px"
}
}
}
Parameters:
document_id(string, required): Google Doc document IDtitle(string, optional): Display titlemode(string, optional): "view" (default) or "edit"width(string, optional): Widget width (default: "100%")height(string, optional): Widget height (default: "600px")
Response:
{
"jsonrpc": "2.0",
"id": 2,
"result": {
"success": true,
"result": {
"document_id": "1BxiMVs0XRA5nFMwSqWObJJW6IH-QyWsF1479kxQaPAU",
"title": "My Presentation",
"embed_url": "https://docs.google.com/document/d/1BxiMVs0.../preview?embedded=true&rm=minimal",
"view_link": "https://docs.google.com/document/d/1BxiMVs0.../view",
"edit_link": "https://docs.google.com/document/d/1BxiMVs0.../edit",
"mode": "view",
"width": "100%",
"height": "600px",
"_meta": { ... }
}
}
}
Create a Google Doc from Markdown content.
Request:
{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": {
"name": "create_doc_with_markdown",
"arguments": {
"title": "My Markdown Doc",
"markdown_content": "# Heading\n\nSome **bold** text"
}
}
}
Parameters:
title(string, required): Document titlemarkdown_content(string, required): Markdown formatted content
Response: Same format as create_doc
The molecule returns widget data in the _meta field with the following structure:
{
"_meta": {
"type": "googledoc-embed",
"data": {
"document_id": "...",
"title": "...",
"embed_url": "...",
"view_link": "...",
"edit_link": "...",
"mode": "view",
"width": "100%",
"height": "600px"
}
}
}
The dashboard renders this using the JavaScript widget in static/googledoc.js, which:
- Displays an iframe with the embedded Google Doc
- Shows a header with the document title and Google Docs logo
- Provides "View" and "Edit" buttons to open the document
- Supports custom width and height
- initialize: Client initializes the MCP server
- tools/list: Client requests available tools
- tools/call: Client calls a tool with arguments
- Configure: Molecule loads OAuth token from config
- API Call: Molecule calls Google Docs/Drive API
- Return Result: Molecule returns formatted response
- Plain Text: Inserted as-is
- Markdown: Markdown syntax stripped, text inserted
- HTML: HTML tags removed, text inserted
Tokens are provided via MCP config and stored in memory. The molecule creates an OAuth HTTP client that automatically includes the token in API requests.
Common errors and their meanings:
-
"oauth_token is required": OAuth token not provided in config
-
"molecule not configured": Configure() hasn't been called yet
-
"failed to create file": Drive API error (quota, permissions, etc.)
-
"failed to update document": Docs API error
-
✅ OAuth tokens are treated as secrets (marked with
x-sixdegree: {widget: secret}) -
✅ No tokens are logged to stdout/stderr
-
✅ All API communication uses HTTPS
-
✅ OAuth tokens should have minimal scopes (documents, drive.file only)
-
main.go: Main molecule implementation -
molecule.yaml: Metadata and capability definitions -
example-config.yaml: Example configuration -
static/googledoc.js: Widget JavaScript renderer -
README.md: This file
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}
{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}' | ./bin/googledocs -mcp
echo '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"show_doc","arguments":{"document_id":"1BxiMVs0XRA5nFMwSqWObJJW6IH-QyWsF1479kxQaPAU"}}}' | ./bin/googledocs -mcp --config example-config.yaml
-
Markdown/HTML conversion is basic (simple text extraction)
-
No support for complex document formatting
-
No caching of document metadata
-
No incremental updates to existing documents
-
Full Markdown to Google Docs formatting conversion
-
Support for images and attachments
-
Batch document operations
-
Document sharing and permissions
-
Comments and revision history
-
Discovery of existing Drive documents (optional)
-
Advanced caching strategies
MIT - See LICENSE file in molecules directory