# Locally install and use OpenAPI MCP

This article introduces how to install and use the OpenAPI MCP tool within AI tools (use [Trae](https://www.trae.com.cn/) as an example).

## Usage restrictions

By default, OpenAPI MCP only enables certain OpenAPIs of the Feishu Open Platform, while also supporting manual activation of specified OpenAPIs.  
It is recommended that you first follow the instructions in this article to complete the installation and experience of the MCP tool step by step. Then, based on your own needs, select and enable the specified OpenAPIs to suit your business. For the list of OpenAPIs enabled by default and how to enable specified OpenAPIs, please refer to the **FAQ** section of this article.  

## Preparations

### Creating a Feishu app

Before using the MCP tool, you need to create a Feishu app.
1. Log in to the [Feishu Developer Console](https://open.feishu.cn/app).
2. In the **Custom Apps** tab, click **Create Custom App**.
4. Set the application name, description, icon, and click **Create**.

For detailed configuration instructions for enterprise custom apps, see [Creating an custom app](https://open.larkoffice.com/document/develop-process/self-built-application-development-process#a0a7f6b0).

4. On the **Credentials & Basic Info** page of the application, save the **Credentials** (**App ID** and **App Secret**) for later use.

![](//sf3-cn.feishucdn.com/obj/open-platform-opendoc/609a45eeb496a28aeb5736b7d380e0d8_scjkuul3Ri.png?height=340&lazyload=true&maxWidth=600&width=2612)

5. On the application's **Add Features** page, add app capabilities as needed.

For example, if you need the AI to send messages to specified users, you need to add the **Bot** capability.

![](//sf3-cn.feishucdn.com/obj/open-platform-opendoc/dae2cabb596f8a1c743f7efe4bd46cb8_jr5OLCTVq2.png?height=906&lazyload=true&maxWidth=600&width=2836)

6. On the application's **Permissions & Scopes** page, click to enable permissions according to your business needs.

For example, if you need to call the [Send message](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/create) API as an application, you must enable the permissions according to the API documentation. For detailed instructions on permission application, see [Apply for API permissions](https://open.feishu.cn/document/ukTMukTMukTM/uQjN3QjL0YzN04CN2cDN).

The APIs enabled by default in the OpenAPI MCP tool require the application to activate the following permissions. You need to paste the following content into the input box on the **Add permission scopes to app** page to enable the permissions in bulk (note that you should enable permissions separately for application identity and user identity as needed).

```
    im:chat:create, im:chat, im:message, wiki:wiki, wiki:wiki:readonly, docx:document, bitable:app, drive:drive, docs:document:import, contact:user.id:readonly
    ```

![image.png](//sf3-cn.feishucdn.com/obj/open-platform-opendoc/05660f8a68c2e89101da3823f307a448_LEZ3MljrxA.png?height=1572&lazyload=true&maxWidth=600&width=2942)

7. On the application's **Security Settings** > **Redirect URLs** page, in the **Redirect URLs** area, enter `http://localhost:3000/callback` and click **Add**.  
    Configure the [Redirect URL](https://open.feishu.cn/document/uYjL24iN/uYjN3QjL2YzN04iN2cDN) for the application. It will be used later for user authorization to obtain the user access token (`user_access_token`).  

![image.png](//sf3-cn.feishucdn.com/obj/open-platform-opendoc/ecb2dc50c0d63e9e922f6020a0786be2_fFuHMebv2u.png?height=478&lazyload=true&maxWidth=600&width=2210)

If there is a **Refresh user_access_token** switch at the bottom of the page, you need to turn it on.  

If there is no such switch, no action is needed as it is enabled by default.

![image.png](//sf3-cn.feishucdn.com/obj/open-platform-opendoc/eae9a18fa44c75e2b3bcd673b1932f0d_0aemJGzOtE.png?height=966&lazyload=true&maxWidth=600&width=1644)

8. After completing the configuration, publish the application to make the configuration effective.

1. On the **Version Management & Release** page of the application, click **Create  a version**.
    3. After completing the configuration items such as application version number, default capabilities for mobile/desktop, update descriptions, etc., click **Save** at the bottom of the page.
    4. In the pop-up dialog, click to confirm the release.

The application will only be published successfully after the enterprise administrator reviews and approves it.

### Install Node.js

Before using the MCP tool, you need to install Node.js in the running environment of the AI tool.
Please ensure that the installed Node version is higher than v20.0.0. It is recommended to use the latest version provided by the [Node.js official website](https://nodejs.org/).

1. Visit the [Node.js official website](https://nodejs.org/).
2. Download and install the LTS version.

After installation, run the following commands to check if the installation was successful.

```
node -v
npm -v
```

If the installation is successful, the corresponding version numbers will be returned.

![image.png](//sf3-cn.feishucdn.com/obj/open-platform-opendoc/e8080890bcf53c2002b205167f7c0152_BEZt4H0JZd.png?height=152&lazyload=true&maxWidth=300&width=477)

## Install OpenAPI MCP

1. Open the Trae tool.

2. Open the terminal within the tool.

![image.png](//sf3-cn.feishucdn.com/obj/open-platform-opendoc/b49cb2d6a1aa9c6725c18bc08ff6bfb1_H5suYXtVTs.png?height=1286&lazyload=true&maxWidth=600&width=1448)

3. Execute the following command to log in to OpenAPI MCP as a user.

```bash
    npx -y @larksuiteoapi/lark-mcp login -a <your_app_id> -s <your_app_secret>
    ```

Here, `<your_app_id>` is the App ID of your Feishu application, and `<your_app_secret>` is the App Secret. You can log in to the [Feishu Developer Console](https://open.larkoffice.com/app) and obtain the **App ID** and **App Secret** on the **Credentials & Basic Info** page of your created self-built application.

![image.png](//sf3-cn.feishucdn.com/obj/open-platform-opendoc/9ce447200c78518e61679906c902a4d8_FNOtpnSOqg.png?height=356&lazyload=true&maxWidth=600&width=2532)

4. The terminal will echo a URL for user authorization, which you need to visit and complete authorization within 60 seconds.

![image.png](//sf3-cn.feishucdn.com/obj/open-platform-opendoc/31dfb2cb1624435ef5539f456e28514f_QhrIVN3W7c.png?height=326&lazyload=true&maxWidth=600&width=1686)

The authorization page looks like the image below. Ensure the user identity is as expected, and click **Authorize** so that the MCP tool can obtain the user access token (`user_access_token`).

![image.png](//sf3-cn.feishucdn.com/obj/open-platform-opendoc/a8b98c48a69c371e2da9ffcaf995868d_Zx8lRSM8vs.png?height=1176&lazyload=true&maxWidth=400&width=1242)

After successful authorization, the terminal will echo `success`.

5. At the top right corner of the tool, navigate through **Toggle AI Side Bar > AI Management > MCP > Add > Add Manually** to open the MCP JSON configuration dialog.

![image.png](//sf3-cn.feishucdn.com/obj/open-platform-opendoc/801a38cfed9feaff2381d9129dc72d7d_1973tdmKq0.gif?height=1104&lazyload=true&maxWidth=600&width=1878)

6. Replace the default content with the following JSON and click **Confirm**.

```json
    {
      "mcpServers": {
        "lark-mcp": {
          "command": "npx",
          "args": [
            "-y",
            "@larksuiteoapi/lark-mcp",
            "mcp",
            "-a",
            "<your_app_id>",
            "-s",
            "<your_app_secret>",
            "--oauth"
          ]
        }
      }
    }
    ```

Here, `<your_app_id>` is the App ID of your Feishu application, and `<your_app_secret>` is the App Secret. You can log in to the [Feishu Developer Console](https://open.larkoffice.com/app) and obtain the **App ID** and **App Secret** on the **Credentials & Basic Info** page of your created self-built application.

![image.png](//sf3-cn.feishucdn.com/obj/open-platform-opendoc/9ce447200c78518e61679906c902a4d8_FNOtpnSOqg.png?height=356&lazyload=true&maxWidth=600&width=2532)

7. After completing the configuration, check the MCP Server status in the **MCP** interface.

In Trae, the checkmark (✅) icon to the right of the tool name (lark-mcp) indicates successful configuration.

![image.png](//sf3-cn.feishucdn.com/obj/open-platform-opendoc/9634a647761d5c3dba2e8bf1678e58e6_5KuHvI5xUU.png?height=420&lazyload=true&maxWidth=400&width=800)

## Use OpenAPI MCP

By default, the tool enables only some of the Feishu Open Platform OpenAPIs, while also supporting manual activation of specified OpenAPIs. For details, please refer to the **FAQ** section of this document.

1. Open **Trae** on the right side of the Trae tool.

![](//sf3-cn.feishucdn.com/obj/open-platform-opendoc/870b4ba6e7f5c82ba8a61e9b47e9ef20_B2AJg83I5W.png?height=1048&lazyload=true&maxWidth=400&width=934)

2. In the lower left corner of the input box, click **Agent** and select the AI agent where the lark-mcp tool is located (the default is **Builder with MCP**).

![](//sf3-cn.feishucdn.com/obj/open-platform-opendoc/0efc331c114c4411cc57fb5e6fe48fad_REcmLb7H8d.png?height=588&lazyload=true&maxWidth=400&width=1210)

3. In the lower right corner of the input box, select any DeepSeek model (the implementation effects of different models vary).

![](//sf3-cn.feishucdn.com/obj/open-platform-opendoc/57c950e436def7ac81114eee2884f8f7_ktheJJUK6S.png?height=374&lazyload=true&maxWidth=400&width=860)

4. Fill in the scene prompt in the input box and click the send button in the lower right corner of the input box.

Example prompt: `Create a Feishu base and send it to employee Li Jian (employee email: xxxx@example.com). Note that Feishu user ID type should uniformly use open_id.`
    Scene prompts should be as detailed as possible and should appropriately add some constraints (such as uniformly using open_id for user ID type) to ensure the model runs accurately.

5. Wait for AI to run, and when the tool invocation reminder appears, click **Run**.

![](//sf3-cn.feishucdn.com/obj/open-platform-opendoc/5577a3d52d1499931a3b2f5b7f384fa2_nckcuEJiZ0.png?height=562&lazyload=true&maxWidth=400&width=866)

6. During the running process, the model will call multiple tools. You need to click **Run** sequentially and wait for the run to complete.warning
    If the execution fails, you can troubleshoot the error based on the call records echoed by the agent.

- A common cause of errors is that the application lacks the required API permissions.<br>

If the agent echoes a URL to enable permissions for the application, you can directly visit the URL to jump to the application details page and enable the missing permissions; alternatively, you can enable the required API permissions for the application according to the API documentation (for example, [Create a Base App](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/bitable-v1/app/create)).

- After enabling permissions for the application, if the permissions require review, you need to republish the application to make the configuration effective.

- If you are calling the API as a user (user_access_token), after enabling new permissions for the application and republishing it, you need to log out of MCP first and then log in again. For detailed operations, please refer to [After adding user identity API permissions to the application, is it necessary to re-authenticate the login](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/mcp_integration/use_cases#4a9c47f0).

![](//sf3-cn.feishucdn.com/obj/open-platform-opendoc/aaded77fc2fca7918c8190e1f115ae37_30Wu50WqSV.png?height=492&lazyload=true&maxWidth=400&width=924)

7. Log in to the Feishu client to view the results.

![](//sf3-cn.feishucdn.com/obj/open-platform-opendoc/ddde60b917bb9a3feebaa01e746cda31_0I7PO0bDFL.png?height=674&lazyload=true&maxWidth=400&width=974)

Click URL to access the base.

![](//sf3-cn.feishucdn.com/obj/open-platform-opendoc/b89b964d0861db9cc50457ed36fd8893_RKzxozdwfW.png?height=686&lazyload=true&maxWidth=400&width=2936)

## FAQ

### Which OpenAPIs are enabled by default in the MCP tool?

By default, MCP service enables the following OpenAPI as shown in the table below.
| **API name**                        | **Function description**      |**Required permissions** |
| ----------------------------------- | ----------------------------- |---|
| im.v1.chat.create                   | [Create Chat Group](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat/create)            |Create group (im:chat:create)|
| im.v1.chat.list                     | [Get List of Groups User or Bot is in](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat/list)      |Obtain and update group information (im:chat)|
| im.v1.chatMembers.get               | [Get List of Chat Members](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat-members/get)          |Obtain and update group information (im:chat)|
| im.v1.message.create                | [Send Message](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/create)           |Read and send messages in private and group chats (im:message)|
| im.v1.message.list                  | [Get Conversation History](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/list)         |Read and send messages in private and group chats (im:message)|
| wiki.v2.space.getNode               | [Get Knowledge Space Node Information](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/wiki-v2/space/get_node)      |View, edit, and manage Wiki (wiki:wiki)|
| wiki.v1.node.search                 | [Search Wiki](https://open.feishu.cn/document/ukTMukTMukTM/uEzN0YjLxcDN24SM3QjN/search_wiki)       |View all Wiki (wiki:wiki:readonly)|
| docx.v1.document.rawContent         | [Get Raw Text Content of Document](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/document-docx/docx-v1/document/raw_content)         |Create and edit upgraded Docs (docx:document)|
| drive.v1.permissionMember.create    | [Add Collaborator Permission](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/drive-v1/permission-member/create)       |View, edit, and manage Wiki (wiki:wiki)|
| docx.builtin.import                 | Import documents including uploading materials/files, creating import tasks, and querying import task results in three steps. For details, see [File Import Overview](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/drive-v1/import_task/import-user-guide#461aa643) |View, comment, edit and manage Base (bitable:app), View, comment, edit, and manage all files in My Space (drive:drive), View and create document import task (docs:document:import)|
| docx.builtin.search                 | [Search Cloud Documents](https://open.feishu.cn/document/ukTMukTMukTM/ugDM4UjL4ADO14COwgTN) |View, comment, edit, and manage all files in My Space (drive:drive)|
| bitable.v1.app.create               | [Create Multi-dimensional Table](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/bitable-v1/app/create)       |View, comment, edit and manage Base (bitable:app)|
| bitable.v1.appTable.create          | [Add a Data Table](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/bitable-v1/app-table/create)  |View, comment, edit and manage Base (bitable:app)|
| bitable.v1.appTable.list            | [List Data Tables](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/bitable-v1/app-table/list)  |View, comment, edit and manage Base (bitable:app)|
| bitable.v1.appTableField.list       | [List Fields](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/bitable-v1/app-table-field/list) |View, comment, edit and manage Base (bitable:app)|
| bitable.v1.appTableRecord.search    | [Search Records](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/bitable-v1/app-table-record/search)  |View, comment, edit and manage Base (bitable:app)|
| bitable.v1.appTableRecord.create    | [Add Records](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/bitable-v1/app-table-record/create)  |View, comment, edit and manage Base (bitable:app)|
| bitable.v1.appTableRecord.update    | [Update Records](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/bitable-v1/app-table-record/update)  |View, comment, edit and manage Base (bitable:app)|
| contact.v3.user.batchGetId          | [Get User ID by Phone Number or Email](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/contact-v3/user/batch_get_id)      | Obtain user ID via email or mobile number (contact:user.id:readonly)|

### How to enable a specified OpenAPI?

To enable specific OpenAPI tools, you can specify them in the MCP configuration file using the `-t` parameter. Instructions for using this parameter:

- Refer to [tools](https://github.com/larksuite/lark-openapi-mcp/blob/main/docs/reference/tool-presets/tools-en.md) to pass the corresponding **MCP tool names** for the tools.
- You can pass [preset tool sets](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/mcp_integration/advanced-configuration#613c137b). For example, passing the message preset tool set (preset.im.default) will enable messaging APIs in bulk.
- Multiple parameter values are supported simultaneously (including individual API tools and preset tool set names), separated by commas.
- This method fully overrides the default enabled API tools, enabling only the API tools included in the `-t` parameter.

The example configuration is as follows:

```json
{
  "mcpServers": {
    "lark-mcp": {
     "command": "npx",
      "args": [
        "-y",
        "@larksuiteoapi/lark-mcp",
        "mcp",
        "-a",
        "<your_app_id>",
        "-s",
        "<your_app_secret>",
        "-t",
        "im.v1.message.create,im.v1.message.list,im.v1.chat.create"
      ]
    }
  }
}
```

### Does user authentication support automatic refresh upon expiration?

Yes. After completing user authentication using the OpenAPI MCP **login** command parameters, the system will check whether the user_access_token has expired before making API requests. If it has expired, the user_access_token will be refreshed automatically.

If the automatic refresh fails, the agent will push a notification prompting you to visit the authorization page and re-authorize as instructed.

### MCP creates a Docs file using tenant_access_token, and users cannot access the Docs file. How to resolve?

The MCP tool does not specify the identity type of the [access token](https://open.feishu.cn/document/ukTMukTMukTM/uMTNz4yM1MjLzUzM) by default, and it is automatically selected by the large model inference. Therefore, it is possible that MCP uses the app identity to call the API and create a Docs file.

If you want MCP to create and operate Docs files using your identity (i.e., the ownership of the Docs file belongs to you, and the app only performs operations on your behalf), you can:

- Method 1: Modify the MCP JSON file to specify that MCP always uses user_access_token to call the API via `--token-mode`:

```json
  {
    "mcpServers": {
      "lark-mcp": {
       "command": "npx",
        "args": [
          "-y",
          "@larksuiteoapi/lark-mcp",
          "mcp",
          "-a",
          "<your_app_id>",
          "-s",
          "<your_app_secret>",
          "--token-mode",   // Specify the token type as user_access_token here
          "user_access_token"
        ]
      }
    }
  }
  ```

- Method 2: Use the command line to specify that MCP always uses user_access_token to call the API:

```bash
  lark-mcp mcp -a cli_xxxxxxxxxx -s xxxxxxxxxxxx --token-mode user_access_token  
  ```
  Here, `cli_xxxxxxxxxx` and `xxxxxxxxxxxx` represent the actual App ID and App Secret of the application. You can go to the [Developer console](https://open.feishu.cn/app) and navigate to the **Credentials & Basic Info** page of the application to obtain the app credentials (App ID and App Secret).

![image.png](//sf3-cn.feishucdn.com/obj/open-platform-opendoc/3a6e16a889a0db713ba479c67ebbac71_mgLDONXX3Z.png?height=340&lazyload=true&maxWidth=600&width=2612)