Public Google Drive — Create and Edit Google Docs/Sheets Hosted on Memyard
Use this skill to create and edit Google Docs and Google Sheets that live in Memyard's workspace. Documents are viewable at https://app.memyard.com/share/<resource_id> (or your configured Memyard base URL). No user OAuth is required. Registration is automatic on first use: when the user first creates or edits a document, register and persist credentials so they never have to fetch a URL or save a key.
Setup / Registration (automatic on first use)
Base URL: https://api.memyard.com — all API paths below are relative to this. Credentials and base URL are persisted in <HOME>/.memyard/agent_config.json, where <HOME> is $HOME on macOS/Linux or %USERPROFILE% on Windows.
Before calling any document endpoint (plan, execute, docs, sheets, etc.), ensure an agent key is available. Do this automatically so the user never has to:
- 1. Check for existing config
If
<HOME>/.memyard/agent_config.json exists and contains
base_url,
agent_id, and
agent_key, use those. Set
Authorization: Bearer <agent_key> for all requests. Skip registration.
- 2. If no config: register and persist
POST <base_url>/v1/drive/register with
{"name": "My Claude Agent"}. Response:
{
"agent_id": "uuid",
"agent_key": "myd_...",
"message": "Store this key securely. It will not be shown again."
}
Ensure
<HOME>/.memyard/ exists and is only accessible by the owner (on macOS/Linux:
chmod 0700; on Windows the default per-user directory permissions are sufficient).
Persist to
<HOME>/.memyard/agent_config.json (on macOS/Linux:
chmod 0600):
{
"base_url": "<base_url>",
"agent_id": "<from response>",
"agent_key": "<from response>"
}
Use the key for all subsequent requests:
Authorization: Bearer <agent_key>.
Available Operations
Write path: Plan then Execute
- 1. POST /v1/drive/plan — Propose what you want to write: doc or sheet, title, intended operation (create / append / insert), and a contentsummary (required for content check). Server returns either approvedplan (with
plan_id and expires_at) or rejectedplan (with reasons and adjusted_constraints). No Drive or DB write happens yet. - POST /v1/drive/execute — Send the
plan_id from an approved plan plus a payload (title, content, columns, rows as needed). Server performs the write and returns the same shape as create/update (resourceid, view_url, etc.). Each plan is one-time use.
This gives the server a choke point for scope, size, content policy, and rate limiting before any Drive API calls.
- - Create Google Doc — via plan (doctype=document, intendedoperation=create) then execute with payload.title and payload.content.
- Create Google Sheet — via plan (doctype=spreadsheet, intendedoperation=create) then execute with payload.title, optional payload.columns and payload.rows.
- Append to Doc — via plan (intendedoperation=append, resourceid required) then execute with payload.content.
- Insert into Doc — via plan (intendedoperation=insert, resourceid required) then execute with payload.content and optional payload.anchor.
- Append rows to Sheet — via plan (intendedoperation=append, resourceid required) then execute with payload.rows.
- Get document metadata — GET /v1/drive/docs/ (read-only; no plan needed).
- List my documents — GET /v1/drive/documents (read-only; no plan needed).
API Reference
All endpoints are relative to <base_url>/v1/drive (see Setup above).
All endpoints except register and discover/<id> require:
INLINECODE26
Register (no auth)
CODEBLOCK2
Plan (propose a write)
CODEBLOCK3
Response — approved (200):
CODEBLOCK4
Response — rejected (200):
CODEBLOCK5
Plans expire after a short TTL (e.g. 10 minutes). Use the plan_id exactly once in execute.
Execute (perform the write)
CODEBLOCK6
For create document: payload.title, payload.content.
For create spreadsheet: payload.title, optional payload.columns, payload.rows.
For append doc: payload.content.
For insert doc: payload.content, optional payload.anchor.
For append sheet: payload.rows (array of rows).
Response (201): Same as create/update endpoints — e.g. { "resource_id", "view_url", "title", ... } or { "resource_id", "char_count", "updated_at" } for append.
Errors: 400 if plan expired or invalid, or payload validation fails; 403 if plan belongs to another agent.
Get document metadata
CODEBLOCK7
List my documents
CODEBLOCK8
Constraints
- - Rate limits: Registration 5/hour per IP; document creates 10/hour per agent; writes 60/hour per agent. Returned as
429 Too Many Requests with Retry-After header. - Size limits: Doc content max 50,000 characters per request; sheet max 1,000 rows per request (tunable via env).
- Permissions: Documents are created with "anyone with link" = reader only. You cannot change sharing via this API.
- Viewing: Share the
view_url (e.g. https://app.memyard.com/share/<resource_id>) for others to view the document in the browser.
Example: Full flow with plan then execute
CODEBLOCK9
Public discover metadata (no auth)
To resolve a public document for embedding (e.g. on the discover page):
CODEBLOCK10
This endpoint does not require authentication.
公共Google Drive — 在Memyard上创建和编辑Google文档/表格
使用此技能创建和编辑位于Memyard工作区中的Google文档和Google表格。文档可通过 https://app.memyard.com/share/(或您配置的Memyard基础URL)查看。无需用户OAuth。首次使用时自动注册:当用户首次创建或编辑文档时,自动注册并持久化凭据,用户无需获取URL或保存密钥。
设置/注册(首次使用时自动完成)
基础URL:https://api.memyard.com — 以下所有API路径均相对于此URL。凭据和基础URL持久化存储在 /.memyard/agent_config.json 中,其中 在macOS/Linux上为 $HOME,在Windows上为 %USERPROFILE%。
在调用任何文档端点(计划、执行、文档、表格等)之前,确保代理密钥可用。自动完成此操作,用户无需手动操作:
- 1. 检查现有配置
如果
/.memyard/agentconfig.json 存在且包含 baseurl、agentid 和 agentkey,则使用这些值。所有请求设置 Authorization: Bearer 。跳过注册。
- 2. 如果没有配置:注册并持久化
POST /v1/drive/register,请求体为 {name: My Claude Agent}。响应:
json
{
agent_id: uuid,
agentkey: myd...,
message: 安全存储此密钥。它将不再显示。
}
确保 /.memyard/ 目录存在且仅所有者可访问(在macOS/Linux上:chmod 0700;在Windows上默认的每用户目录权限即可)。
持久化到 /.memyard/agent_config.json(在macOS/Linux上:chmod 0600):
json
{
baseurl: url>,
agent_id: <来自响应>,
agent_key: <来自响应>
}
使用此密钥进行所有后续请求:Authorization: Bearer 。
可用操作
写入路径:先计划后执行
- 1. POST /v1/drive/plan — 提出您想要写入的内容:文档或表格、标题、预期操作(创建/追加/插入)以及 contentsummary(内容检查必需)。服务器返回 approvedplan(包含 planid 和 expiresat)或 rejectedplan(包含 reasons 和 adjustedconstraints)。此时不进行Drive或数据库写入。
- POST /v1/drive/execute — 发送已批准计划中的 planid 以及 payload(根据需要包含标题、内容、列、行)。服务器执行写入并返回与创建/更新相同格式的结果(resourceid、view_url等)。每个计划仅限一次性使用。
这为服务器在调用任何Drive API之前提供了范围、大小、内容策略和速率限制的检查点。
- - 创建Google文档 — 通过计划(doctype=document,intendedoperation=create),然后使用payload.title和payload.content执行。
- 创建Google表格 — 通过计划(doctype=spreadsheet,intendedoperation=create),然后使用payload.title、可选的payload.columns和payload.rows执行。
- 追加到文档 — 通过计划(intendedoperation=append,需要resourceid),然后使用payload.content执行。
- 插入到文档 — 通过计划(intendedoperation=insert,需要resourceid),然后使用payload.content和可选的payload.anchor执行。
- 追加行到表格 — 通过计划(intendedoperation=append,需要resourceid),然后使用payload.rows执行。
- 获取文档元数据 — GET /v1/drive/docs/(只读;无需计划)。
- 列出我的文档 — GET /v1/drive/documents(只读;无需计划)。
API参考
所有端点均相对于 /v1/drive(参见上面的设置)。
除 register 和 discover/ 外,所有端点均需要:
Authorization: Bearer
注册(无需认证)
bash
POST /v1/drive/register
Content-Type: application/json
{name: My Agent Name}
响应:{ agentid, agentkey, message }
计划(提出写入)
bash
POST /v1/drive/plan
Authorization: Bearer
Content-Type: application/json
{
doc_type: document,
title: My Document,
intended_operation: create,
content_summary: 我将写入内容的简短摘要(例如会议记录)。
}
对于追加/插入还需发送:resource_id:
可选:structure(例如表格的列)
响应 — 已批准(200):
json
{
approved_plan: {
plan_id: <不透明标识>,
expires_at: ,
constraints: { max_chars: 50000 },
doc_type: document,
title: My Document,
intended_operation: create
}
}
响应 — 已拒绝(200):
json
{
rejected_plan: {
reasons: [内容策略:摘要中包含不允许的术语或短语],
adjustedconstraints: { maxchars: 50000, max_rows: 1000 }
}
}
计划在短TTL后过期(例如10分钟)。在execute中仅使用plan_id一次。
执行(执行写入)
bash
POST /v1/drive/execute
Authorization: Bearer
Content-Type: application/json
{
planid: <来自approvedplan>,
payload: {
title: My Document,
content: 此处为初始内容。
}
}
对于创建文档:payload.title,payload.content。
对于创建表格:payload.title,可选的payload.columns,payload.rows。
对于追加文档:payload.content。
对于插入文档:payload.content,可选的payload.anchor。
对于追加表格:payload.rows(行数组)。
响应(201): 与创建/更新端点相同 — 例如 { resourceid, viewurl, title, ... } 或对于追加操作返回 { resourceid, charcount, updated_at }。
错误: 400(计划已过期或无效,或payload验证失败);403(计划属于其他代理)。
获取文档元数据
bash
GET /v1/drive/docs/
Authorization: Bearer
响应:{ resourceid, title, doctype, viewurl, webviewlink, createdat, updated_at }
列出我的文档
bash
GET /v1/drive/documents?limit=50&offset=0
Authorization: Bearer
响应:{ documents: [ { id, title, doctype, webviewlink, createdat, updatedat, viewurl }, ... ] }
约束条件
- - 速率限制:注册每IP每小时5次;文档创建每代理每小时10次;写入每代理每小时60次。返回 429 Too Many Requests 并附带 Retry-After 头部。
- 大小限制:每次请求文档内容最多50,000字符;每次请求表格最多1,000行(可通过环境变量调整)。
- 权限:文档以拥有链接的任何人=仅查看者权限创建。无法通过此API更改共享设置。
- 查看:分享 viewurl(例如 https://app.memyard.com/share/id>)供他人在浏览器中查看文档。
示例:先计划后执行的完整流程
bash
从 /.memyard/agentconfig.json 读取 baseurl 和 agent_key
BASE=/v1/drive
KEY=
2. 提出写入(创建文档)
PLAN=$(curl -s -X POST $BASE/plan \
-H Authorization: Bearer $KEY \
-H Content-Type: application/json \
-d {doctype:document,title:Hello,intendedoperation:create,content_summary:Meeting notes})
3. 如果已批准,使用payload执行
if echo $PLAN | jq -e .approved_plan > /dev/null; then
PLANID=$(echo $PLAN | jq -r .approvedplan