使用说明
LinkedIn自动化MCP服务器
用于LinkedIn自动化任务的完整端到端模型上下文协议(MCP)服务器。此服务器提供用于自动化各种LinkedIn活动的工具,包括登录、搜索、连接请求、消息传递、发布和数据提取。
特性
- 认证:使用会话管理安全登录LinkedIn
- 人员搜索:使用各种过滤器搜索LinkedIn用户
- 连接管理:发送带有自定义消息的连接请求
- 消息传递:向连接发送直接消息
- 内容创建:创建和发布LinkedIn帖子
- 参与:对帖子点赞和评论
- 数据提取:提取个人资料和公司信息
- 速率限制:内置速率限制以避免检测
- 错误处理:全面的错误处理和记录
安装
先决条件
- Python 3.8或更高版本
- 已安装Chrome浏览器
- 领英账号
设置
-
克隆或下载项目文件
-
安装依赖项:
pip install -r requirements.txt -
安装Chrome WebDriver (由Web驱动程序管理器自动处理)
用法
启动服务器
python linkedin_mcp_server.py
可用工具
1.LinkedIn登录
{
"name": "linkedin_login",
"arguments": {
"email": "your-email@example.com",
"password": "your-password",
"headless": false
}
}
2.搜索人员
{
"name": "linkedin_search_people",
"arguments": {
"keywords": "software engineer",
"location": "San Francisco",
"company": "Google",
"max_results": 50
}
}
3.发送连接请求
{
"name": "linkedin_connect_with_person",
"arguments": {
"profile_url": "https://www.linkedin.com/in/username/",
"message": "Hi, I'd like to connect!",
"note": "I saw your profile and thought we could connect."
}
}
4.发送消息
{
"name": "linkedin_send_message",
"arguments": {
"profile_url": "https://www.linkedin.com/in/username/",
"message": "Hello! How are you?",
"subject": "Greeting"
}
}
5.创建帖子
{
"name": "linkedin_post_content",
"arguments": {
"content": "Excited to share my latest project!",
"visibility": "public",
"hashtags": ["automation", "linkedin", "networking"]
}
}
6.喜欢帖子
{
"name": "linkedin_like_post",
"arguments": {
"post_url": "https://www.linkedin.com/posts/activity-123"
}
}
7.对帖子的评论
{
"name": "linkedin_comment_on_post",
"arguments": {
"post_url": "https://www.linkedin.com/posts/activity-123",
"comment": "Great post! Thanks for sharing."
}
}
8.提取个人资料信息
{
"name": "linkedin_get_profile_info",
"arguments": {
"profile_url": "https://www.linkedin.com/in/username/"
}
}
9.提取公司信息
{
"name": "linkedin_scrape_company_info",
"arguments": {
"company_url": "https://www.linkedin.com/company/company-name/"
}
}
10.注销
{
"name": "linkedin_logout",
"arguments": {}
}
配置
服务器使用 config.json 对于配置设置:
- 浏览器设置:无头模式、用户代理、窗口大小
- 自动化设置:延迟、重试、速率限制
- LinkedIn网址:各种LinkedIn页面URL
- CSS选择器:自动化元件选择器
安全和最佳实践
速率限制
- 内置速率限制以避免LinkedIn的检测
- 操作之间的可配置延迟
- 每分钟最大请求数设置
会话管理
- 安全登录处理
- 注销时自动清理会话
- 浏览器实例管理
错误处理
- 全面的错误捕获和报告
- 优雅的故障处理
- 调试详细日志记录
故障排除
常见问题
-
登录失败
- 检查凭据
- 确保禁用或处理2FA
- 尝试无头模式
-
未找到元素
- LinkedIn可能已经更新了他们的用户界面
- 检查config.json中的选择器
- 增加操作之间的延迟
-
速率限制
- 降低请求频率
- 增加行动之间的延迟
- 使用无头模式
-
浏览器问题
- 更新Chrome浏览器
- 清除浏览器缓存
- 检查ChromeDriver兼容性
调试模式
通过修改代码中的日志级别启用调试日志记录:
logging.basicConfig(level=logging.DEBUG)
法律和伦理考虑
⚠️ 重要:此工具仅用于教育和合法商业目的。
- 尊重LinkedIn的服务条款
- 不要发送垃圾邮件或骚扰用户
- 在行动之间使用合理的延迟
- 不要超过LinkedIn的费率限制
- 尊重用户隐私和同意
贡献
- 分叉存储库
- 创建要素分支
- 进行更改
- 如果适用,添加测试
- 提交拉取请求
许可证
此项目根据MIT许可证获得许可-有关详细信息,请参阅许可证文件。
支持
对于问题和疑问:
- 检查故障排除部分
- 查看日志以了解错误详细信息
- 用详细信息创建问题
更新日志
版本1.0.0
- 初始版本
- 完整的LinkedIn自动化功能
- MCP服务器实现
- 全套工具
- 配置管理