@granitebps/twitter-mcp 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +7 -0
- package/README.md +326 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +35 -0
- package/dist/cli.js.map +1 -0
- package/dist/config/env.d.ts +22 -0
- package/dist/config/env.js +44 -0
- package/dist/config/env.js.map +1 -0
- package/dist/domain/requests.d.ts +36 -0
- package/dist/domain/requests.js +2 -0
- package/dist/domain/requests.js.map +1 -0
- package/dist/domain/schemas.d.ts +95 -0
- package/dist/domain/schemas.js +53 -0
- package/dist/domain/schemas.js.map +1 -0
- package/dist/errors/twitter-error.d.ts +20 -0
- package/dist/errors/twitter-error.js +35 -0
- package/dist/errors/twitter-error.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/providers/api/mapper.d.ts +34 -0
- package/dist/providers/api/mapper.js +45 -0
- package/dist/providers/api/mapper.js.map +1 -0
- package/dist/providers/api/provider.d.ts +44 -0
- package/dist/providers/api/provider.js +150 -0
- package/dist/providers/api/provider.js.map +1 -0
- package/dist/providers/deadline.d.ts +1 -0
- package/dist/providers/deadline.js +15 -0
- package/dist/providers/deadline.js.map +1 -0
- package/dist/providers/factory.d.ts +7 -0
- package/dist/providers/factory.js +17 -0
- package/dist/providers/factory.js.map +1 -0
- package/dist/providers/provider.d.ts +9 -0
- package/dist/providers/provider.js +2 -0
- package/dist/providers/provider.js.map +1 -0
- package/dist/providers/rettiwt/mapper.d.ts +29 -0
- package/dist/providers/rettiwt/mapper.js +42 -0
- package/dist/providers/rettiwt/mapper.js.map +1 -0
- package/dist/providers/rettiwt/provider.d.ts +30 -0
- package/dist/providers/rettiwt/provider.js +161 -0
- package/dist/providers/rettiwt/provider.js.map +1 -0
- package/dist/server/create-server.d.ts +9 -0
- package/dist/server/create-server.js +10 -0
- package/dist/server/create-server.js.map +1 -0
- package/dist/server/input.d.ts +17 -0
- package/dist/server/input.js +34 -0
- package/dist/server/input.js.map +1 -0
- package/dist/server/output.d.ts +8 -0
- package/dist/server/output.js +34 -0
- package/dist/server/output.js.map +1 -0
- package/dist/server/register-tools.d.ts +9 -0
- package/dist/server/register-tools.js +106 -0
- package/dist/server/register-tools.js.map +1 -0
- package/package.json +83 -0
- package/server.json +30 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 granitebps
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
# Twitter/X MCP
|
|
2
|
+
|
|
3
|
+
Twitter/X MCP lets an MCP client read public X posts, replies, and profiles, or search X. It uses Rettiwt by default, so you do not need an X developer plan. You can switch to the official X API if you have access.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- Node.js 22.21.0 or newer within the Node 22 release line. The current Rettiwt release does not support Node 23 or later.
|
|
8
|
+
- A `RETTIWT_API_KEY`. Official X API credentials work when you select API mode.
|
|
9
|
+
|
|
10
|
+
## Quick start
|
|
11
|
+
|
|
12
|
+
Once the package is published, your MCP client can run it without a clone:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npx -y @granitebps/twitter-mcp
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The server selects Rettiwt when you omit `TWITTER_MODE`. Pass `RETTIWT_API_KEY` in the client configuration.
|
|
19
|
+
|
|
20
|
+
The server uses stdio. Keep stdout reserved for MCP traffic.
|
|
21
|
+
|
|
22
|
+
## Run from a cloned repository
|
|
23
|
+
|
|
24
|
+
To develop the server or use a clone directly:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
git clone https://github.com/granitebps/twitter-mcp.git
|
|
28
|
+
cd twitter-mcp
|
|
29
|
+
npm ci
|
|
30
|
+
npm run build
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Point your MCP client at the compiled entry point:
|
|
34
|
+
|
|
35
|
+
```text
|
|
36
|
+
node /absolute/path/to/twitter-mcp/dist/cli.js
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Run `npm run build` after each source change. Do not use `src` or `npm run dev` as the client's stdio command. Build logs on stdout can corrupt MCP messages.
|
|
40
|
+
|
|
41
|
+
## Client configuration
|
|
42
|
+
|
|
43
|
+
Each example starts with the npm package, followed by the local equivalent. Replace `/absolute/path/to/twitter-mcp` with your clone's path and `your_key_here` with your Rettiwt key. Do not commit a configuration file that contains the key.
|
|
44
|
+
|
|
45
|
+
### Claude
|
|
46
|
+
|
|
47
|
+
Add the npm package to Claude Code:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
claude mcp add twitter --env RETTIWT_API_KEY=your_key_here -- npx -y @granitebps/twitter-mcp
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
For a local build:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
claude mcp add twitter --env RETTIWT_API_KEY=your_key_here -- node /absolute/path/to/twitter-mcp/dist/cli.js
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Claude Code uses local scope by default. Add `--scope user` before `twitter` to make the server available across projects.
|
|
60
|
+
|
|
61
|
+
Claude Desktop reads the same server from `claude_desktop_config.json`. Restart the app after editing the file.
|
|
62
|
+
|
|
63
|
+
```json
|
|
64
|
+
{
|
|
65
|
+
"mcpServers": {
|
|
66
|
+
"twitter": {
|
|
67
|
+
"command": "npx",
|
|
68
|
+
"args": ["-y", "@granitebps/twitter-mcp"],
|
|
69
|
+
"env": {
|
|
70
|
+
"RETTIWT_API_KEY": "your_key_here"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
For a local build, replace `command` and `args` with:
|
|
78
|
+
|
|
79
|
+
```json
|
|
80
|
+
{
|
|
81
|
+
"command": "node",
|
|
82
|
+
"args": ["/absolute/path/to/twitter-mcp/dist/cli.js"]
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Codex
|
|
87
|
+
|
|
88
|
+
Add the npm package to `~/.codex/config.toml`, or to `.codex/config.toml` in a trusted project:
|
|
89
|
+
|
|
90
|
+
```toml
|
|
91
|
+
[mcp_servers.twitter]
|
|
92
|
+
command = "npx"
|
|
93
|
+
args = ["-y", "@granitebps/twitter-mcp"]
|
|
94
|
+
|
|
95
|
+
[mcp_servers.twitter.env]
|
|
96
|
+
RETTIWT_API_KEY = "your_key_here"
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
For a local build:
|
|
100
|
+
|
|
101
|
+
```toml
|
|
102
|
+
[mcp_servers.twitter]
|
|
103
|
+
command = "node"
|
|
104
|
+
args = ["/absolute/path/to/twitter-mcp/dist/cli.js"]
|
|
105
|
+
|
|
106
|
+
[mcp_servers.twitter.env]
|
|
107
|
+
RETTIWT_API_KEY = "your_key_here"
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Restart Codex after editing the file. The CLI, IDE extension, and desktop app share this configuration on the same computer.
|
|
111
|
+
|
|
112
|
+
### OpenCode
|
|
113
|
+
|
|
114
|
+
Add the npm package to `opencode.json` or `opencode.jsonc`:
|
|
115
|
+
|
|
116
|
+
```json
|
|
117
|
+
{
|
|
118
|
+
"$schema": "https://opencode.ai/config.json",
|
|
119
|
+
"mcp": {
|
|
120
|
+
"twitter": {
|
|
121
|
+
"type": "local",
|
|
122
|
+
"command": ["npx", "-y", "@granitebps/twitter-mcp"],
|
|
123
|
+
"enabled": true,
|
|
124
|
+
"environment": {
|
|
125
|
+
"RETTIWT_API_KEY": "your_key_here"
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
For a local build, replace the `command` array with:
|
|
133
|
+
|
|
134
|
+
```json
|
|
135
|
+
{
|
|
136
|
+
"command": ["node", "/absolute/path/to/twitter-mcp/dist/cli.js"]
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Cursor
|
|
141
|
+
|
|
142
|
+
Add the npm package to `.cursor/mcp.json` in a project, or to `~/.cursor/mcp.json` for global use:
|
|
143
|
+
|
|
144
|
+
```json
|
|
145
|
+
{
|
|
146
|
+
"mcpServers": {
|
|
147
|
+
"twitter": {
|
|
148
|
+
"command": "npx",
|
|
149
|
+
"args": ["-y", "@granitebps/twitter-mcp"],
|
|
150
|
+
"env": {
|
|
151
|
+
"RETTIWT_API_KEY": "your_key_here"
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
For a local build, replace `command` and `args` with:
|
|
159
|
+
|
|
160
|
+
```json
|
|
161
|
+
{
|
|
162
|
+
"command": "node",
|
|
163
|
+
"args": ["/absolute/path/to/twitter-mcp/dist/cli.js"]
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Providers
|
|
168
|
+
|
|
169
|
+
| Mode | Selection | Credentials | Notes |
|
|
170
|
+
| ------------ | ---------------------------------- | ------------------------------------------ | --------------------------------------------------------------------------------------------------- |
|
|
171
|
+
| Rettiwt | Default, or `TWITTER_MODE=rettiwt` | `RETTIWT_API_KEY` | Free of X API charges. Uses unofficial internal endpoints and may break or put the account at risk. |
|
|
172
|
+
| Official API | `TWITTER_MODE=api` | Bearer token or complete OAuth credentials | Uses the supported X API. X controls access tiers and pricing. |
|
|
173
|
+
|
|
174
|
+
### Rettiwt setup
|
|
175
|
+
|
|
176
|
+
Rettiwt requires authenticated user mode in this server. Guest mode is not supported.
|
|
177
|
+
|
|
178
|
+
1. Generate an API key using the [Rettiwt authentication instructions](https://github.com/Rishikant181/Rettiwt-API#authentication).
|
|
179
|
+
2. Store it as `RETTIWT_API_KEY` in the MCP client's environment.
|
|
180
|
+
3. Start the server without `TWITTER_MODE`, or set `TWITTER_MODE=rettiwt` explicitly.
|
|
181
|
+
|
|
182
|
+
A Rettiwt key contains X session cookies and has the same access as the account. Treat it like a password. Do not commit it, paste it into an issue, log it, or pass it as a command-line argument. Use a key only for an account you own or have permission to access.
|
|
183
|
+
|
|
184
|
+
Rettiwt is unofficial. X's [automation rules](https://help.x.com/en/rules-and-policies/x-automation) prohibit non-API website automation and warn that violations may lead to account suspension. Read the [X Rules](https://help.x.com/en/rules-and-policies/x-rules) before using this mode. You accept the compliance and account risk.
|
|
185
|
+
|
|
186
|
+
### Official X API setup
|
|
187
|
+
|
|
188
|
+
Use a bearer token:
|
|
189
|
+
|
|
190
|
+
```env
|
|
191
|
+
TWITTER_MODE=api
|
|
192
|
+
TWITTER_BEARER_TOKEN=your_bearer_token
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Or provide the complete OAuth set:
|
|
196
|
+
|
|
197
|
+
```env
|
|
198
|
+
TWITTER_MODE=api
|
|
199
|
+
TWITTER_API_KEY=your_api_key
|
|
200
|
+
TWITTER_API_SECRET=your_api_secret
|
|
201
|
+
TWITTER_ACCESS_TOKEN=your_access_token
|
|
202
|
+
TWITTER_ACCESS_SECRET=your_access_secret
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Create credentials in the [X Developer Portal](https://developer.x.com/en/portal/dashboard). X controls API access and pricing, so check the current terms before choosing this mode.
|
|
206
|
+
|
|
207
|
+
## Configuration
|
|
208
|
+
|
|
209
|
+
| Variable | Required | Meaning |
|
|
210
|
+
| ---------------------------- | --------------- | ----------------------------------------------------------- |
|
|
211
|
+
| `TWITTER_MODE` | No | `rettiwt` by default, or `api`. Other values fail startup. |
|
|
212
|
+
| `RETTIWT_API_KEY` | Rettiwt mode | Authenticated Rettiwt session key. |
|
|
213
|
+
| `TWITTER_BEARER_TOKEN` | API mode option | Official API bearer token. |
|
|
214
|
+
| `TWITTER_API_KEY` | OAuth option | OAuth application key. |
|
|
215
|
+
| `TWITTER_API_SECRET` | OAuth option | OAuth application secret. |
|
|
216
|
+
| `TWITTER_ACCESS_TOKEN` | OAuth option | OAuth access token. |
|
|
217
|
+
| `TWITTER_ACCESS_SECRET` | OAuth option | OAuth access secret. |
|
|
218
|
+
| `TWITTER_REQUEST_TIMEOUT_MS` | No | Request deadline from 1,000 to 120,000 ms. Default: 30,000. |
|
|
219
|
+
|
|
220
|
+
The server rejects an incomplete OAuth configuration at startup. It reads credentials from the process environment and never returns them through `get_server_info`.
|
|
221
|
+
|
|
222
|
+
## Tools
|
|
223
|
+
|
|
224
|
+
| Tool | Input | Result |
|
|
225
|
+
| ------------------- | ---------------------------------- | ------------------------------------------------------------------------------------ |
|
|
226
|
+
| `get_tweet` | `tweet_id` | One post. Accepts a numeric ID or an `x.com` or `twitter.com` status URL. |
|
|
227
|
+
| `get_tweet_replies` | `tweet_id`, optional `max_results` | Replies and available page metadata. |
|
|
228
|
+
| `get_user_profile` | `username` | One public profile. A leading `@` is accepted. |
|
|
229
|
+
| `search_tweets` | `query`, optional `max_results` | Matching posts and available page metadata. Search operators depend on the provider. |
|
|
230
|
+
| `get_server_info` | None | Version, active provider, tools, limits, and capabilities. |
|
|
231
|
+
|
|
232
|
+
`max_results` defaults to 10 and accepts 1 through 100. Successful calls return structured MCP content plus JSON text for older clients. Collection tools return the items as JSON text and put cursors and warnings in structured content.
|
|
233
|
+
|
|
234
|
+
## Errors
|
|
235
|
+
|
|
236
|
+
Tool failures use stable codes:
|
|
237
|
+
|
|
238
|
+
- `INVALID_INPUT`
|
|
239
|
+
- `AUTH_REQUIRED`
|
|
240
|
+
- `AUTH_FAILED`
|
|
241
|
+
- `NOT_FOUND`
|
|
242
|
+
- `RATE_LIMITED`
|
|
243
|
+
- `UPSTREAM_UNAVAILABLE`
|
|
244
|
+
- `TIMEOUT`
|
|
245
|
+
- `UNSUPPORTED_OPERATION`
|
|
246
|
+
- `INTERNAL_ERROR`
|
|
247
|
+
|
|
248
|
+
Errors name the provider and tell the client whether a retry may work. They do not include credentials or raw upstream response bodies.
|
|
249
|
+
|
|
250
|
+
## Architecture
|
|
251
|
+
|
|
252
|
+
```text
|
|
253
|
+
stdio CLI
|
|
254
|
+
-> validated environment configuration
|
|
255
|
+
-> MCP server and tool handlers
|
|
256
|
+
-> TwitterProvider contract
|
|
257
|
+
-> Rettiwt adapter
|
|
258
|
+
-> official X API adapter
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
The domain schemas do not depend on either provider. Each provider adapter maps upstream data, enforces limits and deadlines, and translates errors. Importing `src/index.ts` does not start the server.
|
|
262
|
+
|
|
263
|
+
## Development
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
npm ci
|
|
267
|
+
npm run check
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
`npm run check` checks formatting, lint, types, coverage, the production build, npm package contents, and a clean tarball installation. The default test suite uses fakes and does not need X credentials.
|
|
271
|
+
|
|
272
|
+
Useful focused commands:
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
npm test
|
|
276
|
+
npm run typecheck
|
|
277
|
+
npm run lint
|
|
278
|
+
npm run build
|
|
279
|
+
npm run check:package
|
|
280
|
+
npm run check:install
|
|
281
|
+
npx @modelcontextprotocol/inspector node dist/cli.js
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### Live Rettiwt smoke test
|
|
285
|
+
|
|
286
|
+
The live smoke test starts the compiled stdio server and calls `get_tweet`, `get_tweet_replies`, `get_user_profile`, and `search_tweets`. It derives the username and search query from the selected post.
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
RETTIWT_API_KEY=your_key_here \
|
|
290
|
+
TWITTER_LIVE_TWEET_ID=1234567890123456789 \
|
|
291
|
+
npm run test:live
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
Choose a public post whose author profile is still available. If either variable is missing, the command stops before starting the live server or making a network request. It does not run as part of `npm run check` or normal CI.
|
|
295
|
+
|
|
296
|
+
## Release verification
|
|
297
|
+
|
|
298
|
+
The automated suite covers configuration, provider adapters, MCP calls, the compiled stdio entry point, and installation from an npm tarball. The live Rettiwt smoke test is optional and does not run in normal CI. Version 1.0.0 was prepared without live upstream verification.
|
|
299
|
+
|
|
300
|
+
Maintainers can follow the [release guide](https://github.com/granitebps/twitter-mcp/blob/main/RELEASE.md) for the manual npm, MCP Registry, and GitHub release process. Live tests must read credentials from repository secrets and must not run for untrusted pull requests.
|
|
301
|
+
|
|
302
|
+
## Troubleshooting
|
|
303
|
+
|
|
304
|
+
### Missing Rettiwt key
|
|
305
|
+
|
|
306
|
+
If startup reports `RETTIWT_API_KEY is required in rettiwt mode`, set the key in the MCP client configuration. Desktop clients do not automatically inherit a shell's `.env` file.
|
|
307
|
+
|
|
308
|
+
### Invalid Rettiwt authentication
|
|
309
|
+
|
|
310
|
+
If you see `Invalid authentication data` or `AUTH_FAILED`, generate a new Rettiwt key and check that the X session still works. Never post the failing key in an issue.
|
|
311
|
+
|
|
312
|
+
### Rate limit
|
|
313
|
+
|
|
314
|
+
For `RATE_LIMITED`, wait before retrying and reduce the request rate. Check `retryAfterSeconds` when the provider supplies it.
|
|
315
|
+
|
|
316
|
+
### Official API 401 or 403
|
|
317
|
+
|
|
318
|
+
Confirm the credential set, app permissions, endpoint access, and current X API plan.
|
|
319
|
+
|
|
320
|
+
### Node engine warning
|
|
321
|
+
|
|
322
|
+
Run Node.js 22.21.0 or a newer Node 22 release. Do not use Node 23 or later with the current Rettiwt dependency.
|
|
323
|
+
|
|
324
|
+
## License
|
|
325
|
+
|
|
326
|
+
[ISC](LICENSE)
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { serveStdio } from "@modelcontextprotocol/server/stdio";
|
|
4
|
+
import { config as loadDotenv } from "dotenv";
|
|
5
|
+
import { loadConfig } from "./config/env.js";
|
|
6
|
+
import { redactSecrets } from "./errors/twitter-error.js";
|
|
7
|
+
import { createProvider } from "./providers/factory.js";
|
|
8
|
+
import { createTwitterServer } from "./server/create-server.js";
|
|
9
|
+
function packageVersion() {
|
|
10
|
+
const manifest = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
11
|
+
if (typeof manifest.version !== "string")
|
|
12
|
+
throw new Error("Package version is missing");
|
|
13
|
+
return manifest.version;
|
|
14
|
+
}
|
|
15
|
+
function reportFatal(error) {
|
|
16
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
17
|
+
console.error(`twitter-mcp: ${redactSecrets(message)}`);
|
|
18
|
+
}
|
|
19
|
+
async function main() {
|
|
20
|
+
loadDotenv({ quiet: true });
|
|
21
|
+
const runtimeConfig = loadConfig(process.env);
|
|
22
|
+
const provider = await createProvider(runtimeConfig);
|
|
23
|
+
const version = packageVersion();
|
|
24
|
+
const handle = serveStdio(() => createTwitterServer({ config: runtimeConfig, provider, version }), { onerror: reportFatal });
|
|
25
|
+
const close = () => {
|
|
26
|
+
void handle.close().catch(reportFatal);
|
|
27
|
+
};
|
|
28
|
+
process.once("SIGINT", close);
|
|
29
|
+
process.once("SIGTERM", close);
|
|
30
|
+
}
|
|
31
|
+
void main().catch((error) => {
|
|
32
|
+
reportFatal(error);
|
|
33
|
+
process.exitCode = 1;
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhE,SAAS,cAAc;IACrB,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CACzB,YAAY,CAAC,IAAI,GAAG,CAAC,iBAAiB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CACzC,CAAC;IAC3B,IAAI,OAAO,QAAQ,CAAC,OAAO,KAAK,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;IACxF,OAAO,QAAQ,CAAC,OAAO,CAAC;AAC1B,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvE,OAAO,CAAC,KAAK,CAAC,gBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AAC1D,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,UAAU,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5B,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC9C,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,aAAa,CAAC,CAAC;IACrD,MAAM,OAAO,GAAG,cAAc,EAAE,CAAC;IACjC,MAAM,MAAM,GAAG,UAAU,CACvB,GAAG,EAAE,CAAC,mBAAmB,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,EACvE,EAAE,OAAO,EAAE,WAAW,EAAE,CACzB,CAAC;IAEF,MAAM,KAAK,GAAG,GAAS,EAAE;QACvB,KAAK,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IACzC,CAAC,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC9B,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;AACjC,CAAC;AAED,KAAK,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IACnC,WAAW,CAAC,KAAK,CAAC,CAAC;IACnB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface RettiwtConfig {
|
|
2
|
+
mode: "rettiwt";
|
|
3
|
+
apiKey: string;
|
|
4
|
+
requestTimeoutMs: number;
|
|
5
|
+
}
|
|
6
|
+
export type ApiCredentials = {
|
|
7
|
+
type: "bearer";
|
|
8
|
+
token: string;
|
|
9
|
+
} | {
|
|
10
|
+
type: "oauth";
|
|
11
|
+
appKey: string;
|
|
12
|
+
appSecret: string;
|
|
13
|
+
accessToken: string;
|
|
14
|
+
accessSecret: string;
|
|
15
|
+
};
|
|
16
|
+
export interface ApiConfig {
|
|
17
|
+
mode: "api";
|
|
18
|
+
credentials: ApiCredentials;
|
|
19
|
+
requestTimeoutMs: number;
|
|
20
|
+
}
|
|
21
|
+
export type RuntimeConfig = RettiwtConfig | ApiConfig;
|
|
22
|
+
export declare function loadConfig(env: NodeJS.ProcessEnv): RuntimeConfig;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
function readNonEmpty(env, name) {
|
|
2
|
+
const value = env[name]?.trim();
|
|
3
|
+
return value ? value : undefined;
|
|
4
|
+
}
|
|
5
|
+
function readTimeout(env) {
|
|
6
|
+
const raw = readNonEmpty(env, "TWITTER_REQUEST_TIMEOUT_MS");
|
|
7
|
+
if (!raw)
|
|
8
|
+
return 30_000;
|
|
9
|
+
const value = Number(raw);
|
|
10
|
+
if (!Number.isInteger(value) || value < 1_000 || value > 120_000) {
|
|
11
|
+
throw new Error("TWITTER_REQUEST_TIMEOUT_MS must be an integer from 1000 to 120000");
|
|
12
|
+
}
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
export function loadConfig(env) {
|
|
16
|
+
const rawMode = readNonEmpty(env, "TWITTER_MODE")?.toLowerCase() ?? "rettiwt";
|
|
17
|
+
if (rawMode !== "rettiwt" && rawMode !== "api") {
|
|
18
|
+
throw new Error('TWITTER_MODE must be either "rettiwt" or "api"');
|
|
19
|
+
}
|
|
20
|
+
const requestTimeoutMs = readTimeout(env);
|
|
21
|
+
if (rawMode === "rettiwt") {
|
|
22
|
+
const apiKey = readNonEmpty(env, "RETTIWT_API_KEY");
|
|
23
|
+
if (!apiKey)
|
|
24
|
+
throw new Error("RETTIWT_API_KEY is required in rettiwt mode");
|
|
25
|
+
return { mode: "rettiwt", apiKey, requestTimeoutMs };
|
|
26
|
+
}
|
|
27
|
+
const bearer = readNonEmpty(env, "TWITTER_BEARER_TOKEN");
|
|
28
|
+
if (bearer) {
|
|
29
|
+
return { mode: "api", credentials: { type: "bearer", token: bearer }, requestTimeoutMs };
|
|
30
|
+
}
|
|
31
|
+
const appKey = readNonEmpty(env, "TWITTER_API_KEY");
|
|
32
|
+
const appSecret = readNonEmpty(env, "TWITTER_API_SECRET");
|
|
33
|
+
const accessToken = readNonEmpty(env, "TWITTER_ACCESS_TOKEN");
|
|
34
|
+
const accessSecret = readNonEmpty(env, "TWITTER_ACCESS_SECRET");
|
|
35
|
+
if (!appKey || !appSecret || !accessToken || !accessSecret) {
|
|
36
|
+
throw new Error("API mode requires TWITTER_BEARER_TOKEN or a complete OAuth credential set");
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
mode: "api",
|
|
40
|
+
credentials: { type: "oauth", appKey, appSecret, accessToken, accessSecret },
|
|
41
|
+
requestTimeoutMs,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=env.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/config/env.ts"],"names":[],"mappings":"AAwBA,SAAS,YAAY,CAAC,GAAsB,EAAE,IAAY;IACxD,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC;IAChC,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACnC,CAAC;AAED,SAAS,WAAW,CAAC,GAAsB;IACzC,MAAM,GAAG,GAAG,YAAY,CAAC,GAAG,EAAE,4BAA4B,CAAC,CAAC;IAC5D,IAAI,CAAC,GAAG;QAAE,OAAO,MAAM,CAAC;IAExB,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAC1B,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,KAAK,IAAI,KAAK,GAAG,OAAO,EAAE,CAAC;QACjE,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAC;IACvF,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,GAAsB;IAC/C,MAAM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O;QACL,IAAI,EAAE,KAAK;QACX,WAAW,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE;QAC5E,gBAAgB;KACjB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export interface GetTweetRequest {
|
|
2
|
+
tweetId: string;
|
|
3
|
+
}
|
|
4
|
+
export interface GetRepliesRequest {
|
|
5
|
+
tweetId: string;
|
|
6
|
+
maxResults: number;
|
|
7
|
+
}
|
|
8
|
+
export interface GetProfileRequest {
|
|
9
|
+
username: string;
|
|
10
|
+
}
|
|
11
|
+
export interface SearchTweetsRequest {
|
|
12
|
+
query: string;
|
|
13
|
+
maxResults: number;
|
|
14
|
+
}
|
|
15
|
+
export interface RequestContext {
|
|
16
|
+
signal: AbortSignal;
|
|
17
|
+
deadline: number;
|
|
18
|
+
}
|
|
19
|
+
export interface ProviderCapabilities {
|
|
20
|
+
provider: "rettiwt" | "api";
|
|
21
|
+
authenticated: boolean;
|
|
22
|
+
operations: {
|
|
23
|
+
getTweet: boolean;
|
|
24
|
+
getTweetReplies: boolean;
|
|
25
|
+
getUserProfile: boolean;
|
|
26
|
+
searchTweets: boolean;
|
|
27
|
+
};
|
|
28
|
+
pagination: {
|
|
29
|
+
replies: boolean;
|
|
30
|
+
search: boolean;
|
|
31
|
+
};
|
|
32
|
+
limits: {
|
|
33
|
+
replies: number;
|
|
34
|
+
search: number;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requests.js","sourceRoot":"","sources":["../../src/domain/requests.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const TweetMetricsSchema: z.ZodObject<{
|
|
3
|
+
likes: z.ZodNumber;
|
|
4
|
+
retweets: z.ZodNumber;
|
|
5
|
+
replies: z.ZodNumber;
|
|
6
|
+
quotes: z.ZodNumber;
|
|
7
|
+
bookmarks: z.ZodNumber;
|
|
8
|
+
views: z.ZodOptional<z.ZodNumber>;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
export declare const TweetAuthorSchema: z.ZodObject<{
|
|
11
|
+
name: z.ZodString;
|
|
12
|
+
username: z.ZodString;
|
|
13
|
+
verified: z.ZodOptional<z.ZodBoolean>;
|
|
14
|
+
blue_verified: z.ZodOptional<z.ZodBoolean>;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
export declare const TweetSchema: z.ZodObject<{
|
|
17
|
+
id: z.ZodString;
|
|
18
|
+
text: z.ZodString;
|
|
19
|
+
created_at: z.ZodOptional<z.ZodString>;
|
|
20
|
+
author: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
21
|
+
name: z.ZodString;
|
|
22
|
+
username: z.ZodString;
|
|
23
|
+
verified: z.ZodOptional<z.ZodBoolean>;
|
|
24
|
+
blue_verified: z.ZodOptional<z.ZodBoolean>;
|
|
25
|
+
}, z.core.$strip>>>;
|
|
26
|
+
metrics: z.ZodObject<{
|
|
27
|
+
likes: z.ZodNumber;
|
|
28
|
+
retweets: z.ZodNumber;
|
|
29
|
+
replies: z.ZodNumber;
|
|
30
|
+
quotes: z.ZodNumber;
|
|
31
|
+
bookmarks: z.ZodNumber;
|
|
32
|
+
views: z.ZodOptional<z.ZodNumber>;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
export declare const ProfileMetricsSchema: z.ZodObject<{
|
|
36
|
+
followers_count: z.ZodNumber;
|
|
37
|
+
following_count: z.ZodNumber;
|
|
38
|
+
tweet_count: z.ZodNumber;
|
|
39
|
+
listed_count: z.ZodNumber;
|
|
40
|
+
likes_count: z.ZodOptional<z.ZodNumber>;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
export declare const UserProfileSchema: z.ZodObject<{
|
|
43
|
+
id: z.ZodString;
|
|
44
|
+
name: z.ZodString;
|
|
45
|
+
username: z.ZodString;
|
|
46
|
+
description: z.ZodOptional<z.ZodString>;
|
|
47
|
+
created_at: z.ZodOptional<z.ZodString>;
|
|
48
|
+
verified: z.ZodBoolean;
|
|
49
|
+
blue_verified: z.ZodOptional<z.ZodBoolean>;
|
|
50
|
+
profile_image_url: z.ZodOptional<z.ZodString>;
|
|
51
|
+
location: z.ZodOptional<z.ZodString>;
|
|
52
|
+
url: z.ZodOptional<z.ZodString>;
|
|
53
|
+
metrics: z.ZodObject<{
|
|
54
|
+
followers_count: z.ZodNumber;
|
|
55
|
+
following_count: z.ZodNumber;
|
|
56
|
+
tweet_count: z.ZodNumber;
|
|
57
|
+
listed_count: z.ZodNumber;
|
|
58
|
+
likes_count: z.ZodOptional<z.ZodNumber>;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
}, z.core.$strip>;
|
|
61
|
+
export declare const ProviderWarningSchema: z.ZodObject<{
|
|
62
|
+
code: z.ZodString;
|
|
63
|
+
message: z.ZodString;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
export declare const TweetPageSchema: z.ZodObject<{
|
|
66
|
+
items: z.ZodArray<z.ZodObject<{
|
|
67
|
+
id: z.ZodString;
|
|
68
|
+
text: z.ZodString;
|
|
69
|
+
created_at: z.ZodOptional<z.ZodString>;
|
|
70
|
+
author: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
71
|
+
name: z.ZodString;
|
|
72
|
+
username: z.ZodString;
|
|
73
|
+
verified: z.ZodOptional<z.ZodBoolean>;
|
|
74
|
+
blue_verified: z.ZodOptional<z.ZodBoolean>;
|
|
75
|
+
}, z.core.$strip>>>;
|
|
76
|
+
metrics: z.ZodObject<{
|
|
77
|
+
likes: z.ZodNumber;
|
|
78
|
+
retweets: z.ZodNumber;
|
|
79
|
+
replies: z.ZodNumber;
|
|
80
|
+
quotes: z.ZodNumber;
|
|
81
|
+
bookmarks: z.ZodNumber;
|
|
82
|
+
views: z.ZodOptional<z.ZodNumber>;
|
|
83
|
+
}, z.core.$strip>;
|
|
84
|
+
}, z.core.$strip>>;
|
|
85
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
86
|
+
partial: z.ZodOptional<z.ZodBoolean>;
|
|
87
|
+
warnings: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
88
|
+
code: z.ZodString;
|
|
89
|
+
message: z.ZodString;
|
|
90
|
+
}, z.core.$strip>>>;
|
|
91
|
+
}, z.core.$strip>;
|
|
92
|
+
export type Tweet = z.infer<typeof TweetSchema>;
|
|
93
|
+
export type UserProfile = z.infer<typeof UserProfileSchema>;
|
|
94
|
+
export type ProviderWarning = z.infer<typeof ProviderWarningSchema>;
|
|
95
|
+
export type TweetPage = z.infer<typeof TweetPageSchema>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const TweetMetricsSchema = z.object({
|
|
3
|
+
likes: z.number().int().nonnegative(),
|
|
4
|
+
retweets: z.number().int().nonnegative(),
|
|
5
|
+
replies: z.number().int().nonnegative(),
|
|
6
|
+
quotes: z.number().int().nonnegative(),
|
|
7
|
+
bookmarks: z.number().int().nonnegative(),
|
|
8
|
+
views: z.number().int().nonnegative().optional(),
|
|
9
|
+
});
|
|
10
|
+
export const TweetAuthorSchema = z.object({
|
|
11
|
+
name: z.string(),
|
|
12
|
+
username: z.string(),
|
|
13
|
+
verified: z.boolean().optional(),
|
|
14
|
+
blue_verified: z.boolean().optional(),
|
|
15
|
+
});
|
|
16
|
+
export const TweetSchema = z.object({
|
|
17
|
+
id: z.string(),
|
|
18
|
+
text: z.string(),
|
|
19
|
+
created_at: z.string().optional(),
|
|
20
|
+
author: TweetAuthorSchema.nullable().optional(),
|
|
21
|
+
metrics: TweetMetricsSchema,
|
|
22
|
+
});
|
|
23
|
+
export const ProfileMetricsSchema = z.object({
|
|
24
|
+
followers_count: z.number().int().nonnegative(),
|
|
25
|
+
following_count: z.number().int().nonnegative(),
|
|
26
|
+
tweet_count: z.number().int().nonnegative(),
|
|
27
|
+
listed_count: z.number().int().nonnegative(),
|
|
28
|
+
likes_count: z.number().int().nonnegative().optional(),
|
|
29
|
+
});
|
|
30
|
+
export const UserProfileSchema = z.object({
|
|
31
|
+
id: z.string(),
|
|
32
|
+
name: z.string(),
|
|
33
|
+
username: z.string(),
|
|
34
|
+
description: z.string().optional(),
|
|
35
|
+
created_at: z.string().optional(),
|
|
36
|
+
verified: z.boolean(),
|
|
37
|
+
blue_verified: z.boolean().optional(),
|
|
38
|
+
profile_image_url: z.string().optional(),
|
|
39
|
+
location: z.string().optional(),
|
|
40
|
+
url: z.string().optional(),
|
|
41
|
+
metrics: ProfileMetricsSchema,
|
|
42
|
+
});
|
|
43
|
+
export const ProviderWarningSchema = z.object({
|
|
44
|
+
code: z.string(),
|
|
45
|
+
message: z.string(),
|
|
46
|
+
});
|
|
47
|
+
export const TweetPageSchema = z.object({
|
|
48
|
+
items: z.array(TweetSchema),
|
|
49
|
+
nextCursor: z.string().optional(),
|
|
50
|
+
partial: z.boolean().optional(),
|
|
51
|
+
warnings: z.array(ProviderWarningSchema).optional(),
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/domain/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;IACrC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;IACxC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;IACvC,MAAM,EAAE,CAAC,CAAC,MAAM,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Q,EAAE;CACpD,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type TwitterErrorCode = "INVALID_INPUT" | "AUTH_REQUIRED" | "AUTH_FAILED" | "NOT_FOUND" | "RATE_LIMITED" | "UPSTREAM_UNAVAILABLE" | "TIMEOUT" | "UNSUPPORTED_OPERATION" | "INTERNAL_ERROR";
|
|
2
|
+
export type ProviderName = "rettiwt" | "api";
|
|
3
|
+
export interface TwitterErrorOptions {
|
|
4
|
+
code: TwitterErrorCode;
|
|
5
|
+
safeMessage: string;
|
|
6
|
+
provider: ProviderName;
|
|
7
|
+
retryable: boolean;
|
|
8
|
+
retryAfterSeconds?: number;
|
|
9
|
+
cause?: unknown;
|
|
10
|
+
}
|
|
11
|
+
export declare class TwitterError extends Error {
|
|
12
|
+
readonly code: TwitterErrorCode;
|
|
13
|
+
readonly safeMessage: string;
|
|
14
|
+
readonly provider: ProviderName;
|
|
15
|
+
readonly retryable: boolean;
|
|
16
|
+
readonly retryAfterSeconds: number | undefined;
|
|
17
|
+
constructor(options: TwitterErrorOptions);
|
|
18
|
+
}
|
|
19
|
+
export declare function redactSecrets(value: string): string;
|
|
20
|
+
export declare function toTwitterError(error: unknown, provider: ProviderName): TwitterError;
|