Megahorn

Megahorn

A Go CLI and MCP server for cross-posting to Twitter, LinkedIn, and Reddit from your terminal or AI agents, with secure local credential storage.

Category
访问服务器

README

<p align="center"> <img src="https://img.shields.io/badge/Go-1.26-00ADD8?style=flat-square&logo=go" alt="Go 1.26" /> <img src="https://img.shields.io/badge/License-MIT-green?style=flat-square" alt="MIT License" /> <img src="https://img.shields.io/badge/Platforms-3-blue?style=flat-square" alt="3 Platforms" /> <img src="https://img.shields.io/badge/MCP-Ready-purple?style=flat-square" alt="MCP Ready" /> </p>

Megahorn

One binary to rule them all. Cross-post to social media from your terminal or let AI agents do it for you.

You: "promote our new feature"
Claude: crafts platform-specific posts, shows you for approval
You: "looks good"
Claude: megahorn_post → Twitter, LinkedIn, Reddit → done

Megahorn is a standalone Go CLI + MCP server. It handles authentication and publishing — your API keys never leave your machine, never enter an AI conversation.


Why Megahorn?

  • Single binarygo install and you're done. No Node.js, no Python, no Docker.
  • Three platforms, one command — Twitter, LinkedIn, Reddit. More coming.
  • AI-native — Ships as an MCP server. Claude Code, Cursor, or any MCP client can post on your behalf.
  • Secure by design — Credentials live in your OS keychain. The MCP server is the security boundary.
  • Product-agnostic — Works for any project. The AI skill reads your repo's context automatically.
  • Free — No paid Twitter API. Browser automation for Twitter, free OAuth for LinkedIn and Reddit.

Installation

1. Install the binary

# Option A: Go install
go install github.com/rajpootathar/megahorn@latest

# Option B: From source
git clone https://github.com/rajpootathar/megahorn.git
cd megahorn && make build
sudo mv megahorn /usr/local/bin/

2. Install the AI skill (optional)

npx skills add rajpootathar/megahorn

This installs the social-post skill for Claude Code, Cursor, or any compatible AI agent. The skill teaches the agent how to write platform-adapted content and call Megahorn's MCP tools.

3. Register MCP server (optional)

megahorn install
# Restart your AI agent to activate

This adds Megahorn to your Claude Code MCP settings so the agent can call megahorn_post, megahorn_auth_status, and megahorn_auth as native tools.


Quick Start

Authenticate

megahorn auth twitter        # Opens Chrome — log in manually, handle 2FA
megahorn auth linkedin       # OAuth2 flow — opens browser for consent
megahorn auth reddit         # OAuth2 flow — opens browser for consent
megahorn auth status         # Check what's connected
$ megahorn auth status
Platform       Status
------------------------------
twitter        + authenticated
linkedin       + authenticated
reddit         x not_configured

Post

# To specific platforms
megahorn post -t "Just shipped journey tracking"
megahorn post -t -l "We cut query time from 12s to 40ms"
megahorn post -r --subreddit SaaS,startups "Launched our analytics dashboard"

# To all authenticated platforms
megahorn post --all "Big announcement today"

# Preview without posting
megahorn post --dry-run -t -l -r --subreddit webdev "test post"

# From a file
megahorn post --file announcement.md -t -l

# JSON output (for scripting / piping)
megahorn post --json --dry-run -t -l "test"
$ megahorn post -t -l -r --subreddit SaaS "Shipped user journey tracking"
TWITTER: https://x.com/yourhandle/status/1234567890
LINKEDIN: https://www.linkedin.com/feed/update/urn:li:share:12345
REDDIT: https://reddit.com/r/SaaS/comments/abc123

3/3 published.

Configure

megahorn config                                          # Show current config
megahorn config set browser.headed true                  # Always use visible browser
megahorn config set platforms.defaults twitter,linkedin   # Default platforms when no flags
megahorn config set browser.chrome_path /usr/bin/chromium # Custom Chrome path

Platform Setup

Twitter

Twitter uses browser automation via chromedp — no paid API needed.

  1. Run megahorn auth twitter
  2. Chrome opens to twitter.com/login
  3. Log in normally (2FA supported)
  4. Press Enter in the terminal once you see your feed
  5. Session cookies are saved to your OS keychain

Headed vs headless: Auth always opens a visible browser. Posting defaults to headless (background). Use --headed to watch it happen.

If selectors break: Twitter changes its DOM frequently. Megahorn uses data-testid attributes which are more stable, but if posting fails, you can update selectors without rebuilding:

# Override selectors at ~/.megahorn/selectors/twitter.yaml
compose_button: '[data-testid="SideNav_NewTweet_Button"]'
tweet_textarea: '[data-testid="tweetTextarea_0"]'
post_button: '[data-testid="tweetButtonInline"]'

LinkedIn

LinkedIn uses the Community Management API (free, OAuth2).

  1. Go to linkedin.com/developers/apps/new
  2. Create an app (any name works, e.g., "Megahorn")
  3. Under Products, request "Share on LinkedIn" and "Sign In with LinkedIn using OpenID Connect"
  4. Under Auth settings, add redirect URL: http://localhost:8338/callback
  5. Run megahorn auth linkedin — enter your Client ID and Client Secret
  6. Browser opens for OAuth consent — authorize and you're done

Token expiry: LinkedIn tokens last ~60 days. Megahorn warns you when a token is approaching expiry. Re-run megahorn auth linkedin to refresh.

Reddit

Reddit uses OAuth2 web app type (free, no password storage).

  1. Go to reddit.com/prefs/apps
  2. Click "create another app"
  3. Choose web app, set redirect URI to http://localhost:8338/callback
  4. Run megahorn auth reddit — enter your Client ID and Client Secret
  5. Browser opens for consent — authorize and you're done

Token refresh: Reddit tokens expire hourly. Megahorn auto-refreshes using the stored refresh token — you won't notice.

Multi-subreddit: Post to multiple subreddits in one command:

megahorn post -r --subreddit SaaS,startups,webdev "Your post title\nYour post body"

First line = title, rest = body.


MCP Server

Megahorn doubles as an MCP server, letting AI agents post to social media through native tool calls.

megahorn server   # Starts stdio JSON-RPC server

Available Tools

Tool Description Parameters
megahorn_post Post content to a platform platform, content, subreddit?, dry_run?
megahorn_auth_status Check authenticated platforms
megahorn_auth Start auth flow (opens browser) platform, headed?

Configuration

Add to your AI agent's MCP settings:

{
  "mcpServers": {
    "megahorn": {
      "command": "megahorn",
      "args": ["server"]
    }
  }
}

Or run megahorn install to auto-configure Claude Code.

How AI Agents Use It

With the social-post skill installed, an AI agent will:

  1. Read your project's CLAUDE.md, docs, and recent git history
  2. Understand what you're promoting
  3. Write platform-specific content (280ch tweet, LinkedIn thought-piece, Reddit discussion)
  4. Show you the posts for approval
  5. Call megahorn_post for each approved platform
  6. Report back with published URLs

The agent crafts the content. Megahorn handles the publishing. Your keys stay local.


Architecture

┌──────────────────┐     ┌─────────────────────┐
│  You (terminal)  │────>│                     │───> Twitter  (Chrome CDP)
│  $ megahorn post │     │                     │
└──────────────────┘     │    megahorn          │───> LinkedIn (REST API)
                         │    (Go binary)       │
┌──────────────────┐     │                     │───> Reddit   (REST API)
│  AI Agent (MCP)  │────>│  Credentials:       │
│  Claude / Cursor │     │  OS keychain        │
└──────────────────┘     │  never in context   │
                         └─────────────────────┘

Project Structure

megahorn/
├── cmd/                  # CLI commands (cobra)
│   ├── auth.go           # megahorn auth
│   ├── post.go           # megahorn post
│   ├── server.go         # megahorn server (MCP)
│   ├── config.go         # megahorn config
│   └── install.go        # megahorn install
├── internal/
│   ├── platform/         # Platform interface + implementations
│   │   ├── twitter.go    # chromedp browser automation
│   │   ├── linkedin.go   # OAuth2 REST API
│   │   └── reddit.go     # OAuth2 REST API
│   ├── mcp/              # MCP server + tool handlers
│   ├── auth/             # Keyring, OAuth2, browser open
│   ├── browser/          # Chrome launcher, selectors
│   └── config/           # YAML config management
├── skills/
│   └── social-post/
│       └── SKILL.md      # AI agent skill (npx skills add)
├── selectors/
│   └── twitter.yaml      # Default Twitter DOM selectors
└── package.json          # For npx skills add discovery

CLI Reference

megahorn [command]

Commands:
  auth [platform]     Authenticate with a platform (twitter, linkedin, reddit)
  auth status         Show auth status for all platforms
  post [content]      Post content to platforms
  server              Start MCP server (stdio)
  config              Show configuration
  config set [k] [v]  Set a config value
  install             Configure MCP in Claude Code
  version             Print version

Post Flags:
  -t, --twitter       Post to Twitter
  -l, --linkedin      Post to LinkedIn
  -r, --reddit        Post to Reddit
  -a, --all           All authenticated platforms
      --subreddit     Comma-separated subreddits
      --headed        Visible browser for Twitter
      --dry-run       Preview without posting
  -f, --file          Read content from file
      --json          JSON output

Auth Flags:
      --headed        Visible browser (default: true)
      --headless      Headless browser

Security

Layer How
At rest OS keychain (macOS Keychain / Linux secret-service)
In transit HTTPS for APIs, WSS for Chrome CDP
In AI context Never. MCP tools are the boundary — agents send commands, never see keys
Config files Preferences only (browser mode, defaults). Zero secrets.

Roadmap

v2 candidates (no timeline):

Bluesky, Dev.to, Hacker News, Mastodon, Discord, Hashnode, Product Hunt, Threads, Indie Hackers | Read feeds & comments | Media attachments | Twitter threads | Scheduling | Analytics | Windows support


Contributing

PRs welcome. The platform interface makes it easy to add new platforms:

type Platform interface {
    Name() string
    Auth(opts AuthOpts) error
    Post(content string, opts PostOpts) (*PostResult, error)
    Status() AuthStatus
}

Implement these four methods, register in the registry, done.


License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选