redfox-twitter-mcp 0.1.0__tar.gz

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.
@@ -0,0 +1,6 @@
1
+ __pycache__/
2
+ *.pyc
3
+ .venv/
4
+ dist/
5
+ *.egg-info/
6
+ .DS_Store
@@ -0,0 +1,117 @@
1
+ Metadata-Version: 2.5
2
+ Name: redfox-twitter-mcp
3
+ Version: 0.1.0
4
+ Summary: RedFoxHub X(Twitter) MCP server: tweet search/detail, user info, comments
5
+ Project-URL: Homepage, https://github.com/redfox-data/redfox-mcp
6
+ Project-URL: Website, https://redfox.hk/apis/?source=mcp
7
+ License-Expression: MIT
8
+ Keywords: mcp,redfox,twitter,x
9
+ Requires-Python: >=3.10
10
+ Requires-Dist: redfox-mcp-core>=0.1.0
11
+ Description-Content-Type: text/markdown
12
+
13
+ # redfox-twitter-mcp
14
+
15
+ RedFoxHub X(Twitter) 数据 MCP Server — 将 X(Twitter) 数据 API 封装为 4 个 MCP 工具,适用于 dsh、Claude Code、Cursor 等任意 MCP 客户端。
16
+
17
+ ## 工具(4)
18
+
19
+ | 工具 | 说明 |
20
+ |---|---|
21
+ | `twitter_search_tweets` | X(Twitter) 关键词搜索推文 |
22
+ | `twitter_get_tweet` | 获取 X(Twitter) 单条推文详情 |
23
+ | `twitter_get_user` | 获取 X(Twitter) 用户信息 |
24
+ | `twitter_get_comments` | 获取 X(Twitter) 推文评论/回复 |
25
+
26
+ ## 认证
27
+
28
+ 1. 前往 <https://redfox.hk/settings/api-keys?source=mcp> 获取 API Key
29
+ 2. 设置环境变量:
30
+
31
+ ```bash
32
+ export REDFOX_API_KEY="YOUR_API_KEY"
33
+ ```
34
+
35
+ 未配置 key 时,每个工具都会返回结构化的获取引导。
36
+
37
+ ## 安装与运行(本地 stdio)
38
+
39
+ 需要 Python ≥ 3.10,推荐使用 [uv](https://docs.astral.sh/uv/):
40
+
41
+ ```bash
42
+ uvx redfox-twitter-mcp
43
+ ```
44
+
45
+ 或:
46
+
47
+ ```bash
48
+ pip install redfox-twitter-mcp
49
+ redfox-twitter-mcp
50
+ ```
51
+
52
+ ## 客户端配置
53
+
54
+ Claude Code:
55
+
56
+ ```bash
57
+ claude mcp add redfox-twitter --env REDFOX_API_KEY=YOUR_API_KEY -- uvx redfox-twitter-mcp
58
+ ```
59
+
60
+ Cursor / 其他 MCP 客户端:
61
+
62
+ ```json
63
+ {
64
+ "mcpServers": {
65
+ "redfox-twitter": {
66
+ "command": "uvx",
67
+ "args": ["redfox-twitter-mcp"],
68
+ "env": { "REDFOX_API_KEY": "YOUR_API_KEY" }
69
+ }
70
+ }
71
+ }
72
+ ```
73
+
74
+ ## 远程 HTTP 模式(多租户)
75
+
76
+ 适用于 MCP 市场与托管场景,每个用户携带自己的 API Key:
77
+
78
+ ```bash
79
+ redfox-twitter-mcp --transport http --host 0.0.0.0 --port 8000
80
+ # 或环境变量:REDFOX_MCP_TRANSPORT=http REDFOX_MCP_HOST=0.0.0.0 REDFOX_MCP_PORT=8000
81
+ ```
82
+
83
+ - MCP 端点:`http://<host>:8000/mcp`(Streamable HTTP);健康检查:`GET /health`
84
+ - 每个请求通过请求头 `X-API-Key: <key>`(或 `Authorization: Bearer <key>`)携带自己的 key,按 key 建独立客户端缓存,额度互不共享
85
+
86
+ 客户端配置(远程 URL + 请求头):
87
+
88
+ ```json
89
+ {
90
+ "mcpServers": {
91
+ "redfox-twitter": {
92
+ "url": "http://<host>:8000/mcp",
93
+ "headers": { "X-API-Key": "ak_your_key" }
94
+ }
95
+ }
96
+ }
97
+ ```
98
+
99
+ ## Docker 部署
100
+
101
+ 本包目录自带 Dockerfile,可独立构建部署:
102
+
103
+ ```bash
104
+ cd packages/redfox-twitter-mcp
105
+ docker build -t redfox-twitter-mcp .
106
+ docker run -d -p 8000:8000 redfox-twitter-mcp
107
+ ```
108
+
109
+ 镜像不内置任何 API Key,调用方通过请求头携带自己的 key。
110
+
111
+ ## 底层实现
112
+
113
+ 基于官方 SDK [redfox-python-sdk](https://github.com/redfox-data/redfox-python-sdk)。API 文档:<https://redfox.hk/?source=mcp>。
114
+
115
+ ## License
116
+
117
+ MIT
@@ -0,0 +1,105 @@
1
+ # redfox-twitter-mcp
2
+
3
+ RedFoxHub X(Twitter) 数据 MCP Server — 将 X(Twitter) 数据 API 封装为 4 个 MCP 工具,适用于 dsh、Claude Code、Cursor 等任意 MCP 客户端。
4
+
5
+ ## 工具(4)
6
+
7
+ | 工具 | 说明 |
8
+ |---|---|
9
+ | `twitter_search_tweets` | X(Twitter) 关键词搜索推文 |
10
+ | `twitter_get_tweet` | 获取 X(Twitter) 单条推文详情 |
11
+ | `twitter_get_user` | 获取 X(Twitter) 用户信息 |
12
+ | `twitter_get_comments` | 获取 X(Twitter) 推文评论/回复 |
13
+
14
+ ## 认证
15
+
16
+ 1. 前往 <https://redfox.hk/settings/api-keys?source=mcp> 获取 API Key
17
+ 2. 设置环境变量:
18
+
19
+ ```bash
20
+ export REDFOX_API_KEY="YOUR_API_KEY"
21
+ ```
22
+
23
+ 未配置 key 时,每个工具都会返回结构化的获取引导。
24
+
25
+ ## 安装与运行(本地 stdio)
26
+
27
+ 需要 Python ≥ 3.10,推荐使用 [uv](https://docs.astral.sh/uv/):
28
+
29
+ ```bash
30
+ uvx redfox-twitter-mcp
31
+ ```
32
+
33
+ 或:
34
+
35
+ ```bash
36
+ pip install redfox-twitter-mcp
37
+ redfox-twitter-mcp
38
+ ```
39
+
40
+ ## 客户端配置
41
+
42
+ Claude Code:
43
+
44
+ ```bash
45
+ claude mcp add redfox-twitter --env REDFOX_API_KEY=YOUR_API_KEY -- uvx redfox-twitter-mcp
46
+ ```
47
+
48
+ Cursor / 其他 MCP 客户端:
49
+
50
+ ```json
51
+ {
52
+ "mcpServers": {
53
+ "redfox-twitter": {
54
+ "command": "uvx",
55
+ "args": ["redfox-twitter-mcp"],
56
+ "env": { "REDFOX_API_KEY": "YOUR_API_KEY" }
57
+ }
58
+ }
59
+ }
60
+ ```
61
+
62
+ ## 远程 HTTP 模式(多租户)
63
+
64
+ 适用于 MCP 市场与托管场景,每个用户携带自己的 API Key:
65
+
66
+ ```bash
67
+ redfox-twitter-mcp --transport http --host 0.0.0.0 --port 8000
68
+ # 或环境变量:REDFOX_MCP_TRANSPORT=http REDFOX_MCP_HOST=0.0.0.0 REDFOX_MCP_PORT=8000
69
+ ```
70
+
71
+ - MCP 端点:`http://<host>:8000/mcp`(Streamable HTTP);健康检查:`GET /health`
72
+ - 每个请求通过请求头 `X-API-Key: <key>`(或 `Authorization: Bearer <key>`)携带自己的 key,按 key 建独立客户端缓存,额度互不共享
73
+
74
+ 客户端配置(远程 URL + 请求头):
75
+
76
+ ```json
77
+ {
78
+ "mcpServers": {
79
+ "redfox-twitter": {
80
+ "url": "http://<host>:8000/mcp",
81
+ "headers": { "X-API-Key": "ak_your_key" }
82
+ }
83
+ }
84
+ }
85
+ ```
86
+
87
+ ## Docker 部署
88
+
89
+ 本包目录自带 Dockerfile,可独立构建部署:
90
+
91
+ ```bash
92
+ cd packages/redfox-twitter-mcp
93
+ docker build -t redfox-twitter-mcp .
94
+ docker run -d -p 8000:8000 redfox-twitter-mcp
95
+ ```
96
+
97
+ 镜像不内置任何 API Key,调用方通过请求头携带自己的 key。
98
+
99
+ ## 底层实现
100
+
101
+ 基于官方 SDK [redfox-python-sdk](https://github.com/redfox-data/redfox-python-sdk)。API 文档:<https://redfox.hk/?source=mcp>。
102
+
103
+ ## License
104
+
105
+ MIT
@@ -0,0 +1,31 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "redfox-twitter-mcp"
7
+ version = "0.1.0"
8
+ description = "RedFoxHub X(Twitter) MCP server: tweet search/detail, user info, comments"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "MIT"
12
+ keywords = ["mcp", "redfox", "twitter", "x"]
13
+ dependencies = [
14
+ "redfox-mcp-core>=0.1.0",
15
+ ]
16
+
17
+ [project.urls]
18
+ Homepage = "https://github.com/redfox-data/redfox-mcp"
19
+ Website = "https://redfox.hk/apis/?source=mcp"
20
+
21
+ [project.scripts]
22
+ redfox-twitter-mcp = "redfox_twitter_mcp.server:main"
23
+
24
+ [tool.uv.sources]
25
+ redfox-mcp-core = { workspace = true }
26
+
27
+ [tool.hatch.build.targets.wheel]
28
+ packages = ["src/redfox_twitter_mcp"]
29
+
30
+ [tool.hatch.build.targets.sdist]
31
+ include = ["src/redfox_twitter_mcp", "README.md"]
@@ -0,0 +1,3 @@
1
+ """RedFox X(Twitter) MCP Server"""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,4 @@
1
+ from .server import main
2
+
3
+ if __name__ == "__main__":
4
+ main()
@@ -0,0 +1,55 @@
1
+ """RedFox X(Twitter) 数据 MCP Server
2
+
3
+ 将 RedFoxHub(红狐数据平台)的 X(Twitter) 数据 API 暴露为 MCP 工具。
4
+
5
+ 认证:stdio 模式读环境变量 REDFOX_API_KEY;HTTP 模式从请求头
6
+ X-API-Key(或 Authorization: Bearer <key>)取 key。
7
+ 获取地址 https://redfox.hk/settings/api-keys?source=mcp
8
+ """
9
+
10
+ from typing import Any, Dict, Optional
11
+
12
+ from redfox_mcp_core import call, create_server, get_client, serve
13
+
14
+ from redfox_twitter_mcp import __version__
15
+
16
+ mcp = create_server("redfox-twitter", __version__)
17
+
18
+
19
+ @mcp.tool()
20
+ def twitter_search_tweets(keyword: str, search_type: Optional[str] = None,
21
+ cursor: Optional[str] = None) -> Dict[str, Any]:
22
+ """X(Twitter) 关键词搜索推文。keyword 必填;
23
+ search_type:Top/Latest/Media/People/Lists;cursor 用于翻页。"""
24
+ return call(lambda: get_client().twitter.search_tweets,
25
+ keyword=keyword, search_type=search_type, cursor=cursor)
26
+
27
+
28
+ @mcp.tool()
29
+ def twitter_get_tweet(tweet_id: str) -> Dict[str, Any]:
30
+ """获取 X(Twitter) 单条推文详情。tweet_id 为推文 ID(必填)。"""
31
+ return call(lambda: get_client().twitter.get_tweet, tweet_id=tweet_id)
32
+
33
+
34
+ @mcp.tool()
35
+ def twitter_get_user(screen_name: Optional[str] = None,
36
+ rest_id: Optional[str] = None) -> Dict[str, Any]:
37
+ """获取 X(Twitter) 用户信息。screen_name 与 rest_id 至少传一个。"""
38
+ return call(lambda: get_client().twitter.get_user,
39
+ screen_name=screen_name, rest_id=rest_id)
40
+
41
+
42
+ @mcp.tool()
43
+ def twitter_get_comments(tweet_id: str,
44
+ cursor: Optional[str] = None) -> Dict[str, Any]:
45
+ """获取 X(Twitter) 推文评论/回复。tweet_id 必填;cursor 用于翻页。"""
46
+ return call(lambda: get_client().twitter.get_comments,
47
+ tweet_id=tweet_id, cursor=cursor)
48
+
49
+
50
+ def main() -> None:
51
+ serve(mcp, prog="redfox-twitter-mcp", description="RedFox X(Twitter) MCP server")
52
+
53
+
54
+ if __name__ == "__main__":
55
+ main()