New:Microsoft Teams Notifications Are Now Available in Socket.Learn more →
Get Started

feishu-user-mcp

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

feishu-user-mcp

All-in-one Feishu/Lark MCP Server — 33 tools, 3 auth layers: user identity messaging (Protobuf), official API (REST), P2P chat reading (OAuth UAT).

latest
Source
npmnpm
Version
0.5.4
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

feishu-user-mcp

License: MIT Node.js MCP Tools PRs Welcome

All-in-one Feishu/Lark MCP Server -- 33 tools, 8 skills, 3 auth layers for messaging, docs, tables, wiki, and drive.

The only MCP server that lets you send messages as your personal identity (not a bot), while also integrating the full official Feishu API for documents, spreadsheets, wikis, and more.

Highlights

  • Send as yourself -- Messages show your real name, not a bot. Supports text, rich text, images, files, stickers, and audio.
  • Read everything -- Group chats via bot API, P2P (direct messages) via OAuth UAT.
  • Full Feishu suite -- Docs, Bitable (spreadsheets), Wiki, Drive, Contacts -- all in one plugin.
  • 3 auth layers -- Cookie-based user identity, app credentials (Official API), and OAuth UAT (P2P reading). Each is independent; configure only what you need.
  • 8 slash commands for Claude Code -- /send, /reply, /search, /digest, /doc, /table, /wiki, /status
  • Auto session management -- Cookie heartbeat every 4h, UAT auto-refresh with token rotation.
  • Chat name resolution -- Pass a group name instead of oc_xxx ID; it resolves automatically.

Why This Exists

Feishu's official API has a hard limitation: there is no send_as_user scope. Even with user_access_token (OAuth), messages still show sender_type: "app".

This project combines three auth layers into one plugin:

User Identity (cookie):     You -> Protobuf -> Feishu (messages appear as YOU)
Official API  (app token):  You -> REST API -> Feishu (docs, tables, wiki, drive)
User OAuth    (UAT):        You -> REST API -> Feishu (read P2P chats, list all chats)

One plugin. Everything Feishu. No other MCP needed.

Quick Start

npx feishu-user-mcp

No installation needed. The package runs directly via npx.

Option 2: Clone and run locally

git clone https://github.com/EthanQC/feishu-user-mcp.git
cd feishu-user-mcp
npm install
npm start

Create Your Feishu App

To use the Official API tools (docs, tables, wiki, drive, bot messaging), you need to create a Feishu app:

Step 1: Create the App

  • Go to Feishu Open Platform and log in
  • Click Create Custom App (创建自建应用) -- you must choose Custom App (自建应用), NOT marketplace/third-party types
  • Fill in the app name and description, then create it

Step 2: Enable Bot Capability

  • In your app settings, go to Add Capabilities (添加应用能力)
  • Enable Bot (机器人)

Step 3: Add Permissions (Scopes)

Go to Permissions & Scopes (权限管理) and add the following scopes:

ScopePurpose
im:messageSend messages as bot
im:message:readonlyRead message history
im:chat:readonlyList and read chats
docx:documentRead and create documents
docx:document:readonlyRead documents
bitable:recordRead and write Bitable records
wiki:wiki:readonlyRead wiki spaces and nodes
drive:drive:readonlyList Drive files and folders
contact:user.id:readonlyLook up users by email/mobile

Add more scopes as needed depending on which tools you use.

Step 4: Get App Credentials

  • Go to Credentials & Basic Info (凭证与基础信息)
  • Copy the App ID (cli_xxxxxxxxxxxx) and App Secret
  • Set them as LARK_APP_ID and LARK_APP_SECRET in your environment

Step 5: Publish and Approve

  • Create a version and submit it for review (创建版本)
  • Have your organization admin approve the app (管理员审核)
  • After approval, the app is live

Step 6: Add Bot to Group Chats

Add your bot to the group chats where you want it to read messages. The bot can only access chats it has been added to.

Environment Variables

VariableRequired ForDescription
LARK_COOKIEUser identity toolsFeishu web session cookie string. Needed for send_to_user, send_to_group, search_contacts, etc.
LARK_APP_IDOfficial API toolsApp ID from Feishu Open Platform. Needed for read_messages, docs, tables, wiki, drive.
LARK_APP_SECRETOfficial API toolsApp Secret from Feishu Open Platform. Used together with LARK_APP_ID.
LARK_USER_ACCESS_TOKENP2P chat readingOAuth user token. Needed for read_p2p_messages and list_user_chats. Obtained via node src/oauth.js.

Each auth layer is independent. You can configure:

  • Cookie only -- for sending messages as yourself
  • App credentials only -- for reading docs, tables, wiki, group chats
  • All three -- for the full feature set

Option A: With Playwright MCP (recommended)

If you have Playwright MCP configured, let Claude Code handle it automatically — you just scan the QR code to log in:

// Playwright can access HttpOnly cookies that document.cookie cannot
const cookies = await context.cookies('https://www.feishu.cn');
const cookieStr = cookies.map(c => c.name + '=' + c.value).join('; ');

Option B: Manual (via Network tab)

  • Open feishu.cn/messenger in your browser and log in
  • Open DevTools (F12 or Cmd+Option+I)
  • Go to the Network tab → check Disable cache → press Cmd+R to reload
  • Click the first request in the list (usually the page itself)
  • In the right panel, find Request Headers → Cookie: → right-click → Copy value
  • Set it as LARK_COOKIE in your environment

⚠️ Do NOT use document.cookie in the Console or copy from Application → Cookies tab individually — neither method captures HttpOnly cookies (session, sl_session), which are required for authentication.

The server automatically refreshes the session via heartbeat every 4 hours. The sl_session cookie has a 12-hour max-age.

How to Set Up P2P Chat Reading (OAuth)

To read direct message history with read_p2p_messages and list_user_chats:

  • Your Feishu app must be a Custom App (自建应用), NOT marketplace/third-party
  • Add scopes: im:message, im:message:readonly, im:chat:readonly
  • In your app's Security Settings (安全设置), add the OAuth redirect URI: http://127.0.0.1:9997/callback
  • Important: Make sure "对外共享" (external sharing) is disabled in your app version settings — enabling it marks the app as b2c/b2b type, which blocks P2P chat access
  • Run the authorization flow:
# If you cloned the repo:
node src/oauth.js

# If you installed via npx:
cd $(npm root -g)/feishu-user-mcp && node src/oauth.js
# Or clone the repo just for the OAuth step, then use npx for daily use

A browser window will open for OAuth consent. The token is saved to .env automatically and auto-refreshes at runtime. Add the resulting LARK_USER_ACCESS_TOKEN to your .mcp.json env.

MCP Client Configuration

Claude Code

Add to your project's .mcp.json (or ~/.claude/.mcp.json for global):

Using npx:

{
  "mcpServers": {
    "feishu": {
      "command": "npx",
      "args": ["-y", "feishu-user-mcp"],
      "env": {
        "LARK_COOKIE": "your-cookie-string",
        "LARK_APP_ID": "cli_xxxxxxxxxxxx",
        "LARK_APP_SECRET": "your-app-secret"
      }
    }
  }
}

Using a local clone:

{
  "mcpServers": {
    "feishu": {
      "command": "node",
      "args": ["/absolute/path/to/feishu-user-mcp/src/index.js"],
      "env": {
        "LARK_COOKIE": "your-cookie-string",
        "LARK_APP_ID": "cli_xxxxxxxxxxxx",
        "LARK_APP_SECRET": "your-app-secret"
      }
    }
  }
}

Then just say things like:

  • "Send a message to Alice saying the meeting is at 3pm"
  • "What did the engineering group chat about today?"
  • "Search for docs about MCP"

Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):

{
  "mcpServers": {
    "feishu": {
      "command": "npx",
      "args": ["-y", "feishu-user-mcp"],
      "env": {
        "LARK_COOKIE": "your-cookie-string",
        "LARK_APP_ID": "cli_xxxxxxxxxxxx",
        "LARK_APP_SECRET": "your-app-secret"
      }
    }
  }
}

Cursor

Add to .cursor/mcp.json in your project:

{
  "mcpServers": {
    "feishu": {
      "command": "npx",
      "args": ["-y", "feishu-user-mcp"],
      "env": {
        "LARK_COOKIE": "your-cookie-string",
        "LARK_APP_ID": "cli_xxxxxxxxxxxx",
        "LARK_APP_SECRET": "your-app-secret"
      }
    }
  }
}

VS Code (Copilot)

Add to .vscode/mcp.json in your project:

{
  "servers": {
    "feishu": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "feishu-user-mcp"],
      "env": {
        "LARK_COOKIE": "your-cookie-string",
        "LARK_APP_ID": "cli_xxxxxxxxxxxx",
        "LARK_APP_SECRET": "your-app-secret"
      }
    }
  }
}

Windsurf

Add to ~/.codeium/windsurf/mcp_config.json:

{
  "mcpServers": {
    "feishu": {
      "command": "npx",
      "args": ["-y", "feishu-user-mcp"],
      "env": {
        "LARK_COOKIE": "your-cookie-string",
        "LARK_APP_ID": "cli_xxxxxxxxxxxx",
        "LARK_APP_SECRET": "your-app-secret"
      }
    }
  }
}

Tools (33 total)

Send messages as yourself, not as a bot.

ToolDescription
send_to_userSearch user by name + send text -- one step
send_to_groupSearch group by name + send text -- one step
send_as_userSend text to any chat by ID, supports reply threading (root_id / parent_id)
send_image_as_userSend image (requires image_key from upload)
send_file_as_userSend file (requires file_key from upload)
send_post_as_userSend rich text with title + formatted paragraphs (links, @mentions)
send_sticker_as_userSend sticker/emoji
send_audio_as_userSend audio message
ToolDescription
search_contactsSearch users, bots, or group chats by name
create_p2p_chatCreate/get P2P (direct message) chat, returns numeric chat_id
get_chat_infoGroup details: name, description, member count, owner
get_user_infoUser display name lookup by user ID
get_login_statusCheck cookie, app credentials, and UAT status

User OAuth UAT -- P2P Chat Reading

ToolDescription
read_p2p_messagesRead P2P (direct message) history. Works for chats the bot cannot access.
list_user_chatsList all chats the user is in, including P2P.

Official API -- IM (Bot Identity)

ToolDescription
list_chatsList all chats the bot has joined
read_messagesRead message history (accepts chat name or oc_xxx ID)
reply_messageReply to a specific message by message_id (as bot)
forward_messageForward a message to another chat

Official API -- Documents

ToolDescription
search_docsSearch documents by keyword
read_docRead raw text content of a document
create_docCreate a new document

Official API -- Bitable (Spreadsheets)

ToolDescription
list_bitable_tablesList all tables in a Bitable app
list_bitable_fieldsList all fields (columns) in a table
search_bitable_recordsQuery records with filter and sort
create_bitable_recordCreate a new record (row)
update_bitable_recordUpdate an existing record

Official API -- Wiki

ToolDescription
list_wiki_spacesList all accessible wiki spaces
search_wikiSearch wiki/docs by keyword
list_wiki_nodesBrowse wiki node tree

Official API -- Drive

ToolDescription
list_filesList files in a folder
create_folderCreate a new folder

Official API -- Contacts

ToolDescription
find_userFind user by email or mobile number

Claude Code Slash Commands (8 skills)

This repo includes 8 ready-to-use slash commands in .claude/commands/:

SkillUsageDescription
/send/send Alice: meeting at 3pmSend message as yourself
/reply/reply engineering-chatRead recent messages and reply
/digest/digest engineering-chat 7Summarize recent chat messages
/search/search engineeringSearch contacts and groups
/doc/doc search MCPSearch, read, or create documents
/table/table query appXxxQuery or create Bitable records
/wiki/wiki search protocolSearch and browse wiki
/status/statusCheck login and auth status

To use these skills, copy .claude/commands/ into your project.

Architecture

                               Cookie + Proto   ┌──────────────────────────────────────┐
                             ────────────────── >│  internal-api-lark-api.feishu.cn     │
┌──────────────┐                                 │  /im/gateway/ (Protobuf over HTTP)   │
│  MCP Client  │                                 └──────────────────────────────────────┘
│  (Claude,    │  App Token (REST) ┌──────────────────────────────────────┐
│   Cursor,    │ ────────────────->│  open.feishu.cn/open-apis/           │
│   VS Code)   │                   │  (Official REST API)                 │
│              │                   └──────────────────────────────────────┘
│              │  User OAuth (REST)┌──────────────────────────────────────┐
│              │ ────────────────->│  open.feishu.cn/open-apis/           │
└──────────────┘                   │  (UAT -- P2P chat reading)           │
                                   └──────────────────────────────────────┘

Session & Token Lifecycle

Auth LayerTokenLifetimeRefresh
Cookiesl_session12h max-ageAuto-refreshed every 4h via heartbeat
App Tokentenant_access_token2hAuto-managed by SDK
User OAuthuser_access_token~2hAuto-refreshed via refresh_token, saved to .env

When the cookie expires (after ~12-24h without heartbeat), re-login at feishu.cn and update LARK_COOKIE. Use get_login_status to check health proactively.

Project Structure

feishu-user-mcp/
├── src/
│   ├── index.js          # MCP server entry point (33 tools)
│   ├── client.js         # User identity client (Protobuf gateway)
│   ├── official.js       # Official API client (REST, UAT)
│   ├── utils.js          # ID generators, cookie parser
│   ├── oauth.js          # OAuth flow for user_access_token
│   ├── oauth-auto.js     # Automated OAuth with Playwright
│   ├── test-send.js      # Quick CLI test
│   └── test-all.js       # Full test suite
├── proto/
│   └── lark.proto        # Protobuf message definitions
├── .claude/
│   └── commands/         # 8 Claude Code slash commands
├── server.json           # MCP Registry manifest
├── .env.example          # Configuration template
└── package.json

Limitations

  • Cookie-based auth requires periodic refresh (auto-heartbeat extends to ~12h; manual re-login needed after that)
  • Depends on Feishu's internal Protobuf protocol -- may break if Feishu updates their web client
  • Image/file/audio sending requires pre-uploaded keys (upload via Official API or external bridge)
  • No real-time message receiving (WebSocket push not yet implemented)
  • May violate Feishu's Terms of Service -- use at your own risk

Contributing

Issues and PRs welcome! See CONTRIBUTING.md for development setup, code style, and submission guidelines.

If Feishu updates their protocol and something breaks, please open an issue with the error details.

License

MIT

Acknowledgments

Keywords

feishu

FAQs

Package last updated on 09 Mar 2026

Related posts