Feishu/Lark OpenAPI MCP

repository·main·Indexed 20 days ago

https://github.com/larksuite/lark-openapi-mcp

An official tool that exposes Feishu/Lark Open Platform APIs as Model Context Protocol (MCP) tools, enabling AI agents like Claude, Cursor, and Trae to perform automation tasks such as document reading, messaging, and calendar management. It supports stdio and SSE transport modes, OAuth 2.0 user identity authentication, and tool presets to optimize API capabilities.

Tokens
134.3K
Snippets
158
Records
302
Agent score
69%

What's inside lark-openapi-mcp

  1. Use stdio or SSE transport modes with lark-mcp

    main

    The recall-developer-documents tool supports two primary transport modes:

    1. stdio mode (Default/Recommended): Best for integration with AI tools like Cursor or Claude via standard input/output streams.
    2. SSE mode: Provides an HTTP interface based on Server-Sent Events, suitable for web applications or scenarios requiring network access. When using SSE, the endpoint is accessible at http://<host>:<port>/sse.
    # Use stdio mode (default)
    lark-mcp recall-developer-documents -m stdio
    
    # Use SSE mode on localhost
    lark-mcp recall-developer-documents -m sse -p 3000
    
    # Use SSE mode and listen on all network interfaces (remote access)
    lark-mcp recall-developer-documents -m sse --host 0.0.0.0 -p 3000
  2. Manage file comments and replies in driveV1

    main

    The driveV1 domain provides several tools for interacting with document comments:

    • Retrieval: Use drive.v1.fileComment.list to get all comments (paginated, default 50 per page) or drive.v1.fileComment.batchQuery for specific IDs. Use drive.v1.fileCommentReply.list to get replies to a specific comment.
    • Creation/Update: Use drive.v1.fileComment.create for global comments and drive.v1.fileCommentReply.update to edit replies.
    • Management: Use drive.v1.fileComment.patch to resolve or restore comments, and drive.v1.fileCommentReply.delete to remove replies.
  3. Manage file permissions and collaborators in driveV1

    main

    Control access to cloud documents using the following tools:

    • Collaborators: Use drive.v1.permissionMember.create or drive.v1.permissionMember.batchCreate to add users, groups, or departments. Use drive.v1.permissionMember.update to change their permissions (read, edit, manage) and drive.v1.permissionMember.delete to remove them. Use drive.v1.permissionMember.transferOwner to change the document owner.
    • Public/Organization Settings: Use drive.v1.permissionPublic.get and drive.v1.permissionPublic.patch to manage settings like sharing outside the organization or allowing content copying.
    • Password Protection: Use drive.v1.permissionPublicPassword.create, update, or delete to manage password access for users outside the organization.
    • Verification: Use drive.v1.permissionMember.auth to check if a specific user or app has certain permissions (read, edit, share, etc.).
  4. CoreHR V2: Manage Organizational Changes and Approvals

    main

    The corehrV2 domain provides tools for managing organizational structure adjustments and the associated approval processes.

    Key capabilities include:

    • Tracking Adjustments: Query organizational structure adjustment records via corehr.v2.approvalGroups.get. This allows you to check the status of an approval and retrieve specific details regarding department or personnel changes using corehr.v2.approvalGroups.openQueryDepartmentChangeListByIds and corehr.v2.approvalGroups.openQueryJobChangeListByIds respectively.
    • Approval Management: Retrieve a specific user's approval task list with corehr.v2.approver.list or manage specific approval tasks (approve/reject) using corehr.v2.processApprover.update.
  5. Docker usage tips for lark-mcp

    main

    When running lark-mcp via Docker, keep the following in mind:

    • No password required: The container automatically initializes the secrets service, allowing keytar to store tokens securely without interaction.
    • Token persistence: Always mount a volume (e.g., -v lark_mcp_data:/home/node/.local/share) to ensure your authentication tokens are not lost when the container stops.
  6. Manage files and folders in the driveV1 domain

    main

    Use these tools to organize and manipulate files within a user's cloud space:

    • File Operations:
      • drive.v1.file.createFolder: Create a new empty folder.
      • drive.v1.file.copy: Copy a file to a different folder (asynchronous).
      • drive.v1.file.move: Move a file or folder to a new location.
      • drive.v1.file.delete: Delete a file or folder (moves it to the recycle bin).
      • drive.v1.file.createShortcut: Create a shortcut to a document in another folder.
      • drive.v1.file.list: List all items (files, folders, docs) within a specific folder.
    • Metadata & Stats:
      • drive.v1.fileStatistics.get: Get view counts (PV), unique visitors (UV), and likes.
      • drive.v1.meta.batchQuery: Get metadata (title, owner, creation time) for multiple documents using tokens.
  7. Deploy lark-mcp as a Service (Streamable Mode)

    main

    For team sharing or server-side deployment, you can run lark-mcp in streamable mode, which provides an HTTP interface.

    Step 1: Start the HTTP Server

    Run the following command on your server:

    npx -y @larksuiteoapi/lark-mcp mcp \
      -a cli_xxxx \
      -s your_secret \
      -m streamable \
      --host 0.0.0.0 \
      -p 3000

    Step 2: Configure MCP Client URL

    In your MCP clients, connect via the URL instead of a command:

    {
      "mcpServers": {
        "lark-mcp": {
           "url": "http://localhost:3000/mcp"
        }
      }
    }

    Note on OAuth in Streamable Mode: To use user identity in streamable mode, add --oauth and --token-mode user_access_token to the startup command. Currently, OAuth-enabled streamable services only support localhost.

    {
      "mcpServers": {
        "lark-mcp": {
           "url": "http://localhost:3000/mcp"
        }
      }
    }
  8. Configure lark-mcp in MCP clients using streamable (HTTP) mode

    main

    To use streamable mode, you must first start the Docker container with port mapping and the streamable mode flag. Then, configure your MCP client to point to the local URL.

    Step 1: Start the container

    docker run --rm -it \
      -p 3000:3000 \
      -v lark_mcp_data:/home/node/.local/share \
      lark-mcp:latest mcp -a <your_app_id> -s <your_app_secret> -m streamable --host 0.0.0.0 -p 3000

    Step 2: Client Configuration

    {
      "mcpServers": {
        "lark-mcp": {
          "url": "http://localhost:3000/mcp"
        }
      }
    }
  9. Use User Identity (OAuth) for Personal Data Access

    main

    To access private user data (e.g., personal documents, sending messages as a user, accessing calendars), you must authenticate via OAuth.

    Step 1: Perform Login in Terminal

    Run the following command to start a local server and open your browser for authorization:

    npx -y @larksuiteoapi/lark-mcp login -a cli_xxxx -s your_secret

    Note: Ensure http://localhost:3000/callback is configured as the redirect URL in your Feishu/Lark app settings.

    Step 2: Configure MCP Client

    Update your MCP client configuration to enable OAuth and set the token mode to user_access_token:

    {
      "mcpServers": {
        "lark-mcp": {
          "command": "npx",
          "args": [
            "-y",
            "@larksuiteoapi/lark-mcp",
            "mcp",
            "-a", "cli_xxxx",
            "-s", "your_secret",
            "--oauth",
            "--token-mode",
            "user_access_token"
          ]
        }
      }
    }
    {
      "mcpServers": {
        "lark-mcp": {
          "command": "npx",
          "args": [
            "-y",
            "@larksuiteoapi/lark-mcp",
            "mcp",
            "-a", "cli_xxxx",
            "-s", "your_secret",
            "--oauth",
            "--token-mode",
            "user_access_token"
          ]
        }
      }
    }
  10. Login and get user access token for OAuth

    main

    If your AI agent needs to access user-specific resources (like personal documents or sending IM messages as a user), you must perform a login step to obtain a user access token.

    1. Ensure your application's redirect URL is set to http://localhost:3000/callback in the developer console.
    2. Run the login command in your terminal. You can optionally specify an OAuth --scope.
    3. Update your MCP configuration to use --oauth and set --token-mode to user_access_token to prevent the AI from falling back to tenant_access_token, which often lacks sufficient permissions for private user data.
    # Login and get user access token
    npx -y @larksuiteoapi/lark-mcp login -a cli_xxxx -s yyyyy
       
    # Or optionally, login with specific OAuth scope
    npx -y @larksuiteoapi/lark-mcp login -a cli_xxxx -s yyyyy --scope offline_access docx:document

    MCP Configuration for OAuth:

    {
      "mcpServers": {
        "lark-mcp": {
          "command": "npx",
          "args": [
            "-y",
            "@larksuiteoapi/lark-mcp",
            "mcp",
            "-a",
            "<your_app_id>",
            "-s",
            "<your_app_secret>",
            "--oauth",
            "--token-mode", "user_access_token"
          ]
        }
      }
    }
  11. Integrate lark-mcp with Trae or Cursor

    main

    To use the Feishu/Lark OpenAPI MCP in AI IDEs like Trae or Cursor, you can use the provided installation deep-links or manually configure the MCP Client using a JSON configuration. You must provide your app_id and app_secret in the args field.

    Standard Configuration (Tenant Access Token): Use this for general automation where the application acts on its own behalf.

    {
      "mcpServers": {
        "lark-mcp": {
          "command": "npx",
          "args": [
            "-y",
            "@larksuiteoapi/lark-mcp",
            "mcp",
            "-a",
            "<your_app_id>",
            "-s",
            "<your_app_secret>"
          ]
        }
      }
    }
  12. Use stdio or SSE transfer modes with lark-mcp

    main

    The recall-developer-documents tool supports different communication modes depending on your integration needs:

    1. stdio mode (default/recommended): Best for AI tools like Cursor or Claude that communicate via standard input/output.
    lark-mcp recall-developer-documents -m stdio
    1. SSE mode: Provides an HTTP interface via Server-Sent Events, useful for web applications. The endpoint is available at http://<host>:<port>/sse.

    Run SSE on localhost:

    lark-mcp recall-developer-documents -m sse -p 3000

    Run SSE on all network interfaces (remote access):

    lark-mcp recall-developer-documents -m sse --host 0.0.0.0 -p 3000