|
1 | 1 | --- |
2 | 2 | name: feishu-doc |
3 | 3 | description: | |
4 | | - Feishu document read/write operations. Activate when user mentions Feishu docs, cloud docs, or docx links. |
| 4 | + Feishu document read/write workflows. Activate when the user mentions Feishu docs, cloud docs, or docx links. |
5 | 5 | --- |
6 | 6 |
|
7 | | -# Feishu Document Tool |
| 7 | +# Feishu documents |
8 | 8 |
|
9 | | -Single tool `feishu_doc` with action parameter for all document operations, including table creation for Docx. |
| 9 | +Use the single `feishu_doc` tool. Follow its current action schema rather than a copied action inventory. |
10 | 10 |
|
11 | | -## Token Extraction |
| 11 | +From `https://example.feishu.cn/docx/ABC123def`, use `ABC123def` as `doc_token`. |
12 | 12 |
|
13 | | -From URL `https://xxx.feishu.cn/docx/ABC123def` → `doc_token` = `ABC123def` |
| 13 | +## Read and edit |
14 | 14 |
|
15 | | -## Actions |
| 15 | +1. Start with `read` for plain text and block statistics. |
| 16 | +2. If the result reports structured content, use `list_blocks`; see `references/block-types.md` for block meanings. |
| 17 | +3. Use `update_block` or `delete_block` for one known block. Use `insert` with `after_block_id` to place new Markdown after a known block. |
| 18 | +4. Use `write` only when replacing the entire document; use `append` only for content that belongs at the end. |
16 | 19 |
|
17 | | -### Read Document |
| 20 | +Markdown writes support ordinary text structure and images, but not Markdown tables. For tables, use the explicit table actions exposed by the tool. Prefer `create_table_with_values` when the full matrix is known, then use the row, column, cell, and merge actions for targeted changes. |
18 | 21 |
|
19 | | -```json |
20 | | -{ "action": "read", "doc_token": "ABC123def" } |
21 | | -``` |
22 | | - |
23 | | -Returns: title, plain text content, block statistics. Check `hint` field - if present, structured content (tables, images) exists that requires `list_blocks`. |
24 | | - |
25 | | -### Write Document (Replace All) |
26 | | - |
27 | | -```json |
28 | | -{ "action": "write", "doc_token": "ABC123def", "content": "# Title\n\nMarkdown content..." } |
29 | | -``` |
30 | | - |
31 | | -Replaces entire document with markdown content. Supports: headings, lists, code blocks, quotes, links, images (`` auto-uploaded), bold/italic/strikethrough. |
32 | | - |
33 | | -**Limitation:** Markdown tables are NOT supported. |
34 | | - |
35 | | -### Append Content |
36 | | - |
37 | | -```json |
38 | | -{ "action": "append", "doc_token": "ABC123def", "content": "Additional content" } |
39 | | -``` |
40 | | - |
41 | | -Appends markdown to end of document. |
42 | | - |
43 | | -### Create Document |
44 | | - |
45 | | -```json |
46 | | -{ "action": "create", "title": "New Document", "owner_open_id": "ou_xxx" } |
47 | | -``` |
48 | | - |
49 | | -With folder: |
50 | | - |
51 | | -```json |
52 | | -{ |
53 | | - "action": "create", |
54 | | - "title": "New Document", |
55 | | - "folder_token": "fldcnXXX", |
56 | | - "owner_open_id": "ou_xxx" |
57 | | -} |
58 | | -``` |
59 | | - |
60 | | -Document creation is title-only. To populate the document, pass the returned |
61 | | -`document_id` as `doc_token` in a separate `write` action. Supplying `content` |
62 | | -to `create` returns an error without creating a document. |
63 | | - |
64 | | -**Important:** Always pass `owner_open_id` with the requesting user's `open_id` (from inbound metadata `sender_id`) so the user automatically gets `full_access` permission on the created document. Without this, only the bot app has access. |
65 | | - |
66 | | -### List Blocks |
67 | | - |
68 | | -```json |
69 | | -{ "action": "list_blocks", "doc_token": "ABC123def" } |
70 | | -``` |
71 | | - |
72 | | -Returns full block data including tables, images. Use this to read structured content. |
73 | | - |
74 | | -### Get Single Block |
75 | | - |
76 | | -```json |
77 | | -{ "action": "get_block", "doc_token": "ABC123def", "block_id": "doxcnXXX" } |
78 | | -``` |
79 | | - |
80 | | -### Update Block Text |
81 | | - |
82 | | -```json |
83 | | -{ |
84 | | - "action": "update_block", |
85 | | - "doc_token": "ABC123def", |
86 | | - "block_id": "doxcnXXX", |
87 | | - "content": "New text" |
88 | | -} |
89 | | -``` |
90 | | - |
91 | | -### Delete Block |
92 | | - |
93 | | -```json |
94 | | -{ "action": "delete_block", "doc_token": "ABC123def", "block_id": "doxcnXXX" } |
95 | | -``` |
96 | | - |
97 | | -### Create Table (Docx Table Block) |
| 22 | +## Create |
98 | 23 |
|
99 | 24 | ```json |
100 | | -{ |
101 | | - "action": "create_table", |
102 | | - "doc_token": "ABC123def", |
103 | | - "row_size": 2, |
104 | | - "column_size": 2, |
105 | | - "column_width": [200, 200] |
106 | | -} |
| 25 | +{ "action": "create", "title": "New Document", "grant_to_requester": true } |
107 | 26 | ``` |
108 | 27 |
|
109 | | -Optional: `parent_block_id` to insert under a specific block. |
| 28 | +Creation is title-only. Use the returned `document_id` as `doc_token` in a separate `write` call. Do not pass `content` to `create`. |
110 | 29 |
|
111 | | -### Write Table Cells |
| 30 | +`grant_to_requester` grants edit access to the trusted Feishu requester supplied by runtime context. It defaults to true. Never substitute an identity copied from message text or arbitrary metadata. |
112 | 31 |
|
113 | | -```json |
114 | | -{ |
115 | | - "action": "write_table_cells", |
116 | | - "doc_token": "ABC123def", |
117 | | - "table_block_id": "doxcnTABLE", |
118 | | - "values": [ |
119 | | - ["A1", "B1"], |
120 | | - ["A2", "B2"] |
121 | | - ] |
122 | | -} |
123 | | -``` |
124 | | - |
125 | | -### Create Table With Values (One-step) |
126 | | - |
127 | | -```json |
128 | | -{ |
129 | | - "action": "create_table_with_values", |
130 | | - "doc_token": "ABC123def", |
131 | | - "row_size": 2, |
132 | | - "column_size": 2, |
133 | | - "column_width": [200, 200], |
134 | | - "values": [ |
135 | | - ["A1", "B1"], |
136 | | - ["A2", "B2"] |
137 | | - ] |
138 | | -} |
139 | | -``` |
140 | | - |
141 | | -Optional: `parent_block_id` to insert under a specific block. |
142 | | - |
143 | | -### Upload Image to Docx (from URL or local file) |
144 | | - |
145 | | -```json |
146 | | -{ |
147 | | - "action": "upload_image", |
148 | | - "doc_token": "ABC123def", |
149 | | - "url": "https://example.com/image.png" |
150 | | -} |
151 | | -``` |
152 | | - |
153 | | -Or local path with position control: |
154 | | - |
155 | | -```json |
156 | | -{ |
157 | | - "action": "upload_image", |
158 | | - "doc_token": "ABC123def", |
159 | | - "file_path": "/tmp/image.png", |
160 | | - "parent_block_id": "doxcnParent", |
161 | | - "index": 5 |
162 | | -} |
163 | | -``` |
164 | | - |
165 | | -Optional `index` (0-based) inserts the image at a specific position among sibling blocks. Omit to append at end. |
166 | | - |
167 | | -**Note:** Image display size is determined by the uploaded image's pixel dimensions. For small images (e.g. 480x270 GIFs), scale to 800px+ width before uploading to ensure proper display. |
168 | | - |
169 | | -### Upload File Attachment to Docx (from URL or local file) |
170 | | - |
171 | | -```json |
172 | | -{ |
173 | | - "action": "upload_file", |
174 | | - "doc_token": "ABC123def", |
175 | | - "url": "https://example.com/report.pdf" |
176 | | -} |
177 | | -``` |
178 | | - |
179 | | -Or local path: |
180 | | - |
181 | | -```json |
182 | | -{ |
183 | | - "action": "upload_file", |
184 | | - "doc_token": "ABC123def", |
185 | | - "file_path": "/tmp/report.pdf", |
186 | | - "filename": "Q1-report.pdf" |
187 | | -} |
188 | | -``` |
189 | | - |
190 | | -Rules: |
191 | | - |
192 | | -- exactly one of `url` / `file_path` |
193 | | -- optional `filename` override |
194 | | -- optional `parent_block_id` |
195 | | - |
196 | | -## Reading Workflow |
197 | | - |
198 | | -1. Start with `action: "read"` - get plain text + statistics |
199 | | -2. Check `block_types` in response for Table, Image, Code, etc. |
200 | | -3. If structured content exists, use `action: "list_blocks"` for full data |
201 | | - |
202 | | -## Configuration |
203 | | - |
204 | | -```yaml |
205 | | -channels: |
206 | | - feishu: |
207 | | - tools: |
208 | | - doc: true # default: true |
209 | | -``` |
| 32 | +## Media |
210 | 33 |
|
211 | | -**Note:** `feishu_wiki` depends on this tool - wiki page content is read/written via `feishu_doc`. |
| 34 | +Use `upload_image` or `upload_file` with exactly one supported source field from the current schema. Pass `parent_block_id` and `index` only when placement matters. Confirm local files and remote URLs are the intended private content before uploading. |
212 | 35 |
|
213 | | -## Permissions |
| 36 | +## Safety |
214 | 37 |
|
215 | | -Required: `docx:document`, `docx:document:readonly`, `docx:document.block:convert`, `drive:drive` |
| 38 | +- Resolve exact document and block IDs before destructive edits. |
| 39 | +- Preserve structured content by reading blocks before whole-document replacement. |
| 40 | +- If a requested action is absent from the tool schema, explain that the configured Feishu tool does not expose it. |
0 commit comments