feedmcp-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.
- feedmcp_mcp-0.1.0/.gitignore +9 -0
- feedmcp_mcp-0.1.0/LICENSE +21 -0
- feedmcp_mcp-0.1.0/PKG-INFO +47 -0
- feedmcp_mcp-0.1.0/README.md +25 -0
- feedmcp_mcp-0.1.0/feedmcp_mcp/__init__.py +3 -0
- feedmcp_mcp-0.1.0/feedmcp_mcp/__main__.py +176 -0
- feedmcp_mcp-0.1.0/pyproject.toml +50 -0
- feedmcp_mcp-0.1.0/tests/test_bridge.py +113 -0
- feedmcp_mcp-0.1.0/uv.lock +104 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 FeedMCP
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: feedmcp-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: FeedMCP stdio MCP bridge for Claude Desktop, Cursor, Cherry Studio, Cline, Windsurf, and uvx — public social media, creator marketing, ad library, and search trend data across 21 global and Chinese platforms (193 endpoints).
|
|
5
|
+
Project-URL: Homepage, https://feedmcp.com/mcp/?utm_source=mcp_stdio_pypi
|
|
6
|
+
Project-URL: Documentation, https://feedmcp.com/docs/?utm_source=mcp_stdio_pypi
|
|
7
|
+
Project-URL: Repository, https://github.com/FeedMCP/feedmcp-mcp
|
|
8
|
+
Project-URL: Issues, https://github.com/FeedMCP/feedmcp-mcp/issues
|
|
9
|
+
Author-email: FeedMCP <support@feedmcp.com>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: bilibili,douyin,feedmcp,mcp,mcp-server,model-context-protocol,rednote,social-media-api,tiktok,twitter,wechat,weibo,xiaohongshu,youtube,zhihu
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Requires-Python: <4.0,>=3.10
|
|
20
|
+
Requires-Dist: httpx<1.0,>=0.27
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# feedmcp-mcp (`uvx feedmcp-mcp`)
|
|
24
|
+
|
|
25
|
+
Python stdio-to-Streamable-HTTP MCP bridge for **FeedMCP** (`https://api.feedmcp.com/mcp`) — read-only public social media, creator marketing, ad library, and search trend data across **21 global and Chinese platforms (193 endpoints)**.
|
|
26
|
+
|
|
27
|
+
> [Website & Docs](https://feedmcp.com/mcp/?utm_source=mcp_stdio_pypi) · [Get an API Key ($0.10 free trial, no card)](https://feedmcp.com/console/keys/?utm_source=mcp_stdio_pypi) · [GitHub](https://github.com/FeedMCP/feedmcp-mcp)
|
|
28
|
+
|
|
29
|
+
## Quick Start (`uvx`)
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"mcpServers": {
|
|
34
|
+
"feedmcp": {
|
|
35
|
+
"command": "uvx",
|
|
36
|
+
"args": ["feedmcp-mcp"],
|
|
37
|
+
"env": {
|
|
38
|
+
"FEEDMCP_API_KEY": "fmk_live_your_api_key"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
- `find` and `describe` work without `FEEDMCP_API_KEY` and are always free.
|
|
46
|
+
- `call` is pay-per-call from `$0.0003`; failed calls are free.
|
|
47
|
+
- Node.js alternative: `npx -y @feedmcp/mcp`.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# feedmcp-mcp (`uvx feedmcp-mcp`)
|
|
2
|
+
|
|
3
|
+
Python stdio-to-Streamable-HTTP MCP bridge for **FeedMCP** (`https://api.feedmcp.com/mcp`) — read-only public social media, creator marketing, ad library, and search trend data across **21 global and Chinese platforms (193 endpoints)**.
|
|
4
|
+
|
|
5
|
+
> [Website & Docs](https://feedmcp.com/mcp/?utm_source=mcp_stdio_pypi) · [Get an API Key ($0.10 free trial, no card)](https://feedmcp.com/console/keys/?utm_source=mcp_stdio_pypi) · [GitHub](https://github.com/FeedMCP/feedmcp-mcp)
|
|
6
|
+
|
|
7
|
+
## Quick Start (`uvx`)
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{
|
|
11
|
+
"mcpServers": {
|
|
12
|
+
"feedmcp": {
|
|
13
|
+
"command": "uvx",
|
|
14
|
+
"args": ["feedmcp-mcp"],
|
|
15
|
+
"env": {
|
|
16
|
+
"FEEDMCP_API_KEY": "fmk_live_your_api_key"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
- `find` and `describe` work without `FEEDMCP_API_KEY` and are always free.
|
|
24
|
+
- `call` is pay-per-call from `$0.0003`; failed calls are free.
|
|
25
|
+
- Node.js alternative: `npx -y @feedmcp/mcp`.
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"""CLI entrypoint for `uvx feedmcp-mcp` / `python -m feedmcp_mcp`."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import json
|
|
7
|
+
import os
|
|
8
|
+
import sys
|
|
9
|
+
from typing import TextIO
|
|
10
|
+
|
|
11
|
+
import httpx
|
|
12
|
+
|
|
13
|
+
from feedmcp_mcp import __version__
|
|
14
|
+
|
|
15
|
+
DEFAULT_MCP_URL = "https://api.feedmcp.com/mcp"
|
|
16
|
+
DEFAULT_TIMEOUT = 60.0
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def parse_sse_payloads(text: str) -> list[str]:
|
|
20
|
+
events: list[str] = []
|
|
21
|
+
for block in text.replace("\r\n", "\n").split("\n\n"):
|
|
22
|
+
data_lines = [
|
|
23
|
+
line[5:].lstrip()
|
|
24
|
+
for line in block.split("\n")
|
|
25
|
+
if line.startswith("data:")
|
|
26
|
+
]
|
|
27
|
+
if data_lines:
|
|
28
|
+
payload = "\n".join(data_lines).strip()
|
|
29
|
+
if payload and payload != "[DONE]":
|
|
30
|
+
events.append(payload)
|
|
31
|
+
return events
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class StdioHttpBridge:
|
|
35
|
+
def __init__(
|
|
36
|
+
self,
|
|
37
|
+
*,
|
|
38
|
+
url: str = DEFAULT_MCP_URL,
|
|
39
|
+
api_key: str = "",
|
|
40
|
+
timeout: float = DEFAULT_TIMEOUT,
|
|
41
|
+
stdin: TextIO = sys.stdin,
|
|
42
|
+
stdout: TextIO = sys.stdout,
|
|
43
|
+
stderr: TextIO = sys.stderr,
|
|
44
|
+
transport: httpx.BaseTransport | None = None,
|
|
45
|
+
) -> None:
|
|
46
|
+
self.url = url
|
|
47
|
+
self.api_key = api_key.strip()
|
|
48
|
+
self.timeout = timeout
|
|
49
|
+
self.stdin = stdin
|
|
50
|
+
self.stdout = stdout
|
|
51
|
+
self.stderr = stderr
|
|
52
|
+
self.transport = transport
|
|
53
|
+
self.session_id: str | None = None
|
|
54
|
+
|
|
55
|
+
def _write_line(self, line: str) -> bool:
|
|
56
|
+
try:
|
|
57
|
+
self.stdout.write(f"{line}\n")
|
|
58
|
+
self.stdout.flush()
|
|
59
|
+
return True
|
|
60
|
+
except BrokenPipeError:
|
|
61
|
+
return False
|
|
62
|
+
|
|
63
|
+
def _write_rpc_error(self, msg_id: object, code: int, message: str) -> bool:
|
|
64
|
+
if msg_id is None:
|
|
65
|
+
return True
|
|
66
|
+
return self._write_line(
|
|
67
|
+
json.dumps(
|
|
68
|
+
{"jsonrpc": "2.0", "id": msg_id, "error": {"code": code, "message": message}},
|
|
69
|
+
ensure_ascii=False,
|
|
70
|
+
)
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
def forward_line(self, raw_line: str, client: httpx.Client) -> bool:
|
|
74
|
+
trimmed = raw_line.strip()
|
|
75
|
+
if not trimmed:
|
|
76
|
+
return True
|
|
77
|
+
try:
|
|
78
|
+
parsed = json.loads(trimmed)
|
|
79
|
+
except json.JSONDecodeError as exc:
|
|
80
|
+
self.stderr.write(f"[feedmcp-mcp] invalid JSON on stdin: {exc}\n")
|
|
81
|
+
return True
|
|
82
|
+
|
|
83
|
+
is_notification = isinstance(parsed, dict) and "id" not in parsed
|
|
84
|
+
msg_id = parsed.get("id") if isinstance(parsed, dict) else None
|
|
85
|
+
|
|
86
|
+
headers = {
|
|
87
|
+
"Content-Type": "application/json",
|
|
88
|
+
"Accept": "application/json, text/event-stream",
|
|
89
|
+
"User-Agent": f"feedmcp-mcp/{__version__}",
|
|
90
|
+
}
|
|
91
|
+
if self.api_key:
|
|
92
|
+
headers["Authorization"] = (
|
|
93
|
+
self.api_key if self.api_key.startswith("Bearer ") else f"Bearer {self.api_key}"
|
|
94
|
+
)
|
|
95
|
+
if self.session_id:
|
|
96
|
+
headers["Mcp-Session-Id"] = self.session_id
|
|
97
|
+
|
|
98
|
+
try:
|
|
99
|
+
resp = client.post(self.url, content=trimmed.encode("utf-8"), headers=headers)
|
|
100
|
+
except Exception as exc:
|
|
101
|
+
if not is_notification:
|
|
102
|
+
return self._write_rpc_error(msg_id, -32000, f"Network error contacting {self.url}: {exc}")
|
|
103
|
+
self.stderr.write(f"[feedmcp-mcp] network error: {exc}\n")
|
|
104
|
+
return True
|
|
105
|
+
|
|
106
|
+
returned_session = resp.headers.get("mcp-session-id")
|
|
107
|
+
if returned_session:
|
|
108
|
+
self.session_id = returned_session
|
|
109
|
+
|
|
110
|
+
if resp.status_code in (202, 204):
|
|
111
|
+
return True
|
|
112
|
+
|
|
113
|
+
body_text = resp.text
|
|
114
|
+
if resp.is_error:
|
|
115
|
+
if body_text.strip().startswith("{"):
|
|
116
|
+
try:
|
|
117
|
+
maybe_rpc = json.loads(body_text)
|
|
118
|
+
if isinstance(maybe_rpc, dict) and maybe_rpc.get("jsonrpc") == "2.0":
|
|
119
|
+
return True if is_notification else self._write_line(json.dumps(maybe_rpc, ensure_ascii=False))
|
|
120
|
+
except Exception:
|
|
121
|
+
pass
|
|
122
|
+
if not is_notification:
|
|
123
|
+
return self._write_rpc_error(
|
|
124
|
+
msg_id,
|
|
125
|
+
-32000,
|
|
126
|
+
f"Upstream MCP HTTP {resp.status_code}: {body_text[:300] or resp.reason_phrase}",
|
|
127
|
+
)
|
|
128
|
+
return True
|
|
129
|
+
|
|
130
|
+
if is_notification or not body_text.strip():
|
|
131
|
+
return True
|
|
132
|
+
|
|
133
|
+
content_type = resp.headers.get("content-type", "").lower()
|
|
134
|
+
if "text/event-stream" in content_type:
|
|
135
|
+
for payload in parse_sse_payloads(body_text):
|
|
136
|
+
if not self._write_line(payload):
|
|
137
|
+
return False
|
|
138
|
+
return True
|
|
139
|
+
|
|
140
|
+
try:
|
|
141
|
+
normalized = json.dumps(json.loads(body_text), ensure_ascii=False)
|
|
142
|
+
except Exception:
|
|
143
|
+
normalized = body_text.strip()
|
|
144
|
+
return self._write_line(normalized)
|
|
145
|
+
|
|
146
|
+
def run(self) -> int:
|
|
147
|
+
with httpx.Client(timeout=self.timeout, transport=self.transport) as client:
|
|
148
|
+
for line in self.stdin:
|
|
149
|
+
if not self.forward_line(line, client):
|
|
150
|
+
return 0
|
|
151
|
+
return 0
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
155
|
+
p = argparse.ArgumentParser(
|
|
156
|
+
prog="feedmcp-mcp",
|
|
157
|
+
description="FeedMCP stdio-to-Streamable-HTTP MCP bridge (https://api.feedmcp.com/mcp)",
|
|
158
|
+
)
|
|
159
|
+
p.add_argument("-v", "--version", action="store_true", help="Print version and exit")
|
|
160
|
+
p.add_argument("-u", "--url", default=os.environ.get("FEEDMCP_MCP_URL", DEFAULT_MCP_URL), help="Remote MCP URL")
|
|
161
|
+
p.add_argument("-k", "--api-key", default=os.environ.get("FEEDMCP_API_KEY", ""), help="FeedMCP Bearer API key")
|
|
162
|
+
p.add_argument("--timeout", type=float, default=float(os.environ.get("FEEDMCP_TIMEOUT_MS", "60000")) / 1000.0)
|
|
163
|
+
return p
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def main(argv: list[str] | None = None) -> int:
|
|
167
|
+
args = build_parser().parse_args(argv)
|
|
168
|
+
if args.version:
|
|
169
|
+
print(__version__)
|
|
170
|
+
return 0
|
|
171
|
+
bridge = StdioHttpBridge(url=args.url, api_key=args.api_key, timeout=args.timeout)
|
|
172
|
+
return bridge.run()
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
if __name__ == "__main__":
|
|
176
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "feedmcp-mcp"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "FeedMCP stdio MCP bridge for Claude Desktop, Cursor, Cherry Studio, Cline, Windsurf, and uvx — public social media, creator marketing, ad library, and search trend data across 21 global and Chinese platforms (193 endpoints)."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.10,<4.0"
|
|
12
|
+
authors = [{ name = "FeedMCP", email = "support@feedmcp.com" }]
|
|
13
|
+
keywords = [
|
|
14
|
+
"mcp",
|
|
15
|
+
"mcp-server",
|
|
16
|
+
"model-context-protocol",
|
|
17
|
+
"feedmcp",
|
|
18
|
+
"xiaohongshu",
|
|
19
|
+
"rednote",
|
|
20
|
+
"douyin",
|
|
21
|
+
"wechat",
|
|
22
|
+
"weibo",
|
|
23
|
+
"bilibili",
|
|
24
|
+
"zhihu",
|
|
25
|
+
"tiktok",
|
|
26
|
+
"youtube",
|
|
27
|
+
"twitter",
|
|
28
|
+
"social-media-api",
|
|
29
|
+
]
|
|
30
|
+
classifiers = [
|
|
31
|
+
"Programming Language :: Python :: 3",
|
|
32
|
+
"Programming Language :: Python :: 3.10",
|
|
33
|
+
"Programming Language :: Python :: 3.11",
|
|
34
|
+
"Programming Language :: Python :: 3.12",
|
|
35
|
+
"Intended Audience :: Developers",
|
|
36
|
+
"License :: OSI Approved :: MIT License",
|
|
37
|
+
]
|
|
38
|
+
dependencies = ["httpx>=0.27,<1.0"]
|
|
39
|
+
|
|
40
|
+
[project.scripts]
|
|
41
|
+
feedmcp-mcp = "feedmcp_mcp.__main__:main"
|
|
42
|
+
|
|
43
|
+
[project.urls]
|
|
44
|
+
Homepage = "https://feedmcp.com/mcp/?utm_source=mcp_stdio_pypi"
|
|
45
|
+
Documentation = "https://feedmcp.com/docs/?utm_source=mcp_stdio_pypi"
|
|
46
|
+
Repository = "https://github.com/FeedMCP/feedmcp-mcp"
|
|
47
|
+
Issues = "https://github.com/FeedMCP/feedmcp-mcp/issues"
|
|
48
|
+
|
|
49
|
+
[tool.hatch.build.targets.wheel]
|
|
50
|
+
packages = ["feedmcp_mcp"]
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import io
|
|
2
|
+
import json
|
|
3
|
+
import unittest
|
|
4
|
+
|
|
5
|
+
import httpx
|
|
6
|
+
|
|
7
|
+
from feedmcp_mcp import __version__
|
|
8
|
+
from feedmcp_mcp.__main__ import StdioHttpBridge, main, parse_sse_payloads
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class TestFeedMcpPythonBridge(unittest.TestCase):
|
|
12
|
+
def test_parse_sse_payloads(self) -> None:
|
|
13
|
+
sse = 'event: message\ndata: {"jsonrpc":"2.0","id":1,"result":{"ok":true}}\n\ndata: [DONE]\n\n'
|
|
14
|
+
self.assertEqual(parse_sse_payloads(sse), ['{"jsonrpc":"2.0","id":1,"result":{"ok":true}}'])
|
|
15
|
+
|
|
16
|
+
def test_version_flag(self) -> None:
|
|
17
|
+
self.assertEqual(main(["--version"]), 0)
|
|
18
|
+
|
|
19
|
+
def test_mock_bridge_auth_session_sse_and_errors(self) -> None:
|
|
20
|
+
seen = []
|
|
21
|
+
|
|
22
|
+
def handler(request: httpx.Request) -> httpx.Response:
|
|
23
|
+
msg = json.loads(request.content.decode("utf-8"))
|
|
24
|
+
seen.append((dict(request.headers), msg))
|
|
25
|
+
if msg.get("method") == "initialize":
|
|
26
|
+
return httpx.Response(
|
|
27
|
+
200,
|
|
28
|
+
headers={"mcp-session-id": "sess-py-1"},
|
|
29
|
+
json={"jsonrpc": "2.0", "id": msg["id"], "result": {"ok": True}},
|
|
30
|
+
)
|
|
31
|
+
if msg.get("method") == "notifications/initialized":
|
|
32
|
+
return httpx.Response(202)
|
|
33
|
+
if msg.get("method") == "sse_call":
|
|
34
|
+
return httpx.Response(
|
|
35
|
+
200,
|
|
36
|
+
headers={"content-type": "text/event-stream"},
|
|
37
|
+
text='event: message\ndata: {"jsonrpc":"2.0","id":2,"result":{"sse":true}}\n\n',
|
|
38
|
+
)
|
|
39
|
+
return httpx.Response(502, text="Bad Gateway")
|
|
40
|
+
|
|
41
|
+
stdin = io.StringIO(
|
|
42
|
+
"\n".join(
|
|
43
|
+
[
|
|
44
|
+
json.dumps({"jsonrpc": "2.0", "id": 1, "method": "initialize"}),
|
|
45
|
+
json.dumps({"jsonrpc": "2.0", "method": "notifications/initialized"}),
|
|
46
|
+
json.dumps({"jsonrpc": "2.0", "id": 2, "method": "sse_call"}),
|
|
47
|
+
json.dumps({"jsonrpc": "2.0", "id": 3, "method": "boom"}),
|
|
48
|
+
]
|
|
49
|
+
)
|
|
50
|
+
+ "\n"
|
|
51
|
+
)
|
|
52
|
+
stdout = io.StringIO()
|
|
53
|
+
stderr = io.StringIO()
|
|
54
|
+
|
|
55
|
+
bridge = StdioHttpBridge(
|
|
56
|
+
url="https://mock.feedmcp.test/mcp",
|
|
57
|
+
api_key="fmk_test_py",
|
|
58
|
+
stdin=stdin,
|
|
59
|
+
stdout=stdout,
|
|
60
|
+
stderr=stderr,
|
|
61
|
+
transport=httpx.MockTransport(handler),
|
|
62
|
+
)
|
|
63
|
+
self.assertEqual(bridge.run(), 0)
|
|
64
|
+
lines = [json.loads(l) for l in stdout.getvalue().strip().splitlines()]
|
|
65
|
+
self.assertEqual(len(lines), 3)
|
|
66
|
+
self.assertEqual(lines[0]["result"], {"ok": True})
|
|
67
|
+
self.assertEqual(lines[1]["result"], {"sse": True})
|
|
68
|
+
self.assertEqual(lines[2]["error"]["code"], -32000)
|
|
69
|
+
self.assertEqual(seen[0][0]["authorization"], "Bearer fmk_test_py")
|
|
70
|
+
self.assertEqual(seen[1][0]["mcp-session-id"], "sess-py-1")
|
|
71
|
+
|
|
72
|
+
def test_live_free_find(self) -> None:
|
|
73
|
+
stdin = io.StringIO(
|
|
74
|
+
"\n".join(
|
|
75
|
+
[
|
|
76
|
+
json.dumps(
|
|
77
|
+
{
|
|
78
|
+
"jsonrpc": "2.0",
|
|
79
|
+
"id": 1,
|
|
80
|
+
"method": "initialize",
|
|
81
|
+
"params": {
|
|
82
|
+
"protocolVersion": "2025-06-18",
|
|
83
|
+
"capabilities": {},
|
|
84
|
+
"clientInfo": {"name": "feedmcp-mcp-py-test", "version": __version__},
|
|
85
|
+
},
|
|
86
|
+
}
|
|
87
|
+
),
|
|
88
|
+
json.dumps({"jsonrpc": "2.0", "id": 2, "method": "tools/list", "params": {}}),
|
|
89
|
+
json.dumps(
|
|
90
|
+
{
|
|
91
|
+
"jsonrpc": "2.0",
|
|
92
|
+
"id": 3,
|
|
93
|
+
"method": "tools/call",
|
|
94
|
+
"params": {"name": "find", "arguments": {"query": "xiaohongshu"}},
|
|
95
|
+
}
|
|
96
|
+
),
|
|
97
|
+
]
|
|
98
|
+
)
|
|
99
|
+
+ "\n"
|
|
100
|
+
)
|
|
101
|
+
stdout = io.StringIO()
|
|
102
|
+
bridge = StdioHttpBridge(stdin=stdin, stdout=stdout, stderr=io.StringIO())
|
|
103
|
+
self.assertEqual(bridge.run(), 0)
|
|
104
|
+
msgs = [json.loads(l) for l in stdout.getvalue().strip().splitlines()]
|
|
105
|
+
self.assertEqual(len(msgs), 3)
|
|
106
|
+
self.assertEqual(msgs[0]["result"]["serverInfo"]["name"], "feedmcp")
|
|
107
|
+
tool_names = [t["name"] for t in msgs[1]["result"]["tools"]]
|
|
108
|
+
self.assertIn("find", tool_names)
|
|
109
|
+
self.assertIn("xiaohongshu", msgs[2]["result"]["content"][0]["text"])
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
if __name__ == "__main__":
|
|
113
|
+
unittest.main()
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
version = 1
|
|
2
|
+
revision = 5
|
|
3
|
+
requires-python = ">=3.10, <4.0"
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "anyio"
|
|
7
|
+
version = "4.16.0"
|
|
8
|
+
source = { registry = "https://pypi.org/simple" }
|
|
9
|
+
dependencies = [
|
|
10
|
+
{ name = "exceptiongroup", marker = "python_full_version < '3.11'" },
|
|
11
|
+
{ name = "idna" },
|
|
12
|
+
{ name = "typing-extensions", marker = "python_full_version < '3.15'" },
|
|
13
|
+
]
|
|
14
|
+
sdist = { url = "https://files.pythonhosted.org/packages/a1/98/7e457a3b014976887a050561955c0b76e1e7e2d6e27b78ecef2ef80518f2/anyio-4.16.0.tar.gz", hash = "sha256:59bb03251907983d1603d27c3087ddb1e93299ea2163adcdba37899a4fb12ffb", size = 310971, upload-time = "2026-11-01T11:20:07.282Z" }
|
|
15
|
+
wheels = [
|
|
16
|
+
{ url = "https://files.pythonhosted.org/packages/a9/16/7757fb84c819accc7d7e9af5291b261e4abb8627ee040f99e7d35ef2457a/anyio-4.16.0-py3-none-any.whl", hash = "sha256:c66ae634e0b8228396b801741beb3294326d4b6102f7bba4041c0dfb58c29026", size = 134521, upload-time = "2026-11-01T11:20:05.59Z" },
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[[package]]
|
|
20
|
+
name = "certifi"
|
|
21
|
+
version = "2026.11.20"
|
|
22
|
+
source = { registry = "https://pypi.org/simple" }
|
|
23
|
+
sdist = { url = "https://files.pythonhosted.org/packages/51/33/4cd27639502f010084bcef7a2036391dd637439901341ce1a530f36f6e51/certifi-2026.11.20.tar.gz", hash = "sha256:af1cb240a8133f105aa52684a3a3258339d7f2fd0bd4e2812698ff5cf5588c4e", size = 128901, upload-time = "2026-11-20T23:37:49.522Z" }
|
|
24
|
+
wheels = [
|
|
25
|
+
{ url = "https://files.pythonhosted.org/packages/6d/39/5eec3296860b94ac20bb8ed807725b88f6adfab3f343df592afd975f5f86/certifi-2026.11.20-py3-none-any.whl", hash = "sha256:7422df25243767b9877031a2248cb14d09ddac9beee846f4cef3d5c9191d488f", size = 127913, upload-time = "2026-11-20T23:37:48.117Z" },
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
[[package]]
|
|
29
|
+
name = "exceptiongroup"
|
|
30
|
+
version = "1.3.2"
|
|
31
|
+
source = { registry = "https://pypi.org/simple" }
|
|
32
|
+
dependencies = [
|
|
33
|
+
{ name = "typing-extensions" },
|
|
34
|
+
]
|
|
35
|
+
sdist = { url = "https://files.pythonhosted.org/packages/85/ac/f882fe3234606340c8729372da0fb98c634b97a560c9d375d9afea21496b/exceptiongroup-1.3.2.tar.gz", hash = "sha256:ca82e69f0cb535fbde934885744b67669a3efddd50fe7bc00d3398839fcaddec", size = 34687, upload-time = "2026-11-19T22:10:16.815Z" }
|
|
36
|
+
wheels = [
|
|
37
|
+
{ url = "https://files.pythonhosted.org/packages/a0/7d/0fb19ccdf794c448141461180d5992c50402f69f8515a801bfac7ad65f45/exceptiongroup-1.3.2-py3-none-any.whl", hash = "sha256:41c6a70dfec22050d3d8b43386b059a4dc0bca3f3d40a40971cb206fff1785af", size = 16854, upload-time = "2026-11-19T22:10:15.746Z" },
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
[[package]]
|
|
41
|
+
name = "feedmcp-mcp"
|
|
42
|
+
version = "0.1.0"
|
|
43
|
+
source = { editable = "." }
|
|
44
|
+
dependencies = [
|
|
45
|
+
{ name = "httpx" },
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
[package.metadata]
|
|
49
|
+
requires-dist = [{ name = "httpx", specifier = ">=0.27,<1.0" }]
|
|
50
|
+
|
|
51
|
+
[[package]]
|
|
52
|
+
name = "h11"
|
|
53
|
+
version = "0.16.0"
|
|
54
|
+
source = { registry = "https://pypi.org/simple" }
|
|
55
|
+
sdist = { url = "https://files.pythonhosted.org/packages/01/ee/02a2c011bdab74c6fb3c75474d40b3052059d95df7e73351460c8588d963/h11-0.16.0.tar.gz", hash = "sha256:4e35b956cf45792e4caa5885e69fba00bdbc6ffafbfa020300e549b208ee5ff1", size = 101250, upload-time = "2025-04-24T03:35:25.427Z" }
|
|
56
|
+
wheels = [
|
|
57
|
+
{ url = "https://files.pythonhosted.org/packages/04/4b/29cac41a4d98d144bf5f6d33995617b185d14b22401f75ca86f384e87ff1/h11-0.16.0-py3-none-any.whl", hash = "sha256:63cf8bbe7522de3bf65932fda1d9c2772064ffb3dae62d55932da54b31cb6c86", size = 37515, upload-time = "2025-04-24T03:35:24.344Z" },
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
[[package]]
|
|
61
|
+
name = "httpcore"
|
|
62
|
+
version = "1.0.9"
|
|
63
|
+
source = { registry = "https://pypi.org/simple" }
|
|
64
|
+
dependencies = [
|
|
65
|
+
{ name = "certifi" },
|
|
66
|
+
{ name = "h11" },
|
|
67
|
+
]
|
|
68
|
+
sdist = { url = "https://files.pythonhosted.org/packages/06/94/82699a10bca87a5556c9c59b5963f2d039dbd239f25bc2a63907a05a14cb/httpcore-1.0.9.tar.gz", hash = "sha256:6e34463af53fd2ab5d807f399a9b45ea31c3dfa2276f15a2c3f00afff6e176e8", size = 85484, upload-time = "2025-04-24T22:06:22.219Z" }
|
|
69
|
+
wheels = [
|
|
70
|
+
{ url = "https://files.pythonhosted.org/packages/7e/f5/f66802a942d491edb555dd61e3a9961140fd64c90bce1eafd741609d334d/httpcore-1.0.9-py3-none-any.whl", hash = "sha256:2d400746a40668fc9dec9810239072b40b4484b640a8c38fd654a024c7a1bf55", size = 78784, upload-time = "2025-04-24T22:06:20.566Z" },
|
|
71
|
+
]
|
|
72
|
+
|
|
73
|
+
[[package]]
|
|
74
|
+
name = "httpx"
|
|
75
|
+
version = "0.29.0"
|
|
76
|
+
source = { registry = "https://pypi.org/simple" }
|
|
77
|
+
dependencies = [
|
|
78
|
+
{ name = "anyio" },
|
|
79
|
+
{ name = "certifi" },
|
|
80
|
+
{ name = "httpcore" },
|
|
81
|
+
{ name = "idna" },
|
|
82
|
+
]
|
|
83
|
+
sdist = { url = "https://files.pythonhosted.org/packages/9a/d5/b4d2c4d397b7c0222635cd069098f232fb5cba31f6749e77b339e263b52c/httpx-0.29.0.tar.gz", hash = "sha256:700928ee6c1f4213795e67c47eba8f8553639069fea89199f71d654e38edc593", size = 141642, upload-time = "2026-11-26T15:58:37.028Z" }
|
|
84
|
+
wheels = [
|
|
85
|
+
{ url = "https://files.pythonhosted.org/packages/82/c6/dddba524648da23345e446e6413530474e19e44122dba752d34ae7c4ae57/httpx-0.29.0-py3-none-any.whl", hash = "sha256:6734dcf742ced6e8018e45d3f9f7728975b6b3e1085a24f3e2c056069d858bd1", size = 73532, upload-time = "2026-11-26T15:58:35.703Z" },
|
|
86
|
+
]
|
|
87
|
+
|
|
88
|
+
[[package]]
|
|
89
|
+
name = "idna"
|
|
90
|
+
version = "3.21"
|
|
91
|
+
source = { registry = "https://pypi.org/simple" }
|
|
92
|
+
sdist = { url = "https://files.pythonhosted.org/packages/7b/f2/49de8a3ad60ecb57466235a74f9446cf644604ae187b9d8bde736ba95a62/idna-3.21.tar.gz", hash = "sha256:13c8b14853c5c336eaab526f3390817e9c8fcd8fa175abdd1a7480a5c94f99cb", size = 225738, upload-time = "2026-12-04T01:41:56.416Z" }
|
|
93
|
+
wheels = [
|
|
94
|
+
{ url = "https://files.pythonhosted.org/packages/1a/b2/3b613e8a32f9de30d202ae40031f4946248eb716797a3ecb4fc9d9610ef5/idna-3.21-py3-none-any.whl", hash = "sha256:387ab0bbea1ee7a196ea5b24eb007bad0242cc3127fe96713939942bc9e720d7", size = 69750, upload-time = "2026-12-04T01:41:55.252Z" },
|
|
95
|
+
]
|
|
96
|
+
|
|
97
|
+
[[package]]
|
|
98
|
+
name = "typing-extensions"
|
|
99
|
+
version = "4.16.0"
|
|
100
|
+
source = { registry = "https://pypi.org/simple" }
|
|
101
|
+
sdist = { url = "https://files.pythonhosted.org/packages/f6/cc/6253133b5bb138fc3306cebfbda2c520f545d36b5be2c7255cc528bb45d6/typing_extensions-4.16.0.tar.gz", hash = "sha256:dc983d19a509c94dba722ee6abd33940f7c05a89e243c47e907eb4db6f1a43e5", size = 113555, upload-time = "2026-07-02T08:40:05.92Z" }
|
|
102
|
+
wheels = [
|
|
103
|
+
{ url = "https://files.pythonhosted.org/packages/49/d3/b8441a820a491ddfc024b0b0cf0393375b75ea13866d9c66727e54c2fc80/typing_extensions-4.16.0-py3-none-any.whl", hash = "sha256:481caa481374e813c1b176ada14e97f1f67a4539ce9cfeb3f350d78d6370c2e8", size = 45571, upload-time = "2026-07-02T08:40:04.659Z" },
|
|
104
|
+
]
|