Sign In

linkedctl

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

linkedctl

The complete CLI & MCP for LinkedIn

Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
48
-15.79%
Maintainers
1
Weekly downloads
 
Created
Source

LinkedCtl

CI License

OAuth2 CLI and MCP server for the LinkedIn API.

What It Does

  • Post content to LinkedIn via the official API
  • 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

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

Claude Code

claude mcp add linkedctl -- npx linkedctl mcp

Claude Desktop

Add to claude_desktop_config.json:

{
    "mcpServers": {
        "linkedctl": {
            "command": "npx",
            "args": ["linkedctl", "mcp"]
        }
    }
}

Available Tools

post_create

Create a text post on LinkedIn.

ParameterTypeRequiredDescription
textstringYesThe text content of the post
visibilitystringNo"PUBLIC" or "CONNECTIONS" (default "PUBLIC")
profilestringNoProfile name to use from config file

auth_status

Show authentication status for a profile.

ParameterTypeRequiredDescription
profilestringNoProfile name to check (uses default if not specified)

auth_revoke

Revoke the access token server-side and clear local credentials for a profile.

ParameterTypeRequiredDescription
profilestringNoProfile name to revoke (uses default if not specified)

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:

KeyDescription
api-versionLinkedIn API version (e.g. 202601)
oauth.client-idOAuth 2.0 client ID
oauth.client-secretOAuth 2.0 client secret
oauth.access-tokenOAuth 2.0 access token
oauth.refresh-tokenOAuth 2.0 refresh token
oauth.token-expires-atToken expiration timestamp (ISO 8601)

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.yaml in the current working directory
  • ~/.linkedctl.yaml in 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/:

ProfileConfig file path
(default)~/.linkedctl.yaml
work~/.linkedctl/work.yaml
personal~/.linkedctl/personal.yaml

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

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

VariableDescription
LINKEDCTL_CLIENT_IDLinkedIn OAuth 2.0 client ID
LINKEDCTL_CLIENT_SECRETLinkedIn OAuth 2.0 client secret
LINKEDCTL_ACCESS_TOKENDirect access token (bypasses OAuth flow)
LINKEDCTL_API_VERSIONLinkedIn API version string (e.g. 202601) required

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:

ProfileVariable
(default)LINKEDCTL_ACCESS_TOKEN
workLINKEDCTL_WORK_ACCESS_TOKEN
my-brandLINKEDCTL_MY_BRAND_ACCESS_TOKEN

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

OptionDescription
--profile <name>Use a specific configuration profile

auth -- Manage Authentication

CommandDescription
auth loginAuthenticate via OAuth 2.0 (opens browser)
auth tokenStore a direct access token
auth statusShow authentication status and token expiry
auth logoutClear stored credentials from the active profile
auth refreshRefresh the access token using a stored refresh token
auth revokeRevoke the access token server-side and clear local tokens

auth login options:

OptionDescriptionDefault
--client-id <id>OAuth 2.0 client IDfrom config
--client-secret <secret>OAuth 2.0 client secretfrom config
--scope <scopes>OAuth 2.0 scopes (space-separated)openid profile w_member_social

auth token options:

OptionDescription
--access-token <token>Access token to store (required)

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:

OptionDescriptionDefault
--text <text>Text content of the post
--visibility <visibility>PUBLIC or CONNECTIONSPUBLIC
--format <format>Output format (json, table)auto

When no --text is provided, text is read from stdin if available.

The --format option defaults to table in a terminal and json when piped.

profile -- Manage Configuration Profiles

CommandDescription
profile create <name>Create a new profile
profile listList all profiles
profile show <name>Show profile details (redacted)
profile delete <name>Delete a profile

profile create options:

OptionDescription
--access-token <token>OAuth 2.0 access token (required)
--api-version <version>LinkedIn API version, e.g. 202601 (required)

whoami -- Show Current User

linkedctl whoami
linkedctl whoami --format json
OptionDescriptionDefault
--format <format>Output format (json, table)auto

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

AGPL-3.0-only

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).

Keywords

linkedin

FAQs

Package last updated on 09 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts