Skip to main content
Glama
README.md
# LinkedIn MCP Server

An MCP (Model Context Protocol) server that lets Claude Code post to LinkedIn, manage drafts, schedule posts, comment, react, and more — all from your terminal.

## What It Does

16 tools with a two-step safety system (every publish/delete requires explicit confirmation):

| Tool | What it does | Safety |
|------|-------------|--------|
| `linkedin_auth` | OAuth login via browser | — |
| `linkedin_status` | Check connection, token expiry, DB health | Read-only |
| `linkedin_drafts_list` | List all drafts (filter by tag) | Read-only |
| `linkedin_drafts_get` | Get full draft details | Read-only |
| `linkedin_posts_history` | View published post history | Read-only |
| `linkedin_schedule_list` | List scheduled posts | Read-only |
| `linkedin_drafts_save` | Save/update a draft | Requires "CONFIRM" |
| `linkedin_drafts_delete` | Delete a draft | Requires "CONFIRM" |
| `linkedin_schedule_add` | Schedule a draft for publishing | Requires "CONFIRM" |
| `linkedin_schedule_remove` | Cancel a scheduled post | Requires "CONFIRM" |
| `linkedin_react` | React to a post (LIKE, CELEBRATE, etc.) | Requires "CONFIRM" |
| `linkedin_comment` | Comment on a post | Requires "CONFIRM" |
| `linkedin_post` | Publish a post to LinkedIn | Requires "POST IT" |
| `linkedin_drafts_publish` | Publish a saved draft | Requires "POST IT" |
| `linkedin_delete` | Delete a published post | Requires "DELETE IT" |
| `linkedin_confirm` | Confirm any pending action | — |

## Setup (5 minutes)

### 1. Create a LinkedIn Developer App

1. Go to [linkedin.com/developers/apps](https://www.linkedin.com/developers/apps)
2. Click **Create app**
3. Fill in:
   - **App name**: anything (e.g. "My Claude MCP")
   - **LinkedIn Page**: link any company page you admin (or create one)
   - **App logo**: any image
4. Under **Auth** tab:
   - Add redirect URL: `http://localhost:8585/callback`
5. Under **Products** tab:
   - Request access to **Share on LinkedIn** and **Sign In with LinkedIn using OpenID Connect**
6. Copy your **Client ID** and **Client Secret** from the Auth tab

### 2. Clone & Build

```bash
git clone <this-repo-url> ~/linkedin-mcp-server
cd ~/linkedin-mcp-server
npm install
npm run build
```

### 3. Add to Claude Code

Open your Claude Code settings and add the MCP server. You can do this by running:

```bash
claude mcp add linkedin -- node /path/to/linkedin-mcp-server/dist/index.js
```

Or manually add to your Claude Code settings (`~/.claude.json` or via the Claude Code UI):

```json
{
  "mcpServers": {
    "linkedin": {
      "command": "node",
      "args": ["/full/path/to/linkedin-mcp-server/dist/index.js"],
      "env": {
        "LINKEDIN_CLIENT_ID": "your_client_id_here",
        "LINKEDIN_CLIENT_SECRET": "your_client_secret_here"
      }
    }
  }
}
```

Replace `/full/path/to/` with the actual path where you cloned the repo.

### 4. Authenticate

Restart Claude Code, then say:

> "authenticate with linkedin"

Claude will call `linkedin_auth`, which opens a browser window for OAuth. Authorize, and you're done. Token is stored locally at `~/.linkedin-mcp-tokens.json` (file permissions: 600).

## Usage

Just talk to Claude naturally:

- "Post this to LinkedIn: [your text]"
- "Save this as a draft: [text]"
- "Show me my drafts"
- "Schedule draft X for tomorrow at 3pm"
- "What's my LinkedIn connection status?"
- "React to [post-urn] with CELEBRATE"

Every action that touches LinkedIn requires you to confirm with a keyword. Nothing gets published without your explicit "POST IT".

## How It Works

- **OAuth 2.0**: Starts a local server on port 8585, opens LinkedIn auth in browser, catches the callback
- **SQLite storage**: Drafts, scheduled posts, and post history stored in `~/.linkedin-mcp/data.db`
- **Config**: Stored in `~/.linkedin-mcp/config.json` (scopes, API tier)
- **Token**: Stored in `~/.linkedin-mcp-tokens.json` (auto-expires)
- **Safety middleware**: Two-step confirmation for all write operations. High-risk actions (post, delete) need specific keywords ("POST IT", "DELETE IT")

## Configuration

The server auto-creates `~/.linkedin-mcp/config.json` on first run:

```json
{
  "scopes": ["openid", "profile", "w_member_social"],
  "api_tier": "consumer"
}
```

If you have Community Management API access, change `api_tier` to `"community_management"` to unlock comment and reaction tools beyond your own posts.

## Requirements

- Node.js 18+
- Claude Code (or any MCP-compatible client)
- A LinkedIn account with a Developer App