Skip to main content
Glama
README.md
# linkedin-mcp

![What LinkedIn's self-serve API really allows](assets/cover.png)

An MCP server that lets Claude (or any MCP client) publish to **your own** LinkedIn profile through the **official API**, plus publish articles to **dev.to**.

No scraping, no cookies, no browser automation. And an honest answer to the question every LinkedIn integration hits sooner or later: *what does the API actually let a self-serve app do?*

## What works (and what doesn't)

Tested live in December 2026 with a self-serve app (**Share on LinkedIn** + **Sign In with LinkedIn using OpenID Connect**), API version `202611`:

| Action | Endpoint | Result |
|---|---|---|
| Create a post (text, hashtags) | `POST /rest/posts` | ✅ works |
| Post with an image | `POST /rest/images?action=initializeUpload` + `PUT` | ✅ works |
| Delete your own post | `DELETE /rest/posts/{urn}` | ✅ works |
| Comment on a post | `POST /rest/socialActions/{urn}/comments` | ❌ 403 `partnerApiSocialActions.CREATE` |
| Reply to a comment | same, with `parentComment` | ❌ 403 |
| Like / react | `POST /rest/reactions` | ❌ 403 `partnerApiReactions` |
| Read comments | `GET /rest/socialActions/{urn}/comments` | ❌ 403 `partnerApiSocialActions.GET_ALL` |
| Read reactions on a post | `GET /rest/reactions/(entity:{urn})?q=entity` | ✅ works (returns member URNs, not names) |
| Read post metadata (counts) | `GET /rest/socialMetadata/{urn}` | ❌ 403 `partnerApiSocialMetadata.GET` |
| Read the feed, search people/posts | — | ❌ no public API |
| Post analytics | Community Management API | ❌ needs partner approval |

The docs list `w_member_social` as covering comments and reactions. In practice those calls are gated behind partner access. That's why this server only ships the tools that work. Run `linkedin_doctor` to see the result for your own app.

## Tools

| Tool | What it does |
|---|---|
| `linkedin_auth_status` | Is the account connected, days left on the token |
| `linkedin_login` | Connect / reconnect (opens LinkedIn's consent page) |
| `linkedin_create_post` | Post with an optional image from a local file. Hashtags stay clickable, reserved characters are escaped for LinkedIn's Little Text Format |
| `linkedin_delete_post` | Delete one of your posts |
| `linkedin_doctor` | Read-only diagnostics: token, image upload, and (given any post link) every read endpoint, with the exact status and permission LinkedIn reports. Publishes nothing |
| `devto_create_article` | Create a dev.to article, **draft by default** |
| `devto_update_article` | Edit or publish a draft |
| `devto_my_articles` | Your articles with views, reactions, comments |

Every publishing tool tells the model to publish only text the user has approved. Keep a human in the loop: it's your name on the post.

## Setup

### 1. LinkedIn app (about 10 minutes)
1. https://www.linkedin.com/developers/apps → **Create app**. LinkedIn requires a Company Page even for personal posting: pick one you admin, or create an empty one.
2. **Products** tab → request **Share on LinkedIn** and **Sign In with LinkedIn using OpenID Connect** (both self-serve, approved instantly).
3. **Auth** tab → copy Client ID and Primary Client Secret, and add the redirect URL `http://localhost:8765/callback`.

### 2. Install
```bash
git clone https://github.com/Nuprostochuvak/linkedin-mcp.git
cd linkedin-mcp
cp .env.example .env      # fill in LINKEDIN_CLIENT_ID / LINKEDIN_CLIENT_SECRET (and DEVTO_API_KEY if you want dev.to)
npm install
npm run check             # sanity-checks .env without printing secrets
npm run login             # browser opens → Allow → "Connected as …"
npm run install-claude    # adds the server to Claude Desktop's config (backs it up first)
```
Restart Claude Desktop. Tools appear as `linkedin_*` and `devto_*`.

Secrets stay on your machine: `.env` is git-ignored, the OAuth token lives in `~/.linkedin-mcp/token.json` (chmod 600). Tokens last ~60 days; `linkedin_login` renews.

### dev.to key
dev.to → Settings → Extensions → **DEV Community API Keys** → Generate. Put it in `.env` as `DEVTO_API_KEY`.

Cross-posting tip: Medium no longer issues API tokens. Publish on dev.to first, then use Medium's "Import a story" with the dev.to URL. Medium keeps the canonical link.

### Test without publishing
```bash
DRY_RUN=1 npm run post -- "Hello #LinkedIn" ./image.png
```

## Gotchas we hit, so you don't have to
- **Composite URNs in paths**: `encodeURIComponent` leaves `(` `)` unencoded and LinkedIn answers `400 Syntax exception in path variables`. Encode them as `%28` / `%29`.
- **Little Text Format**: `( ) [ ] { } < > @ # * _ ~ | \` must be escaped in post commentary, and hashtags need `{hashtag|\#|tag}`, or the post silently loses text.
- **Slow image posts**: an upload plus publish can take longer than an MCP client's timeout. The post may appear a minute later. Check your feed before retrying, or you'll publish it twice.
- **Client ID vs secret**: an `invalid_client` on token exchange usually means the secret field holds the Client ID. `npm run check` shows lengths and prefixes without leaking values.

## License
MIT © Valerij Tykhonov