feishu-integration

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

飞书集成技能

Feishu Integration Skill

飞书(Feishu/Lark)API 集成和自动化综合指南。
Comprehensive guide for Feishu (Lark) API integration and automation.

🚀 工作方式

🚀 How It Works

本项目提供两种使用方式
This project provides two usage methods:

方式一:MCP 工具(推荐)⚡

Option 1: MCP Tool (Recommended) ⚡

实时交互,无需手动运行脚本
用户请求 → MCP 工具调用 → 飞书 API → 返回结果
通过
mcp__feishu__*
工具直接操作飞书 API。
优势
  • ✅ 实时交互式操作
  • ✅ 无需切换终端
  • ✅ 自动处理认证
  • ✅ 支持链式操作
Real-time interaction, no need to manually run scripts
User Request → MCP Tool Call → Feishu API → Return Result
Directly operate Feishu API via
mcp__feishu__*
tools.
Advantages:
  • ✅ Real-time interactive operations
  • ✅ No need to switch terminals
  • ✅ Automatic authentication handling
  • ✅ Supports chained operations

方式二:Python 脚本 📜

Option 2: Python Script 📜

适合复杂批量操作和自动化流程。

Suitable for complex batch operations and automated workflows.

🔧 MCP 工具列表

🔧 MCP Tool List

认证与连接

Authentication & Connection

工具功能使用场景
mcp__feishu__get_tenant_access_token
获取访问令牌验证连接状态
ToolFunctionUse Case
mcp__feishu__get_tenant_access_token
Obtain access tokenVerify connection status

多维表格管理

Base Table Management

工具功能参数
mcp__feishu__create_bitable
创建多维表格
name
: 表格名称<br>
folder_token
: 文件夹(可选)
mcp__feishu__get_tables
获取数据表列表
app_token
: 应用token
mcp__feishu__add_table_field
添加字段
app_token
,
table_id
,
field_name
,
field_type
ToolFunctionParameters
mcp__feishu__create_bitable
Create base table
name
: Table name<br>
folder_token
: Folder (optional)
mcp__feishu__get_tables
Get data table list
app_token
: App token
mcp__feishu__add_table_field
Add field
app_token
,
table_id
,
field_name
,
field_type

数据操作

Data Operations

工具功能参数
mcp__feishu__add_record
添加记录
app_token
,
table_id
,
fields
(dict)
mcp__feishu__get_records
获取记录
app_token
,
table_id
,
page_size
(默认20)
ToolFunctionParameters
mcp__feishu__add_record
Add record
app_token
,
table_id
,
fields
(dict)
mcp__feishu__get_records
Get records
app_token
,
table_id
,
page_size
(default 20)

权限管理

Permission Management

工具功能参数
mcp__feishu__add_collaborator
添加协作者
app_token
,
member_type
,
member_id
,
perm_type
mcp__feishu__get_user_by_email
通过邮箱查找用户
email
: 用户邮箱
ToolFunctionParameters
mcp__feishu__add_collaborator
Add collaborator
app_token
,
member_type
,
member_id
,
perm_type
mcp__feishu__get_user_by_email
Find user by email
email
: User email

资源

Resources

资源 URI功能
feishu://config
获取当前配置信息

Resource URIFunction
feishu://config
Get current configuration information

💡 典型使用场景

💡 Typical Use Scenarios

场景 1: 创建不同类型多维表格

Scenario 1: Create Different Types of Base Tables

你是一个多维表格创建专家,需要按照以下步骤完成任务:
用户请求示例:
- "创建一个客户管理系统"
- "帮我做一个项目任务管理表"
- "建立一个库存管理表格"

助手执行流程:

1. 分析用户需求,设计合理的表格结构
   - 识别业务类型(CRM/项目管理/库存/销售等)
   - 确定核心实体和属性
   - 设计字段关系和数据流

2. 调用 create_bitable 创建多维表格

3. 获取返回的 app_token

4. 调用 get_tables(app_token) 获取 table_id

5. 调用 add_table_field() 添加字段:[根据需求动态生成]
   - 主表:核心业务字段
   - 字段类型选择(文本/数字/日期/单选/多选/人员等)
   - 必填字段和默认值设置

6. 设置字段类型、选项、验证规则
   - 单选字段:配置选项列表
   - 数字字段:设置范围限制
   - 日期字段:配置时间格式
   - 关联字段:建立表间关系

7. 添加示例数据

8. 添加用户为协作者

9. 创建关联表(如需要)
   - 子表设计(如订单明细、任务评论)
   - 表间关联配置
   - 数据关系说明
示例:创建客户管理系统
用户: 创建一个客户管理系统

助手执行:

1. 分析需求
   - 业务类型:CRM 客户管理
   - 核心实体:客户、跟进记录
   - 数据流:客户信息 → 跟进互动 → 成交转化

2. 调用 create_bitable(name="客户管理系统")

3. 获取返回的 app_token(例如:app_xxxxxxxxx)

4. 调用 get_tables(app_token) 获取 table_id(例如:tblxxxxxxxx)

5. 调用 add_table_field() 添加字段:
   - 客户名称(field_name="客户名称", field_type=1)文本
   - 联系人姓名(field_name="联系人姓名", field_type=1)文本
   - 联系电话(field_name="联系电话", field_type=11)电话
   - 客户来源(field_name="客户来源", field_type=3)单选
   - 客户阶段(field_name="客户阶段", field_type=3)单选
   - 所属行业(field_name="所属行业", field_type=3)单选
   - 预估成交金额(field_name="预估成交金额", field_type=2)数字
   - 创建时间(field_name="创建时间", field_type=5)日期
   - 备注(field_name="备注", field_type=1)文本

6. 设置字段配置
   - 客户来源选项:网络推广/客户介绍/展会/主动开发
   - 客户阶段选项:潜在客户/意向客户/谈判中/已成交/已流失
   - 所属行业选项:互联网/金融/制造/零售/其他
   - 预估金额:设置最小值为0

7. 添加示例数据
   调用 add_record(app_token, table_id, {
     "客户名称": "示例科技公司",
     "联系人姓名": "张三",
     "联系电话": "13800138000",
     "客户来源": "网络推广",
     "客户阶段": "意向客户",
     "所属行业": "互联网",
     "预估成交金额": 50000,
     "创建时间": 1704067200000,
     "备注": "潜在优质客户"
   })

8. 添加用户为协作者
   调用 get_user_by_email(email="user@example.com") 获取 open_id
   调用 add_collaborator(app_token, "user", open_id, "edit")

9. 创建关联表"跟进记录"
   重复步骤 4-5,创建跟进记录表,包含:
   - 跟进时间(field_type=5)
   - 跟进方式(field_type=3,选项:电话/微信/邮件/面谈)
   - 跟进内容(field_type=1)
   - 下次跟进时间(field_type=5)
   - 客户名称(关联字段,关联到客户信息表)

10. 返回结果
   - 表格链接:https://feishu.cn/base/{app_token}
   - 字段说明文档
   - 使用建议
示例:创建项目任务管理表
用户: 创建一个项目任务管理表

助手执行:

1. 分析需求
   - 业务类型:项目管理
   - 核心实体:项目、任务
   - 数据流:项目分解 → 任务分配 → 执行跟踪

2. 调用 create_bitable(name="项目任务管理系统")

3. 获取返回的 app_token

4. 调用 get_tables(app_token) 获取 table_id

5. 调用 add_table_field() 为"项目列表"表添加字段:
   - 项目名称(field_name="项目名称", field_type=1)
   - 项目编号(field_name="项目编号", field_type=1)
   - 项目状态(field_name="项目状态", field_type=3)选项:未开始/进行中/已完成/已延期
   - 开始日期(field_name="开始日期", field_type=5)
   - 结束日期(field_name="结束日期", field_type=5)
   - 项目优先级(field_name="项目优先级", field_type=3)选项:高/中/低
   - 项目进度(field_name="项目进度", field_type=15)0-100%
   - 项目经理(field_name="项目经理", field_type=1)

6. 添加示例数据
   调用 add_record() 添加 2-3 个示例项目

7. 添加用户为协作者

8. 创建"任务列表"关联表
   - 任务名称(field_type=1)
   - 所属项目(关联字段 → 项目列表)
   - 任务负责人(field_type=1)
   - 任务状态(field_type=3)选项:待办/进行中/已完成/已取消
   - 任务优先级(field_type=3)选项:紧急/高/中/低
   - 开始时间(field_type=5)
   - 截止时间(field_type=5)
   - 预计工时(field_type=2)
   - 实际工时(field_type=2)
   - 任务描述(field_type=1)

9. 返回双表结构说明、关联关系图、使用建议
示例:创建采购订单管理系统
用户: 创建一个采购订单管理系统

助手执行:

1. 分析需求
   - 业务类型:采购管理
   - 核心实体:采购订单
   - 数据流:订单创建 → 审批 → 执行

2. 调用 create_bitable(name="采购订单管理系统")

3. 获取返回的 app_token

4. 调用 get_tables(app_token) 获取 table_id

5. 调用 add_table_field() 添加字段:
   - 采购订单(field_name="采购订单", field_type=1)
   - 采购单价(field_name="采购单价", field_type=2)
   - 采购数量(field_name="采购数量", field_type=2)
   - 采购金额(field_name="采购金额", field_type=2)
   - 采购时间(field_name="采购时间", field_type=5)
   - 采购人(field_name="采购人", field_type=1)

6. 添加示例数据
7. 添加用户为协作者
8. 返回表格链接和使用说明
You are a base table creation expert, follow these steps to complete the task:
User Request Examples:
- "Create a customer management system"
- "Help me make a project task management table"
- "Build an inventory management table"

Assistant Execution Process:

1. Analyze user requirements and design a reasonable table structure
   - Identify business type (CRM/project management/inventory/sales, etc.)
   - Determine core entities and attributes
   - Design field relationships and data flows

2. Call create_bitable to create the base table

3. Obtain the returned app_token

4. Call get_tables(app_token) to get table_id

5. Call add_table_field() to add fields: [Dynamically generated based on requirements]
   - Main table: Core business fields
   - Select field types (text/number/date/single-select/multi-select/people, etc.)
   - Set required fields and default values

6. Set field types, options, and validation rules
   - Single-select fields: Configure option lists
   - Number fields: Set range limits
   - Date fields: Configure time formats
   - Associated fields: Establish inter-table relationships

7. Add sample data

8. Add users as collaborators

9. Create associated tables (if needed)
   - Sub-table design (e.g., order details, task comments)
   - Inter-table association configuration
   - Data relationship description
Example: Create a Customer Management System
User: Create a customer management system

Assistant Execution:

1. Requirement Analysis
   - Business Type: CRM Customer Management
   - Core Entities: Customers, Follow-up Records
   - Data Flow: Customer Information → Follow-up Interaction → Conversion

2. Call create_bitable(name="Customer Management System")

3. Obtain the returned app_token (e.g.: app_xxxxxxxxx)

4. Call get_tables(app_token) to get table_id (e.g.: tblxxxxxxxx)

5. Call add_table_field() to add fields:
   - Customer Name (field_name="Customer Name", field_type=1) Text
   - Contact Person (field_name="Contact Person", field_type=1) Text
   - Contact Phone (field_name="Contact Phone", field_type=11) Phone
   - Customer Source (field_name="Customer Source", field_type=3) Single-select
   - Customer Stage (field_name="Customer Stage", field_type=3) Single-select
   - Industry (field_name="Industry", field_type=3) Single-select
   - Estimated Transaction Amount (field_name="Estimated Transaction Amount", field_type=2) Number
   - Creation Time (field_name="Creation Time", field_type=5) Date
   - Remarks (field_name="Remarks", field_type=1) Text

6. Set field configurations
   - Customer Source Options: Online Promotion/Referral/Exhibition/Proactive Development
   - Customer Stage Options: Potential Customer/Interested/Negotiating/Converted/Lost
   - Industry Options: Internet/Finance/Manufacturing/Retail/Other
   - Estimated Amount: Set minimum value to 0

7. Add sample data
   Call add_record(app_token, table_id, {
     "Customer Name": "Sample Tech Company",
     "Contact Person": "Zhang San",
     "Contact Phone": "13800138000",
     "Customer Source": "Online Promotion",
     "Customer Stage": "Interested",
     "Industry": "Internet",
     "Estimated Transaction Amount": 50000,
     "Creation Time": 1704067200000,
     "Remarks": "Potential high-quality customer"
   })

8. Add user as collaborator
   Call get_user_by_email(email="user@example.com") to get open_id
   Call add_collaborator(app_token, "user", open_id, "edit")

9. Create associated table "Follow-up Records"
   Repeat steps 4-5 to create follow-up record table, including:
   - Follow-up Time (field_type=5)
   - Follow-up Method (field_type=3, options: Phone/WeChat/Email/In-person)
   - Follow-up Content (field_type=1)
   - Next Follow-up Time (field_type=5)
   - Customer Name (associated field linked to customer information table)

10. Return results
    - Table link: https://feishu.cn/base/{app_token}
    - Field description document
    - Usage suggestions
Example: Create a Project Task Management Table
User: Create a project task management table

Assistant Execution:

1. Requirement Analysis
   - Business Type: Project Management
   - Core Entities: Projects, Tasks
   - Data Flow: Project Decomposition → Task Assignment → Execution Tracking

2. Call create_bitable(name="Project Task Management System")

3. Obtain the returned app_token

4. Call get_tables(app_token) to get table_id

5. Call add_table_field() to add fields to the "Project List" table:
   - Project Name (field_name="Project Name", field_type=1)
   - Project Number (field_name="Project Number", field_type=1)
   - Project Status (field_name="Project Status", field_type=3) Options: Not Started/In Progress/Completed/Delayed
   - Start Date (field_name="Start Date", field_type=5)
   - End Date (field_name="End Date", field_type=5)
   - Project Priority (field_name="Project Priority", field_type=3) Options: High/Medium/Low
   - Project Progress (field_name="Project Progress", field_type=15) 0-100%
   - Project Manager (field_name="Project Manager", field_type=1)

6. Add sample data
   Call add_record() to add 2-3 sample projects

7. Add user as collaborator

8. Create associated "Task List" table
   - Task Name (field_type=1)
   - Belongs to Project (associated field → Project List)
   - Task Owner (field_type=1)
   - Task Status (field_type=3) Options: To Do/In Progress/Completed/Canceled
   - Task Priority (field_type=3) Options: Urgent/High/Medium/Low
   - Start Time (field_type=5)
   - Deadline (field_type=5)
   - Estimated Hours (field_type=2)
   - Actual Hours (field_type=2)
   - Task Description (field_type=1)

9. Return dual-table structure description, association diagram, and usage suggestions
Example: Create a Purchase Order Management System
User: Create a purchase order management system

Assistant Execution:

1. Requirement Analysis
   - Business Type: Procurement Management
   - Core Entities: Purchase Orders
   - Data Flow: Order Creation → Approval → Execution

2. Call create_bitable(name="Purchase Order Management System")

3. Obtain the returned app_token

4. Call get_tables(app_token) to get table_id

5. Call add_table_field() to add fields:
   - Purchase Order (field_name="Purchase Order", field_type=1)
   - Unit Price (field_name="Unit Price", field_type=2)
   - Quantity (field_name="Quantity", field_type=2)
   - Total Amount (field_name="Total Amount", field_type=2)
   - Purchase Time (field_name="Purchase Time", field_type=5)
   - Purchaser (field_name="Purchaser", field_type=1)

6. Add sample data
7. Add user as collaborator
8. Return table link and usage instructions

场景 2: 批量导入数据

Scenario 2: Batch Import Data

用户: 向表格 xyz 添加 10 条采购记录

助手:
1. 调用 get_tables(app_token) 确认 table_id
2. 循环调用 add_record() 添加数据
3. 返回添加结果
User: Add 10 purchase records to table xyz

Assistant:
1. Call get_tables(app_token) to confirm table_id
2. Loop call add_record() to add data
3. Return addition results

场景 3: 权限管理

Scenario 3: Permission Management

用户: 添加 user@example.com 为表格管理员

助手:
1. 调用 get_user_by_email(email="user@example.com") 获取 open_id
2. 调用 add_collaborator(
   app_token="...",
   member_type="user",
   member_id="<open_id>",
   perm_type="full_access"
)

User: Add user@example.com as table administrator

Assistant:
1. Call get_user_by_email(email="user@example.com") to get open_id
2. Call add_collaborator(
   app_token="...",
   member_type="user",
   member_id="<open_id>",
   perm_type="full_access"
)

🤖 智能表格类型识别

🤖 Intelligent Table Type Recognition

支持识别以下业务类型:
业务类型关键词预设字段
客户管理CRM、客户、销售、客户管理客户名称、联系人、阶段、金额
项目管理项目、任务、项目任务项目名称、状态、负责人、进度
采购管理采购、订单、供应商订单号、单价、数量、金额
库存管理库存、仓库、商品商品名称、SKU、库存量、位置
人事管理员工、考勤、招聘姓名、部门、职位、状态
费用管理报销、费用、审批报销人、金额、类型、日期

Supports recognition of the following business types:
Business TypeKeywordsPreset Fields
Customer ManagementCRM, customer, sales, customer managementCustomer Name, Contact Person, Stage, Amount
Project Managementproject, task, project taskProject Name, Status, Owner, Progress
Procurement Managementprocurement, order, supplierOrder Number, Unit Price, Quantity, Amount
Inventory Managementinventory, warehouse, commodityCommodity Name, SKU, Stock Quantity, Location
HR Managementemployee, attendance, recruitmentName, Department, Position, Status
Expense Managementreimbursement, expense, approvalReimburser, Amount, Type, Date

📋 字段类型说明

📋 Field Type Description

类型值类型名称说明
1text文本
2number数字
3select单选
4multiSelect多选
5dateTime日期
7attachment附件
11phone电话
12email邮箱
13url网址
15progress进度

Type ValueType NameDescription
1textText
2numberNumber
3selectSingle-select
4multiSelectMulti-select
5dateTimeDate & Time
7attachmentAttachment
11phonePhone
12emailEmail
13urlURL
15progressProgress

🔐 权限类型说明

🔐 Permission Type Description

  • view
    - 仅查看
  • edit
    - 编辑权限
  • full_access
    - 完全管理权限

  • view
    - View only
  • edit
    - Edit permission
  • full_access
    - Full management permission

📁 项目结构

📁 Project Structure

feishu-integration/
├── plugin.json              # 插件清单
├── SKILL.md                 # 本文档
├── mcp-server/              # MCP 服务器
│   ├── index.py             # FastMCP 实现
│   ├── requirements.txt     # Python 依赖
│   └── README.md            # MCP 文档
├── scripts/                 # Python 脚本(备用)
│   ├── create_feishu_app.py
│   ├── create_purchase_order_bitable.py
│   ├── add_feishu_collaborator.py
│   └── ...
└── .mcp.json                # MCP 配置

feishu-integration/
├── plugin.json              # Plugin manifest
├── SKILL.md                 # This document
├── mcp-server/              # MCP Server
│   ├── index.py             # FastMCP implementation
│   ├── requirements.txt     # Python dependencies
│   └── README.md            # MCP documentation
├── scripts/                 # Python scripts (backup)
│   ├── create_feishu_app.py
│   ├── create_purchase_order_bitable.py
│   ├── add_feishu_collaborator.py
│   └── ...
└── .mcp.json                # MCP configuration

🛠️ 配置说明

🛠️ Configuration Instructions

MCP 服务器配置

MCP Server Configuration

确保
~/.minto/config/mcp.json
包含:
json
{
  "mcpServers": {
    "feishu": {
      "command": "python3.11",
      "args": ["/path/to/mcp-server/index.py"],
      "env": {
        "FEISHU_APP_ID": "your_app_id",
        "FEISHU_APP_SECRET": "your_app_secret"
      }
    }
  }
}
Ensure
~/.minto/config/mcp.json
contains:
json
{
  "mcpServers": {
    "feishu": {
      "command": "python3.11",
      "args": ["/path/to/mcp-server/index.py"],
      "env": {
        "FEISHU_APP_ID": "your_app_id",
        "FEISHU_APP_SECRET": "your_app_secret"
      }
    }
  }
}

环境变量

Environment Variables

  • FEISHU_APP_ID
    : 飞书应用ID
  • FEISHU_APP_SECRET
    : 飞书应用密钥
获取方式:
  1. 访问 https://open.feishu.cn
  2. 创建应用或选择已有应用
  3. 在"凭证与基础信息"页面获取

  • FEISHU_APP_ID
    : Feishu app ID
  • FEISHU_APP_SECRET
    : Feishu app secret
How to obtain:
  1. Visit https://open.feishu.cn
  2. Create a new app or select an existing one
  3. Obtain from the "Credentials & Basic Information" page

🔍 故障排查

🔍 Troubleshooting

MCP 工具不可用

MCP Tool Unavailable

  1. 检查 MCP 服务器是否启动:
    bash
    minto mcp list
  2. 检查环境变量是否配置:
    bash
    minto mcp get feishu
  3. 查看 MCP 配置文件:
    bash
    cat ~/.minto/config/mcp.json
  1. Check if MCP server is running:
    bash
    minto mcp list
  2. Check if environment variables are configured:
    bash
    minto mcp get feishu
  3. View MCP configuration file:
    bash
    cat ~/.minto/config/mcp.json

API 返回 404

API Returns 404

  • 确保在飞书开放平台启用了相关权限
  • 重新发布应用并等待权限生效(约10分钟)
  • Ensure relevant permissions are enabled on Feishu Open Platform
  • Republish the app and wait for permissions to take effect (approx. 10 minutes)

添加协作者失败

Failed to Add Collaborator

应用需要以下权限:
  • permission:permission.member.create
  • 或权限包:"分享云文档"

The app requires the following permissions:
  • permission:permission.member.create
  • Or permission package: "Share Cloud Docs"

📚 Python 脚本使用(备用)

📚 Python Script Usage (Backup)

如果需要使用脚本方式:
bash
cd scripts
python3 create_feishu_app.py
python3 add_feishu_collaborator.py
依赖安装:
bash
pip install requests lark-oapi

If you need to use script mode:
bash
cd scripts
python3 create_feishu_app.py
python3 add_feishu_collaborator.py
Dependency installation:
bash
pip install requests lark-oapi

✅ 最佳实践

✅ Best Practices

  1. 优先使用 MCP 工具进行交互式操作
  2. 批量操作使用脚本提高效率
  3. 创建表格后及时添加自己为协作者
  4. 验证权限:先用
    get_tenant_access_token
    测试连接
  5. 保存 app_token:创建的表格 token 需保存以便后续操作

  1. Prioritize MCP tools for interactive operations
  2. Use scripts for batch operations to improve efficiency
  3. Add yourself as a collaborator immediately after creating tables
  4. Verify permissions: Test connectivity with
    get_tenant_access_token
    first
  5. Save app_token: Save the created table token for subsequent operations

🔗 参考文档

🔗 Reference Documents

💻 开发者

💻 Developers