Lark MCP
Supports containerized deployment of the Lark MCP server through Docker, facilitating easy setup and consistent runtime environments
Uses .env file for configuration management, allowing easy setup of API keys, database credentials, and other environment-specific settings
Provides integration for issue tracking and project discussions through GitHub's issue system and discussion forums
Stores message data in MySQL database with functionality to query message history and user activity statistics
Utilizes Node.js for specific components like the Lark decryption utility, enabling secure communication with the Lark API
Integrates with OpenAI's API for AI model access, supporting function calls and processing natural language requests from Lark messages
Built on Python with support for async/await patterns, providing the core runtime environment for the MCP server functionality
Uses Shields.io for generating status badges in documentation to display version requirements and build status
Leverages SQLAlchemy for database operations, enabling structured data storage and retrieval of message data and interaction history
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Lark MCPwhat's the weather in Beijing today?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Lark Agentx - Your Feishu AI Assistant 🚀
An AI Agent based on Feishu (Lark) that enables large models to perform function calls and message processing via Feishu.
No Feishu bot configuration required; your Feishu account acts as the AI assistant.
Simply define functions and comments, and your Feishu bot will automatically call them based on the context.
Project Overview 🌟
Lark Agentx is a modern Python application capable of:
📊 Reverse-engineering Websockets and APIs transmitting in Feishu Protobuf format to listen to and record messages
🤖 Providing custom functions for large models to call
🔄 Implementing a function-calling framework based on MCP (Model Context Protocol)
💾 Storing messages in a MySQL database using SQLAlchemy
Related MCP server: Feishu MCP Server
Screenshots 🧸
✨ Features
Function Registration Mechanism: Simple and intuitive function registration decorator
Automatic Message Processing: Records all received messages (private and group chats)
Asynchronous Processing: Uses async/await pattern for asynchronous communication
Data Persistence: Uses SQLAlchemy to store messages in a MySQL database
Flexible Configuration: Configurable via environment variables
Containerized Deployment: Supports rapid deployment via Docker
Intelligent Function Calling: The AI automatically analyzes user input and calls the most relevant function; developers only need to add the function and its comment description
📦 Currently Supported Functions
The project currently includes the following built-in functions for large models to call:
Function Name | Description |
| Tell a random joke |
| Get the current time |
| Draw a random fortune |
| Get weather for a city |
| Get statistics on the number of speakers today |
| Get the user who spoke the most today |
| Send a message to a specified user |
| List all available tools and their descriptions |
| Extract order information from text, including order number, product name, quantity, etc. |
You can call these functions by entering a trigger command in Feishu followed by the operation, for example: /run tell a joke
📂 Project Structure
project/
├── app/ # 应用程序模块
│ ├── api/ # API相关模块
│ │ ├── auth.py # 认证模块
│ │ └── lark_client.py # 飞书客户端
│ ├── config/ # 配置模块
│ │ └── settings.py # 应用配置
│ ├── core/ # 核心业务逻辑
│ │ ├── mcp_server.py # MCP服务器(函数注册和处理)
│ │ ├── llm_service.py # LLM服务
│ │ └── message_service.py # 消息处理服务
│ ├── db/ # 数据库相关
│ │ ├── models.py # 数据模型
│ │ └── session.py # 数据库会话管理
│ └── utils/ # 工具函数
├── builder/ # 请求构建器
├── extension/ # 扩展功能
│ └── weather_api/ # 天气API集成
├── static/ # 静态资源
│ ├── resource/ # 图片资源
│ ├── proto_pb2.py # 协议定义
│ └── lark_decrypt.js # 飞书解密工具
├── .env # 环境变量
├── main.py # 应用入口
├── requirements.txt # 项目依赖
├── docker-compose.yml # Docker Compose配置
└── Dockerfile # Docker配置🛠️ Custom Function Development
In the app/core/mcp_server.py file, you can add your own custom functions using the @register_tool decorator:
@register_tool(name="tell_joke", description="讲一个随机笑话")
def tell_joke() -> str:
jokes = [
"为什么程序员都喜欢黑色?因为他们不喜欢 bug 光。",
"Python 和蛇有什么共同点?一旦缠上你就放不下了。",
"为什么 Java 开发者很少被邀去派对?因为他们总是抛出异常。",
]
return random.choice(jokes)
@register_tool(name="send_message", description="给指定用户发送消息 {user:用户名称 content:消息内容}")
def send_message(user: str, content: str) -> str:
"""给指定用户发送私信"""
lark_client = LarkClient(get_auth())
# ... 实现逻辑 ...
return f"成功向 {user} 发送了私信: '{content}'"Important: Simply add the function and its corresponding description; the AI will automatically analyze and call the most matching function based on the user's text, with no need to manually implement function matching logic.
🔧 Requirements
Python 3.10+
Node.js 18+
MySQL Database
📦 Installation
Using Local Environment
Install dependencies:
pip install -r requirements.txtNote for Windows users: Windows systems require additional dependencies:
pip install win-inet-pton==1.1.0
Using Docker
Method 1: Build image separately
# 构建镜像
docker build -t feishuapp .
# 运行容器 需要外部mysql 通过docker网关连接宿主机mysql 推荐--env-file
docker run -it feishuapp bashMethod 2: Use Docker Compose (Recommended)
# 启动所有服务(应用和数据库)
docker-compose up -d
# 查看日志
docker-compose logs -f
# 停止所有服务
docker-compose downUsing Docker Compose allows you to start the entire application environment with one click, including the MySQL database and application services, which is more convenient and efficient.
🛠️ Configuration
Copy the .env.example file and rename it to .env, containing the following configuration:
# 数据库设置
DB_HOST=localhost
DB_PORT=3306
DB_USER=root
DB_PASSWORD=123456
DB_NAME=lark_messages
# 飞书的Cookie设置 - 只需配置LARK_COOKIE即可,告别飞书机器人
LARK_COOKIE=""
# 调用函数的触发前缀 (以FUNCTION_TRIGGER_FLAG开头的消息会被大模型解析,所有消息都会被记录到数据库,无论是否以该前缀开头)
FUNCTION_TRIGGER_FLAG="/run"
# 机器人发言前缀 (暂未使用)
AI_BOT_PREFIX="Lark AI Bot:"
# OpenAI API配置 默认是通义千问的,满足OpenAI的大模型厂商都可以
OPENAI_API_KEY=""
OPENAI_API_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1"
OPENAI_API_MODEL="qwen-plus"🚀 Usage Guide
Running the Application
Method 1: Run directly
python main.pyMethod 2: Use Docker Compose
docker-compose up -dThe application will:
Initialize the MCP server
Connect to the Feishu API and use your Feishu account as the AI assistant
Listen for incoming messages
Process and execute function calls initiated by the large model via Feishu
Store messages in the MySQL database
🗄️ Database Schema
The application stores messages in the messages table, which has the following structure:
Column Name | Type | Description |
id | INT (PK) | Primary Key |
user_name | VARCHAR(255) | Name of the message sender |
user_id | VARCHAR(255) | Feishu User ID of the sender |
content | TEXT | Message content |
is_group_chat | BOOLEAN | Whether the message is from a group chat |
group_name | VARCHAR(255) | Group chat name (if applicable) |
chat_id | VARCHAR(255) | Chat ID |
message_time | DATETIME | Message timestamp |
created_at | DATETIME | Record creation time |
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Fork this repository
Create your feature branch (
git checkout -b feature/amazing-feature)Commit your changes (
git commit -m 'Add some amazing features')Push to the branch (
git push origin feature/amazing-feature)Open a Pull Request
🐛 Issues and Support
If you encounter any problems or have questions, please submit an issue or visit our discussion forum.
📈 Star Trend
🍔 Community Group
If you are interested in web scraping and AI Agents, please add the author's WeChat from their homepage to be invited to the group chat.
ps: Please join Group 7; if full or expired, please leave an issue | WeChat reminder

This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceA zero-configuration MCP server enabling AI assistants to interact with Feishu (Lark) workspace through OAuth authentication, supporting document operations, content creation, and advanced file management.37MIT
- AlicenseNot gradedqualityFmaintenanceA remote Model Context Protocol server for Feishu (Lark) that supports OAuth authentication and deployment on Cloudflare Workers. It allows AI clients to interact with Feishu documents, perform content searches, and manage document blocks with a zero-configuration experience.85MIT
- AlicenseBqualityFmaintenanceAn MCP server that exposes Feishu/Lark capabilities as function tools to MCP-compatible agents like Hermes and Claude Desktop. It provides 57 tools for messaging, document management, calendar operations, and task management through both hand-written fallback tools and bridged OpenClaw SDK functionality.531MIT
- AlicenseNot gradedqualityDmaintenanceMCP server that pushes Feishu (Lark) messages to Claude Code sessions and allows Claude to reply directly in Feishu.2MIT
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
MCP server for AI dialogue using various LLM models via AceDataCloud
A Model Context Protocol server for Wix AI tools
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/cv-cat/LarkAgentX'
If you have feedback or need assistance with the MCP directory API, please join our Discord server