Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ jobs:
- name: Build
run: npm run build

- name: Test
run: npm test

- name: MCP introspection smoke test
run: |
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"ci","version":"0"}}}' \
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ Eight tools, dot-notation names form a navigable tree (`post.*`, `channel.*`, `p
| `linkedin` | Browser fallback | returns `needs_browser` + compose URL |
| `medium` | Browser fallback | returns `needs_browser` + compose URL |
| `twitter` / `x` | Browser fallback | returns `needs_browser` + compose URL |
| `twitter_getxapi` / `getxapi_twitter` | API (write) | `GETXAPI_API_KEY`, `GETXAPI_AUTH_TOKEN`, and `GETXAPI_ENABLE_ACTIONS=true` |

GetXAPI uses an API key for the service and an X account `auth_token` cookie in `GETXAPI_AUTH_TOKEN`. Keep both in the distribution profile at runtime. Writes require explicit opt-in. The adapter rejects empty or over-280-character text instead of silently truncating it, and reports a live URL only after a successful response includes a tweet ID. See the [Create Tweet API documentation](https://docs.getxapi.com/docs/tweets/create-tweet).

## Example agent call

Expand Down Expand Up @@ -185,7 +188,7 @@ Agent (Claude Code / n8n / Cursor / any MCP host)
▼
content-distribution-mcp (this package, stdio transport)
│ no LLM calls — pure I/O
├── adapters/ devto · hashnode · github-discussions · reddit · bluesky · browser
├── adapters/ devto · hashnode · github-discussions · reddit · bluesky · getxapi-twitter · browser
└── backends/ yaml (post log · profiles · schedule queue · subreddit catalog)
```

Expand Down
132 changes: 80 additions & 52 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
],
"scripts": {
"build": "tsc",
"prepare": "npm run build"
"prepare": "npm run build",
"pretest": "npm run build",
"test": "node --test"
},
"dependencies": {
"@modelcontextprotocol/sdk": "^1.12.0",
"js-yaml": "^4.1.0",
"@modelcontextprotocol/sdk": "^1.32.1",
"js-yaml": "^4.3.2",
"zod": "^3.23.0"
},
"devDependencies": {
Expand Down
71 changes: 71 additions & 0 deletions src/adapters/getxapi-twitter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import type { Variant, PublishResult, ChannelHints } from "../models.js";
import type { Profile } from "../backends/base.js";

const DEFAULT_GETXAPI_BASE_URL = "https://api.getxapi.com";

export class GetXAPITwitterAdapter {
hints(): ChannelHints {
return {
max_length: 280,
supported_md_features: ["links"],
cta_placement: "bottom",
canonical_url_supported: false,
browser_only: false,
};
}

async publish(variant: Variant, profile: Profile): Promise<PublishResult> {
const apiKey = profile.credentials.GETXAPI_API_KEY;
if (!apiKey) {
return { channel: variant.channel, state: "failed", error: "GETXAPI_API_KEY required in profile" };
}

const enableActions = profile.credentials.GETXAPI_ENABLE_ACTIONS === "true";
if (!enableActions) {
return { channel: variant.channel, state: "failed", error: "GETXAPI_ENABLE_ACTIONS must be true to publish writes" };
}

const authToken = profile.credentials.GETXAPI_AUTH_TOKEN;
if (!authToken) {
return { channel: variant.channel, state: "failed", error: "GETXAPI_AUTH_TOKEN required in profile" };
}
if (!variant.body.trim() || Array.from(variant.body).length > 280) {
return { channel: variant.channel, state: "failed", error: "GetXAPI tweet text must contain 1 to 280 characters; shorten the variant before publishing" };
}

const baseUrl = (profile.credentials.GETXAPI_BASE_URL || DEFAULT_GETXAPI_BASE_URL).replace(/\/+$/, "");
const text = variant.body;

const res = await fetch(`${baseUrl}/twitter/tweet/create`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${apiKey}`,
},
body: JSON.stringify({ auth_token: authToken, text }),
});

if (!res.ok) {
// Remote error bodies can echo account credentials. Keep them out of logs.
return { channel: variant.channel, state: "failed", error: `GetXAPI publish failed: HTTP ${res.status}` };
}

const data = await res.json() as { status?: string; data?: { id?: string } };
const tweetId = data?.data?.id;
if (data?.status !== "success" || typeof tweetId !== "string" || !/^\d+$/.test(tweetId)) {
return { channel: variant.channel, state: "failed", error: "GetXAPI did not confirm a created tweet ID" };
}
const liveUrl = `https://x.com/i/web/status/${tweetId}`;

return {
channel: variant.channel,
state: "live",
live_url: liveUrl,
published_at: new Date().toISOString(),
};
}

async unpublish(_liveUrl: string, _profile: Profile): Promise<[boolean, string]> {
return [false, "GetXAPI tweet deletion not yet implemented"];
}
}
5 changes: 5 additions & 0 deletions src/adapters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { HashnodeAdapter } from "./hashnode.js";
import { GitHubDiscussionsAdapter } from "./github-discussions.js";
import { RedditAdapter } from "./reddit.js";
import { BlueskyAdapter } from "./bluesky.js";
import { GetXAPITwitterAdapter } from "./getxapi-twitter.js";
import { makeBrowserAdapter } from "./browser.js";
import type { Variant, PublishResult, ChannelHints } from "../models.js";
import type { Profile } from "../backends/base.js";
Expand Down Expand Up @@ -35,5 +36,9 @@ export function buildAdapterMap(): Record<string, ChannelAdapter> {
twitter_browser: twitter,
"twitter-browser": twitter,
x: twitter,
twitter_getxapi: new GetXAPITwitterAdapter(),
"twitter-getxapi": new GetXAPITwitterAdapter(),
getxapi_twitter: new GetXAPITwitterAdapter(),
"getxapi-twitter": new GetXAPITwitterAdapter(),
};
}
Loading
Loading