feishu-integration

Original🇨🇳 Chinese
Translated
14 scripts

Feishu (Lark) API Integration Guide. Use this when users request to "create Feishu apps", "manage base tables", "add collaborators", "generate Feishu reports", "set Feishu permissions" or "automate Feishu operations". Prioritize using MCP tools for real-time interactive operations.

3installs
Added on

NPX Install

npx skill4agent add within-7/minto-plugin-tools feishu-integration

SKILL.md Content (Chinese)

View Translation Comparison →

Feishu Integration Skill

Comprehensive guide for Feishu (Lark) API integration and automation.

🚀 How It Works

This project provides two usage methods:

Option 1: MCP Tool (Recommended) ⚡

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

Option 2: Python Script 📜

Suitable for complex batch operations and automated workflows.

🔧 MCP Tool List

Authentication & Connection

ToolFunctionUse Case
mcp__feishu__get_tenant_access_token
Obtain access tokenVerify connection status

Base Table Management

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

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

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

Resource URIFunction
feishu://config
Get current configuration information

💡 Typical Use Scenarios

Scenario 1: Create Different Types of Base Tables

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

Scenario 2: Batch Import Data

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

Scenario 3: Permission Management

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

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

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

🔐 Permission Type Description

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

📁 Project Structure

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 Server Configuration

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
    : 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 Tool Unavailable

  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 Returns 404

  • 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

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

📚 Python Script Usage (Backup)

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. 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