LinkedIn浏览器自动化服务器

一个基于FastMCP的LinkedIn浏览器自动化服务器,用于程序化地与LinkedIn交互,包括个人资料操作、帖子互动等功能,同时遵守LinkedIn的服务条款和速率限制。

  • by alinaqi
  • Python
  • 本地部署
  • 55 星标
  • 更新于
在 GitHub 查看 alinaqi/mcp-linkedin-server

使用说明

LinkedIn浏览器MCP服务器

基于FastMCP的服务器,用于LinkedIn自动化和使用浏览器自动化的数据提取。该服务器提供了一组工具,用于以编程方式与LinkedIn交互,同时遵守LinkedIn的服务条款和费率限制。

特性

  • 安全认证

    • 基于环境的凭证管理
    • 使用加密cookie存储的会话持久性
    • 速率限制保护
    • 自动会话恢复
  • 配置文件操作

    • 查看和提取配置文件信息
    • 根据关键字搜索个人资料
    • 浏览LinkedIn订阅源
    • 个人资料访问能力
  • 帖子互动

    • 喜欢帖子
    • 对帖子的评论
    • 阅读帖子内容和参与度指标

先决条件

  • Python 3.8+
  • 剧作家
  • FastMCP库
  • 领英账号

安装

  1. 克隆存储库:
git clone [repository-url]
cd mcp-linkedin-server
  1. 创建并激活虚拟环境:
python -m venv env
source env/bin/activate  # On Windows: env\Scripts\activate
  1. 安装依赖项:
pip install -r requirements.txt
playwright install chromium
  1. 设置环境变量: 创建一个 .env 根目录中的文件,其中包含:
LINKEDIN_USERNAME=your_email@example.com
LINKEDIN_PASSWORD=your_password
COOKIE_ENCRYPTION_KEY=your_encryption_key  # Optional: will be auto-generated if not provided

用法

  1. 启动MCP服务器:
python linkedin_browser_mcp.py
  1. 可用工具:
  • login_linkedin_secure:使用环境凭据安全登录
  • browse_linkedin_feed:浏览并从提要中提取帖子
  • search_linkedin_profiles:搜索符合条件的配置文件
  • view_linkedin_profile:从特定配置文件中查看和提取数据
  • interact_with_linkedin_post:点赞、评论或阅读帖子

示例用法

from fastmcp import FastMCP

# Initialize client
client = FastMCP.connect("http://localhost:8000")

# Login
result = await client.login_linkedin_secure()
print(result)

# Search profiles
profiles = await client.search_linkedin_profiles(
    query="software engineer",
    count=5
)
print(profiles)

# View profile
profile_data = await client.view_linkedin_profile(
    profile_url="https://www.linkedin.com/in/username"
)
print(profile_data)

安全功能

  • 加密cookie存储
  • 速率限制保护
  • 安全的凭证管理
  • 会话持续
  • 浏览器自动化安全措施

最佳实践

  1. 速率限制:服务器实施速率限制以防止请求过多:

    • 每小时最多5次登录尝试
    • 自动会话重用
    • Cookie持久化以最大限度地减少登录需求
  2. 错误处理:全面的错误处理:

    • 网络问题
    • 身份验证失败
    • LinkedIn安全挑战
    • URL或参数无效
  3. 会话管理:

    • 自动cookie加密
    • 会话持续
    • 安全存储实践

贡献

  1. 分叉存储库
  2. 创建要素分支
  3. 提交您的更改
  4. 推到分支
  5. 创建拉取请求

许可证

麻省理工学院

免责声明

此工具仅用于教育目的。使用此软件时,确保遵守LinkedIn的服务条款和费率限制指南。