LinkedIn MCP
by MHChlagou
README.md
# LinkedIn MCP
A local-first Model Context Protocol (MCP) server for working with your own LinkedIn profile and preparing LinkedIn text posts through the official LinkedIn APIs.
The project is built with Python, FastMCP, FastAPI and SQLite. Its initial development target is a single-user environment on WSL. It is not currently designed for public or multi-user deployment.
> **Important:** This is an independent, community project and is not affiliated with, endorsed by, or supported by LinkedIn. API access depends on LinkedIn's approval of your application and permissions.
## Project status
The core implementation is merged. The remaining work is live validation with a LinkedIn Developer application and production hardening. See the [roadmap](ROADMAP.md).
| Area | Status |
| --- | --- |
| MCP server and local WSL setup | Implemented |
| LinkedIn OAuth 2.0 flow | Implemented; live credentials required |
| Encrypted local token storage | Implemented |
| OIDC profile lookup | Implemented |
| Local post drafts and approval workflow | Implemented |
| LinkedIn text-post API integration | Implemented; permission and live test pending |
| Multi-user / public deployment | Not supported |
## Features
- LinkedIn OAuth 2.0 authorization-code flow with state validation bound to an HTTP-only cookie.
- OpenID Connect profile lookup using LinkedIn's userinfo endpoint.
- Encrypted local OAuth token storage.
- MCP tools for reading the authorized profile.
- Persistent local post drafts using SQLite.
- Explicit approval state before a post can be published.
- Text-post publishing through LinkedIn's official Posts API.
- Automated hygiene checks, Ruff linting, and pytest in GitHub Actions.
## Requirements
- Python 3.12 or newer.
- Git.
- Ubuntu or another Linux distribution, including WSL.
- A LinkedIn Developer application with the products and permissions required for the operations you intend to use.
## Quick start (WSL / Linux)
```bash
git clone https://github.com/MHChlagou/free-linkedin-mcp.git
cd free-linkedin-mcp
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
pip install -e ".[dev]"
cp .env.example .env
mkdir -p data
```
Generate a local encryption key:
```bash
python -c "import secrets; print(secrets.token_urlsafe(48))"
```
Set the generated value as `APP_SECRET_KEY` in your local `.env` file. Configure the LinkedIn application values:
- `LINKEDIN_CLIENT_ID`
- `LINKEDIN_CLIENT_SECRET`
- `LINKEDIN_REDIRECT_URI`
- `LINKEDIN_SCOPES`
- `LINKEDIN_API_VERSION`
Register this exact local redirect URI in the LinkedIn Developer Portal:
`http://localhost:8000/oauth/linkedin/callback`
Start the server:
```bash
python -m app.main
```
Check the health endpoint:
```bash
curl http://127.0.0.1:8000/health
```
Open the following URL to start LinkedIn authorization:
`http://127.0.0.1:8000/oauth/linkedin/start`
After successful authorization, the callback stores the token response encrypted in `data/linkedin_tokens.enc`.
The MCP endpoint is:
`http://127.0.0.1:8000/mcp`
## Available MCP tools
| Tool | Purpose |
| --- | --- |
| `get_my_profile` | Read profile fields exposed by the granted OpenID Connect permissions. |
| `create_post_draft` | Save a local post draft. |
| `get_post_draft` | Retrieve a saved draft and its status. |
| `get_pending_posts` | List drafts waiting for review. |
| `submit_post_for_approval` | Move a draft to pending review. |
| `approve_post` | Approve the exact text after explicit user confirmation. |
| `publish_approved_post` | Publish an approved draft through the official LinkedIn Posts API. |
**Publication safety:** never approve or publish a post unless the user has reviewed and explicitly approved the exact content and requested publication.
## LinkedIn API permissions and limitations
LinkedIn API access depends on the products and permissions approved for your application.
The initial profile integration uses OpenID Connect scopes: `openid`, `profile`, and optionally `email`. These scopes do not provide unrestricted access to edit profile sections such as the headline, About, experience, or skills. Profile editing is therefore not implemented.
The `w_member_social` permission is required for member post creation. LinkedIn must grant this permission to your application. The Posts API also requires a currently supported API version configured through `LINKEDIN_API_VERSION`.
This project does not scrape LinkedIn pages, automate browser sessions, or bypass LinkedIn API restrictions.
## Development and quality checks
Install development dependencies with `pip install -e ".[dev]"`, then run:
```bash
python scripts/check_hygiene.py --all --messages
ruff check .
pytest
```
All three checks are expected to pass before opening a pull request. See [CONTRIBUTING.md](CONTRIBUTING.md) and the [pull request template](.github/pull_request_template.md).
## Security
- Never commit `.env`, OAuth client secrets, access tokens, refresh tokens, private keys, or local database files.
- OAuth tokens are encrypted at rest using a key derived from `APP_SECRET_KEY`. Keep that key private and back it up securely. Losing it makes the locally stored token file unreadable.
- OAuth state is bound to an HTTP-only cookie and expires after ten minutes.
- The local token store is intended for single-user development on loopback.
- **Do not expose this server to a network or the public internet** until MCP client authentication, TLS, durable OAuth state storage, rate limiting, backups, monitoring, and a security review are complete.
Please read [SECURITY.md](SECURITY.md) before reporting a vulnerability.
## Current limitations
- OAuth refresh is not implemented. Reconnect when the access token expires.
- LinkedIn profile editing is not implemented because the available API permissions do not grant those capabilities.
- Post publishing requires LinkedIn approval for `w_member_social` and a valid `LINKEDIN_API_VERSION`.
- Draft storage uses local SQLite and is intended for one local development instance.
- Live OAuth and real publication have not been validated without the user's LinkedIn application credentials.
## Documentation
- [Roadmap](ROADMAP.md)
- [Contributing guide](CONTRIBUTING.md)
- [Security policy](SECURITY.md)
- [Code of Conduct](CODE_OF_CONDUCT.md)
## License
This project is licensed under the [MIT License](LICENSE). You may use, copy, modify, distribute, sublicense, and sell copies of the software, subject to the license conditions.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues