
OAuth2 CLI and MCP server for the LinkedIn API.
What It Does
- Post content — text, images, video, documents, articles, multi-image carousels, and polls
- Comments & reactions — create, list, and delete comments and reactions on posts
- Organization support — post, comment, react, and view analytics as an organization
- Analytics — per-post, per-member, and per-organization statistics
- Media uploads — upload images, video, and documents to LinkedIn
- Draft posts — save posts as drafts before publishing
- OAuth 2.0 authentication with your own LinkedIn app
- Direct token passing for tokens obtained from other applications
- MCP server for AI assistant integration (Claude, Cursor, etc.)
- CLI for scriptable LinkedIn operations
Prerequisites
- Node.js >= 24
- A LinkedIn Developer App with appropriate permissions
Installation
npm install -g linkedctl
Or run directly:
npx linkedctl --help
Quick Start
- Create a LinkedIn app at linkedin.com/developers
- Configure OAuth 2.0 credentials
- Authenticate:
linkedctl auth login --client-id YOUR_CLIENT_ID --client-secret YOUR_CLIENT_SECRET - Start using:
linkedctl post "Hello from LinkedCtl!"
See the OAuth Setup Guide for detailed step-by-step instructions.
MCP Integration
MCP Client Configuration
Add to your Claude Desktop configuration (claude_desktop_config.json):
{
"mcpServers": {
"linkedctl": {
"command": "npx",
"args": ["linkedctl", "mcp"]
}
}
}
claude mcp add linkedctl -- npx linkedctl mcp
Add to .cursor/mcp.json in your project root:
{
"mcpServers": {
"linkedctl": {
"command": "npx",
"args": ["linkedctl", "mcp"]
}
}
}
Add to ~/.codeium/windsurf/mcp_config.json:
{
"mcpServers": {
"linkedctl": {
"command": "npx",
"args": ["linkedctl", "mcp"]
}
}
}
Available Tools
All tools accept an optional profile parameter to select a configuration profile.
Authentication
Posts
post_create supports rich content types:
Comments
Reactions
Organizations
Analytics
Media
Configuration
Config File Format
LinkedCtl stores configuration in YAML files. Each file represents a single profile:
api-version: "202601"
oauth:
client-id: "YOUR_CLIENT_ID"
client-secret: "YOUR_CLIENT_SECRET"
access-token: "YOUR_ACCESS_TOKEN"
refresh-token: "YOUR_REFRESH_TOKEN"
token-expires-at: "2026-05-03T12:00:00.000Z"
Available keys:
Config files are written with 0600 permissions (owner read/write only).
File Location and Precedence
Without a profile, LinkedCtl searches for config files in this order:
.linkedctl.yamlin the current working directory~/.linkedctl.yamlin the home directory
The first file found is used. When writing (e.g. after auth login), LinkedCtl writes to the CWD file if it exists, otherwise to the home directory file.
Profiles
Profiles let you manage multiple LinkedIn accounts or configurations. Each profile is stored as a separate YAML file under ~/.linkedctl/:
Use the --profile flag with any command:
linkedctl --profile work auth login --client-id ID --client-secret SECRET
linkedctl --profile work post "Hello from my work account!"
Manage profiles with the profile command:
linkedctl profile create work --access-token YOUR_TOKEN --api-version 202601
linkedctl profile list
linkedctl profile show work
linkedctl profile delete work
Authentication Methods
OAuth 2.0 (Recommended)
LinkedCtl supports OAuth 2.0 with your own LinkedIn Developer App:
linkedctl auth login --client-id YOUR_CLIENT_ID --client-secret YOUR_CLIENT_SECRET
Direct Token
If you already have an access token from another application:
linkedctl auth token --access-token YOUR_TOKEN
Environment Variables
Environment variables take precedence over config file values.
Profile-Prefixed Environment Variables
When using a named profile, LinkedCtl also reads profile-prefixed environment variables. The profile name is uppercased with hyphens converted to underscores:
The same pattern applies to CLIENT_ID, CLIENT_SECRET, and API_VERSION.
Precedence Order
Configuration values are resolved in this order (highest priority first):
- Environment variables (profile-prefixed if a profile is active)
- Config file (profile-specific file, or CWD/home fallback)
CLI Reference
Global Options
auth — Manage Authentication
auth login options:
auth token options:
post — Manage LinkedIn Posts
# Shorthand: pass text as an argument
linkedctl post "Hello from LinkedCtl!"
# Explicit subcommand
linkedctl post create --text "Hello from LinkedCtl!"
# Pipe content from stdin
echo "Hello from LinkedCtl!" | linkedctl post create
post create options:
post list options:
comment — Manage Comments
comment create options:
reaction — Manage Reactions
reaction create options:
org — Manage Organizations
media — Upload Media
All media commands accept --as-org <id> and --format json|table.
stats — View Analytics
Common options:
profile — Manage Configuration Profiles
profile create options:
whoami — Show Current User
linkedctl whoami
linkedctl whoami --format json
completion — Shell Completions
linkedctl completion bash
linkedctl completion zsh
Security
- Dependabot keeps dependencies up to date with automated pull requests
- CodeQL analysis runs on every push and pull request for automated vulnerability detection
- Path traversal validation on profile names prevents directory escape attacks
- Unified auth error handling across all MCP tools provides consistent authentication failure messages
- Destructive operations (delete post, delete comment, delete profile) require interactive confirmation unless
--forceis passed
Disclaimer
This is an independent project and is not affiliated with, endorsed by, or associated with LinkedIn Corporation. LinkedIn is a trademark of LinkedIn Corporation.
License
Using LinkedCtl as a CLI tool or MCP server: No license obligations — use freely.
Using @linkedctl/core as a library in your project: Your combined work must be licensed under AGPL-3.0 (or a compatible license).