### Install Crosspost CLI Source: https://github.com/humanwhocodes/crosspost/blob/main/README.md Installs the Crosspost utility using npm. This command is typically run once to set up the tool on your system or within a project. ```shell npm install @humanwhocodes/crosspost ``` -------------------------------- ### Crosspost CLI Usage Examples Source: https://github.com/humanwhocodes/crosspost/blob/main/README.md Demonstrates how to use the Crosspost command-line interface to post messages to specific social networks. It shows how to specify target platforms and the message content. ```shell # Post a message to multiple services npx @humanwhocodes/crosspost -t -m -b "Check out this beach!" ``` -------------------------------- ### Crosspost API: Initialize Strategies and Client (JavaScript) Source: https://github.com/humanwhocodes/crosspost/blob/main/README.md Initializes various social media strategy objects (e.g., Twitter, Mastodon, Bluesky) and then creates a Crosspost Client instance configured with these strategies. This setup is necessary for programmatic posting. ```javascript import { Client, TwitterStrategy, MastodonStrategy, BlueskyStrategy, LinkedInStrategy, DiscordStrategy, DiscordWebhookStrategy, TelegramStrategy, DevtoStrategy, NostrStrategy, } from "@humanwhocodes/crosspost"; // Note: Use an app password, not your login password! const bluesky = new BlueskyStrategy({ identifier: "me.you.social", password: "your-app-password", host: "you.social", // "bsky.social" for most people }); // Note: Personal access token is required const mastodon = new MastodonStrategy({ accessToken: "your-access-token", host: "mastodon.host", }); // Note: OAuth app is required const twitter = new TwitterStrategy({ accessTokenKey: "access-token-key", accessTokenSecret: "access-token-secret", apiConsumerKey: "api-consumer-key", apiConsumerSecret: "api-consumer-secret", }); // Note: OAuth access token is required const linkedin = new LinkedInStrategy({ accessToken: "your-access-token", }); // Note: Bot token and channel ID required const discord = new DiscordStrategy({ botToken: "your-bot-token", channelId: "your-channel-id", }); // Note: Webhook URL required const discordWebhook = new DiscordWebhookStrategy({ webhookUrl: "your-webhook-url", }); // Note: Bot token and chat ID required const telegram = new TelegramStrategy({ botToken: "your-bot-token", chatId: "your-chat-id", }); // Note: API key required const devto = new DevtoStrategy({ apiKey: "your-api-key", }); // Note: Private key and relays required const nostr = new NostrStrategy({ privateKey: "your-private-key", // hex or bech32 format relays: ["wss://relay.example.com", "wss://relay2.example.com"], }); // create a client that will post to all services const client = new Client({ strategies: [ bluesky, mastodon, twitter, linkedin, discord, discordWebhook, telegram, devto, nostr, ], }); ``` -------------------------------- ### Run Crosspost as MCP Server Source: https://github.com/humanwhocodes/crosspost/blob/main/README.md This command starts the crosspost tool as an MCP (Model Context Protocol) server. The server can then be used by AI agents to post messages to the services specified by the flags (-t, -m, -b). The server provides an interface for posting content. ```shell npx @humanwhocodes/crosspost --mcp -t -m -b ``` -------------------------------- ### Configure Crosspost MCP Server with .env in Claude Desktop (JSON) Source: https://github.com/humanwhocodes/crosspost/blob/main/README.md This JSON configuration for Claude Desktop's settings enables the crosspost MCP server and uses the `CROSSPOST_DOTENV` environment variable to load credentials from a specified .env file. This approach avoids hardcoding sensitive information directly in the JSON configuration. ```json { "mcpServers": { "crosspost": { "command": "npx", "args": ["@humanwhocodes/crosspost", "-m", "-l", "-t", "--mcp"], "env": { "CROSSPOST_DOTENV": "/usr/nzakas/settings/.env" } } } } ``` -------------------------------- ### Post Message with Image from File to Multiple Services (CLI) Source: https://github.com/humanwhocodes/crosspost/blob/main/README.md This command posts a message from a file ('message.txt') along with an image to multiple services. The image path is specified using the '-i' flag. This is useful for batch posting content with associated media. ```shell npx @humanwhocodes/crosspost -t -m -b -f message.txt -i path/to/image.jpg ``` -------------------------------- ### Run MCP Server with Inspector for Debugging Source: https://github.com/humanwhocodes/crosspost/blob/main/README.md This command runs the crosspost MCP server through the MCP Inspector tool, which is useful for debugging. The flags (-t, -m, -b) determine which services the server will support. ```shell npx run mcp:inspect -- -t -m -b ``` -------------------------------- ### Post Message from File to Multiple Services (CLI) Source: https://github.com/humanwhocodes/crosspost/blob/main/README.md This command posts a message read from a text file to multiple services. The message content is stored in 'message.txt', and the services to post to are specified via flags (e.g., -t for Twitter, -m for Mastodon, -b for Bluesky). ```shell npx @humanwhocodes/crosspost -t -m -b -f message.txt ``` -------------------------------- ### Post Message with Image to Multiple Services (CLI) Source: https://github.com/humanwhocodes/crosspost/blob/main/README.md This command posts a message and an image to Twitter, Mastodon, and Bluesky. The message is provided directly on the command line, and the image is specified by its file path. Additional services can be included by adding their respective flags. ```shell npx @humanwhocodes/crosspost -t -m -b --image ./photo.jpg --image-alt "A beautiful sunset" "Check out this beach!" ``` -------------------------------- ### Configure Crosspost MCP Server in Claude Desktop (JSON) Source: https://github.com/humanwhocodes/crosspost/blob/main/README.md This JSON configuration is for Claude Desktop's settings, enabling the crosspost MCP server. It specifies the command to run, arguments, and environment variables for Mastodon and LinkedIn. The `CROSSPOST_DOTENV` variable can be used to load credentials from a .env file. ```json { "mcpServers": { "crosspost": { "command": "npx", "args": ["@humanwhocodes/crosspost", "-m", "-l", "--mcp"], "env": { "LINKEDIN_ACCESS_TOKEN": "abcdefghijklmnop", "MASTODON_ACCESS_TOKEN": "abcdefghijklmnop", "MASTODON_HOST": "mastodon.social" } } } } ``` -------------------------------- ### Crosspost API: Post with Abort Signal (JavaScript) Source: https://github.com/humanwhocodes/crosspost/blob/main/README.md Demonstrates how to post a message to all services while providing an `AbortSignal`. This allows for cancellation of the posting operation before it completes. ```javascript // post to all services with an abort signal const controller = new AbortController(); await client.post("Hello world!", { signal: controller.signal }); ``` -------------------------------- ### Crosspost API: Post to Specific Services with Signal (JavaScript) Source: https://github.com/humanwhocodes/crosspost/blob/main/README.md Enables posting to selected services with an `AbortSignal` for potential cancellation. This combines targeted posting with the ability to abort the operation. ```javascript // post to specific services with a signal await client.postTo( [ { message: "Hello Twitter!", strategyId: "twitter", }, { message: "Hello Mastodon!", strategyId: "mastodon", }, ], { signal: controller.signal }, ); ``` -------------------------------- ### Crosspost API: Post to All Services (JavaScript) Source: https://github.com/humanwhocodes/crosspost/blob/main/README.md Posts a message to all configured social media services using the Crosspost client. Supports optional image attachments with specified alt text. The `imageData` should be a Uint8Array. ```javascript // post to all services with up to 4 images (must be PNG, JPEG, or GIF) await client.post("Hello world!", { images: [ { data: imageData, // Uint8Array of image data alt: "Description of the image", }, ], }); ``` -------------------------------- ### Crosspost API: Post to Specific Services (JavaScript) Source: https://github.com/humanwhocodes/crosspost/blob/main/README.md Allows posting messages to a subset of configured services by specifying their `strategyId`. This method also supports image attachments. ```javascript // post to specific services using postTo await client.postTo([ { message: "Hello Twitter!", strategyId: "twitter", // Uses the strategy's id property }, { message: "Hello Mastodon and Bluesky!", strategyId: "mastodon", images: [ { data: imageData, // Uint8Array of image data alt: "Description of the image", }, ], }, { message: "Hello Bluesky!", strategyId: "bluesky", }, ]); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.