Skip to main content
Glama
joaovjo

linkedin-mcp-server-ts

by joaovjo

LinkedIn MCP Server (TypeScript / Bun)

免责声明: 这是一个由社区驱动的独立开源项目。它不隶属于 LinkedIn 公司或微软公司,也未经其赞助、授权或认可。“LinkedIn”是 LinkedIn 公司的注册商标,此处仅作描述性使用。

一个极速、轻量的 Model Context Protocol (MCP) 服务器,用于 LinkedIn 自动化和数据抓取,使用 TypeScript 重写,并由 Bun 运行时驱动。

它为 AI 助手(如 Claude Desktop、Cursor、OpenCode、VS Code 和 Windsurf/Antigravity)提供 19 个生产级 MCP 工具,以便浏览个人资料、搜索职位和公司、与消息交互,并使用你已认证的浏览器会话提取信息流。


⚡ 为什么选择 TypeScript + Bun?

linkedin-mcp-server-ts 是 stickerdaniel/linkedin-mcp-server 的原生 TypeScript/Bun 移植版本,旨在实现最高效率并占用最小的资源:

  • 🚀 即时启动与近乎零开销:Bun 的原生 JIT 和快速的包执行消除了冷启动延迟。

  • 🌐 原生 WebView 与直接 CDP 引擎:通过直接 Chrome DevTools Protocol (CDP) 和 Bun.WebView 自动化 Chromium,无需笨重的外部浏览器守护进程层。

  • 🔄 100% 契约与模式一致性:与 Python MCP 服务器工具、模式和返回格式完全 1:1 即插即用替代。

  • 🔑 无缝会话共享:与标准的 ~/.linkedin-mcp/profile 会话存储和 cookie 格式 100% 兼容。

架构对比

特性

Python 版本(mcp-server-linkedin)

TypeScript / Bun 版本(linkedin-mcp-server-ts)

运行时

Python 3.10+(uv / uvx)

Bun 1.2+(bun / bunx)

语言

Python(fastmcp)

TypeScript 6(@modelcontextprotocol/server v2)

浏览器引擎

Patchright Chromium 分支

原生 Bun.WebView + 直接 Chrome DevTools Protocol (CDP)

内存 / 占用

中等(约 150MB+ 运行时)

超轻量(约 30-60MB 基准)

传输方式

stdio, streamable-http

stdio, streamable-http(通过原生 Bun.serve)

会话目录

~/.linkedin-mcp/profile

~/.linkedin-mcp/profile(共享且可互操作)

验证

Pydantic

Zod 模式

工具数量

19 个工具

19 个工具


Related MCP server: LinkedIn MCP Pro Max

🛠️ MCP 工具概览(19 个工具)

工具

类别

描述

访问类型

get_person_profile

人脉

提取个人资料的详细信息,包含细分的板块(经历、教育背景、技能、项目、证书、动态等)

只读

get_my_profile

人脉

提取当前登录用户的个人资料

只读

search_people

人脉

按关键词、地点、人脉度数(F=1 度、S=2 度、O=3 度及以上)以及当前公司搜索人员

只读

connect_with_person

人脉

发送连接请求或接受邀请,并可附带个性化的备注

写入 / 操作

get_sidebar_profiles

人脉

提取侧边栏推荐的个人资料链接(“你可能认识的人”、“更多资料”)

只读

get_company_profile

公司

提取公司详细信息、关于我们、动态、职位以及公司 URN 数字 ID

只读

get_company_posts

公司

获取公司最近的信息流动态

只读

search_companies

公司

按关键词搜索公司

只读

get_company_employees

公司

从 /people/ 板块列出公司员工,支持可选筛选条件

只读

get_job_details

职位

获取特定职位发布的完整详情和描述

只读

search_jobs

职位

按筛选条件搜索职位:关键词、地点、发布日期、职位类型、工作性质、经验级别、便捷申请

只读

get_saved_jobs

职位

获取当前登录用户保存的职位列表

只读

get_inbox

消息

列出消息收件箱中的最近会话线程

只读

get_conversation

消息

按用户名或 thread_id 读取会话中的消息

只读

search_conversations

消息

按关键词搜索消息会话

只读

send_message

消息

发送 LinkedIn 私信(需要 confirm_send: true 以进行安全的两步确认)

写入 / 操作

get_feed

信息流

获取首页时间线上的最近动态

只读

search_posts

信息流

在 LinkedIn 动态中进行全局搜索,支持时间筛选(past-24h、past-week、past-month)

只读

close_session

会话

优雅地终止浏览器会话并清理后台资源

写入 / 操作


🚀 快速开始

前置要求

  1. 安装 Bun(v1.2 或更高版本):

    # Windows (PowerShell)
    powershell -c "irm bun.sh/install.ps1 | iex"
    
    # macOS / Linux
    curl -fsSL https://bun.sh/install | bash
  2. Google Chrome / Chromium:已安装在你的系统上。

单命令执行(bunx)

你可以使用 bunx 直接运行服务器,无需手动安装:

bunx linkedin-mcp-server-ts

本地克隆与开发设置

# Clone the repository
git clone https://github.com/joaovjo/linkedin-mcp-server-ts.git
cd linkedin-mcp-server-ts

# Install dependencies
bun install

# Start the server (stdio mode for MCP clients)
bun run start

# Start the HTTP server (for web MCP debugging)
bun run dev

💻 MCP 客户端配置

1. Claude Desktop

添加到你的 claude_desktop_config.json:

  • Windows: %APPDATA%\Claude\claude_desktop_config.json

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

  • Linux: ~/.config/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "linkedin": {
      "command": "bunx",
      "args": ["linkedin-mcp-server-ts"]
    }
  }
}

或者从本地克隆运行时:

{
  "mcpServers": {
    "linkedin": {
      "command": "bun",
      "args": ["run", "src/index.ts"],
      "cwd": "D:/linkedin/linkedin-mcp-server-ts"
    }
  }
}

2. Cursor

添加到你的项目 .cursor/mcp.json 或全局 Cursor 设置中:

{
  "mcpServers": {
    "linkedin": {
      "command": "bunx",
      "args": ["linkedin-mcp-server-ts"]
    }
  }
}

3. OpenCode

添加到你的 opencode.json(或 ~/.config/opencode/opencode.json):

{
  "mcp": {
    "linkedin": {
      "type": "stdio",
      "command": "bunx",
      "args": ["linkedin-mcp-server-ts"]
    }
  }
}

4. Antigravity / Windsurf / VS Code(Cline / Roo Code)

添加到 mcp_config.json:

{
  "mcpServers": {
    "linkedin": {
      "command": "bunx",
      "args": ["linkedin-mcp-server-ts"],
      "disabled": false,
      "autoApprove": []
    }
  }
}

5. Streamable HTTP 模式

要通过 HTTP 暴露服务器以供远程代理或容器化环境使用:

bun run src/index.ts --transport streamable-http --host 127.0.0.1 --port 8000

端点 URL:http://127.0.0.1:8000/mcp
健康检查:http://127.0.0.1:8000/health


🔐 认证与会话管理

服务器使用存储在 ~/.linkedin-mcp/profile 的持久化浏览器配置文件,因此你只需认证一次。

选项 A:从日常浏览器自动导入(最快)

如果你已经在浏览器(Chrome、Brave、Edge、Arc、Vivaldi)中登录了 LinkedIn,可以立即导入你的会话:

# Auto-detect the most recent browser session
bunx linkedin-mcp-server-ts --import-from-browser

# Or specify a target browser
bunx linkedin-mcp-server-ts --import-from-browser brave
bunx linkedin-mcp-server-ts --import-from-browser chrome
bunx linkedin-mcp-server-ts --import-from-browser edge

选项 B:交互式可视化登录

启动一个交互式 Chrome 窗口进行登录:

bunx linkedin-mcp-server-ts --login
# Or from local source:
bun run login
  1. 将打开一个 Chrome 浏览器窗口,进入 LinkedIn 登录页面。

  2. 完成登录(如果提示,包括两步验证 / 验证码)。

  3. 服务器检测到成功导航到你的信息流后,会安全地保存你的会话配置文件。

检查会话状态

bunx linkedin-mcp-server-ts --status
# Or from local source:
bun run status

退出并清除会话

bunx linkedin-mcp-server-ts --logout
# Or from local source:
bun run logout

⚙️ 配置与环境变量

在根目录创建 .env 文件(或传入 CLI 参数)以自定义行为:

变量

CLI 标志

默认值

描述

USER_DATA_DIR

--user-data-dir

~/.linkedin-mcp/profile

持久化浏览器配置文件目录的路径

HEADLESS

--headless / --no-headless

true

以无头模式运行浏览器

TRANSPORT

--transport

stdio

传输协议:stdio 或 streamable-http

HOST

--host

127.0.0.1

HTTP 绑定主机

PORT

--port

8000

HTTP 端口

HTTP_PATH

--path

/mcp

HTTP 端点路径

TIMEOUT

--timeout

5000

DOM 导航/交互超时时间(毫秒)

TOOL_TIMEOUT

--tool-timeout

180

每个工具的 MCP 执行超时时间(秒)

LOGIN_TIMEOUT

--login-timeout

1800

--login 期间的最大等待时间(秒)

LOGIN_INLINE_WAIT

--login-inline-wait

25

内联认证回退的等待时间(秒)

AUTO_IMPORT_FROM_BROWSER

--auto-import / --no-auto-import

true

如果不存在配置文件,则自动导入 Cookie

CHROME_PATH

--chrome-path

""(自动检测)

Chrome/Chromium 可执行文件的自定义路径

USER_AGENT

--user-agent

""

可选的自定义浏览器 User-Agent 覆盖值

VIEWPORT

--viewport

1280x720

浏览器视口尺寸(WIDTHxHEIGHT)

DEBUG_PORT

--debug-port

9222

--login 期间使用的 Chrome 远程调试端口

LOG_LEVEL

--log-level

WARNING

日志级别(DEBUG、INFO、WARNING、ERROR)


🧪 开发、测试与质量

运行契约与单元测试

运行完整测试套件,验证所有 19 个工具、模式校验、链接元数据分类器以及错误处理:

bun test

代码检查与格式化

代码风格和格式化由 Biome 强制执行:

# Check code for lint issues
bun run lint

# Auto-fix formatting and linting
bun run lint:fix

# Format files
bun run format

项目架构

linkedin-mcp-server-ts/
├── src/
│   ├── index.ts               # CLI Entrypoint & Transport routing (stdio / HTTP)
│   ├── config.ts              # CLI flags & environment configuration
│   ├── browser/
│   │   ├── auth.ts            # Login, logout, status, and browser cookie importer
│   │   ├── cdp.ts             # Direct Chrome DevTools Protocol helper functions
│   │   ├── chrome-launch.ts   # Process launcher for visual login & remote attach
│   │   ├── manager.ts         # Bun.WebView & CDP lifecycle manager
│   │   └── types.ts           # Browser status types
│   ├── errors/                # Unified error handling & custom error hierarchy
│   ├── mcp/
│   │   └── create-server.ts   # MCP Server registration & tool mounting
│   ├── middleware/            # Concurrency serialization queue
│   ├── scraping/              # DOM extraction, noise removal, link classification & URNs
│   ├── session/               # Cookie storage, profile directories, and persistence
│   ├── tools/                 # 19 MCP tool implementations
│   └── utils/                 # General helpers
├── tests/                     # Bun test suite & contract validations
├── bunfig.toml                # Bun configuration & npm publish registry settings
└── package.json               # Package metadata, dependencies, and scripts

📦 发布到 NPM

本项目使用 bunfig.toml 通过 Bun 直接发布到 npm 仓库:

# Verify typecheck & tests pass
bun test
bun run lint

# Publish public package
bun publish

🤝 贡献

欢迎贡献、错误报告和 Pull Request!

  1. 在 GitHub 上复刻仓库:https://github.com/joaovjo/linkedin-mcp-server-ts

  2. 创建功能分支:git checkout -b feature/amazing-feature

  3. 提交你的更改:git commit -m 'feat: add amazing feature'

  4. 确保所有测试通过:bun test && bun run lint

  5. 推送到分支:git push origin feature/amazing-feature

  6. 打开一个 Pull Request。


📄 许可证与致谢

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    D
    maintenance
    Fully featured MCP server that provides automation tools for LinkedIn, supporting browser-based scraping and API-based operations for content management, media uploads, and reactions.
    6
    3
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    High-performance autonomous MCP server that turns LinkedIn into an API for AI workflows, enabling profile management, job search, content posting, and document generation.
    14
    1
    MIT
  • A
    license
    A
    quality
    C
    maintenance
    Self-hosted, ban-safe MCP server for LinkedIn that provides 22 tools for profiles, search, jobs, posts, connections, and messages. Integrates with any MCP-compatible client like Claude Desktop.
    58
    1
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    MCP server for programmable LinkedIn automation via Playwright, offering 20 tools for profile management, messaging, feed interaction, and job searching through real browser automation.
    17 npm
    MIT