honest-rss-mcp 0.2.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,7 @@
1
+ venv/
2
+ __pycache__/
3
+ *.pyc
4
+ *.pyo
5
+ .DS_Store
6
+ .env
7
+ dist/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Bartosz Kuć
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,151 @@
1
+ Metadata-Version: 2.5
2
+ Name: honest-rss-mcp
3
+ Version: 0.2.0
4
+ Summary: Local MCP server for RSS/Atom feeds — fetch and parse without cloud middle.
5
+ Project-URL: Homepage, https://github.com/bartosz-kuc/honest-rss-mcp
6
+ Project-URL: Repository, https://github.com/bartosz-kuc/honest-rss-mcp
7
+ Project-URL: Issues, https://github.com/bartosz-kuc/honest-rss-mcp/issues
8
+ Author-email: Bartosz Kuć <firma@bartosza.pl>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: atom,feeds,mcp,rss
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Requires-Python: >=3.10
22
+ Requires-Dist: feedparser<7,>=6.0.12
23
+ Requires-Dist: mcp<3.0.0,>=2.0.0
24
+ Description-Content-Type: text/markdown
25
+
26
+ # honest-rss-mcp
27
+
28
+ <!-- mcp-name: io.github.bartosz-kuc/honest-rss-mcp -->
29
+
30
+ Local MCP server for RSS and Atom feeds. Universal, no cloud middle.
31
+
32
+ Part of the [honest-mcp family](https://github.com/bartosz-kuc?tab=repositories) of small, auditable, local-first MCP servers.
33
+
34
+ ## Why
35
+
36
+ Every AI assistant should be able to read a feed. RSS is the last honest content protocol on the open web — no login, no algorithm, no tracker. This server hands feed data to your AI in the same shape as any other structured tool, so you can ask questions like "what did HN's frontpage look like this morning?" without scraping.
37
+
38
+ ## Features
39
+
40
+ Three tools:
41
+
42
+ - `fetch_feed` — feed metadata + the first N entries in feed order (not re-sorted; most feeds list newest first, but that isn't guaranteed)
43
+ - `search_entries` — feed entries filtered by keyword in title/summary
44
+ - `list_feed_metadata` — quick dashboard view over up to 20 feeds at once (no full entry payload)
45
+
46
+ Handles RSS 1.0, RSS 2.0, and Atom — whatever `feedparser` handles. Network fetches use a 15-second socket timeout (for connecting and for each read), so a feed server that stops responding returns an error instead of hanging the tool.
47
+
48
+ ## Requirements
49
+
50
+ - Python 3.10+
51
+
52
+ ## Setup
53
+
54
+ ```bash
55
+ git clone https://github.com/bartosz-kuc/honest-rss-mcp.git
56
+ cd honest-rss-mcp
57
+ python3 -m venv venv
58
+ ./venv/bin/pip install -r requirements.txt
59
+ ```
60
+
61
+ On Windows use `python` instead of `python3`, and `venv\Scripts\pip` / `venv\Scripts\python` instead of the `venv/bin/...` paths shown here and in the configs below.
62
+
63
+ Register with Claude Code:
64
+
65
+ ```bash
66
+ claude mcp add rss /absolute/path/to/venv/bin/python /absolute/path/to/server.py
67
+ ```
68
+
69
+ Claude Desktop `claude_desktop_config.json`:
70
+
71
+ ```json
72
+ {
73
+ "mcpServers": {
74
+ "rss": {
75
+ "command": "/absolute/path/to/venv/bin/python",
76
+ "args": ["/absolute/path/to/server.py"]
77
+ }
78
+ }
79
+ }
80
+ ```
81
+
82
+ ### Alternative: install from PyPI (`uvx`)
83
+
84
+ The server is also published on PyPI as `honest-rss-mcp`, so you can skip the clone and the venv. With [uv](https://docs.astral.sh/uv/) installed:
85
+
86
+ ```bash
87
+ claude mcp add rss -- uvx honest-rss-mcp
88
+ ```
89
+
90
+ Claude Desktop `claude_desktop_config.json`:
91
+
92
+ ```json
93
+ {
94
+ "mcpServers": {
95
+ "rss": {
96
+ "command": "uvx",
97
+ "args": ["honest-rss-mcp"]
98
+ }
99
+ }
100
+ }
101
+ ```
102
+
103
+ `pip install honest-rss-mcp` works too; it installs the `honest-rss-mcp` command.
104
+
105
+ ## Example usage
106
+
107
+ > "What's on Hacker News right now?"
108
+
109
+ `fetch_feed(url="https://news.ycombinator.com/rss", limit=10)`
110
+
111
+ > "Anything about Copilot on the GitHub blog?"
112
+
113
+ `search_entries(url="https://github.blog/feed/", query="Copilot")`
114
+
115
+ > "Give me a summary line for each of these five feeds."
116
+
117
+ `list_feed_metadata(urls=["...", "...", ...])`
118
+
119
+ Only `http://` and `https://` feed URLs are accepted — local file paths and `file://` URLs are rejected, so the server never reads files from your disk.
120
+
121
+ ## Data flow
122
+
123
+ ```
124
+ Your AI client
125
+ ↕ MCP stdio
126
+ This server (Python, on your machine)
127
+ ↕ HTTPS
128
+ Feed URL
129
+ ```
130
+
131
+ Nothing else. No aggregator server, no analytics.
132
+
133
+ ## Author
134
+
135
+ **Bartosz Kuć** — Warsaw-based developer, JDG owner running [skanfirmy.pl](https://skanfirmy.pl).
136
+
137
+ - GitHub: https://github.com/bartosz-kuc
138
+
139
+ - Email: firma@bartosza.pl
140
+
141
+ ## Consulting
142
+
143
+ Available for consulting on Polish tax and business integrations (KSeF, GUS/NFZ/GIOŚ APIs, mBank data), MCP server design, and AI-assisted tooling for JDGs and small teams. See **[skanfirmy.pl/uslugi](https://skanfirmy.pl/uslugi)** for productized packages (audit 3k PLN, setup 8-15k PLN, retainer 2-4k PLN/mo), or reach out via email.
144
+
145
+ ## License
146
+
147
+ MIT — see [LICENSE](LICENSE).
148
+
149
+ ## Related
150
+
151
+ - Part of the honest-mcp family — see the [family index](https://github.com/bartosz-kuc?tab=repositories).
@@ -0,0 +1,126 @@
1
+ # honest-rss-mcp
2
+
3
+ <!-- mcp-name: io.github.bartosz-kuc/honest-rss-mcp -->
4
+
5
+ Local MCP server for RSS and Atom feeds. Universal, no cloud middle.
6
+
7
+ Part of the [honest-mcp family](https://github.com/bartosz-kuc?tab=repositories) of small, auditable, local-first MCP servers.
8
+
9
+ ## Why
10
+
11
+ Every AI assistant should be able to read a feed. RSS is the last honest content protocol on the open web — no login, no algorithm, no tracker. This server hands feed data to your AI in the same shape as any other structured tool, so you can ask questions like "what did HN's frontpage look like this morning?" without scraping.
12
+
13
+ ## Features
14
+
15
+ Three tools:
16
+
17
+ - `fetch_feed` — feed metadata + the first N entries in feed order (not re-sorted; most feeds list newest first, but that isn't guaranteed)
18
+ - `search_entries` — feed entries filtered by keyword in title/summary
19
+ - `list_feed_metadata` — quick dashboard view over up to 20 feeds at once (no full entry payload)
20
+
21
+ Handles RSS 1.0, RSS 2.0, and Atom — whatever `feedparser` handles. Network fetches use a 15-second socket timeout (for connecting and for each read), so a feed server that stops responding returns an error instead of hanging the tool.
22
+
23
+ ## Requirements
24
+
25
+ - Python 3.10+
26
+
27
+ ## Setup
28
+
29
+ ```bash
30
+ git clone https://github.com/bartosz-kuc/honest-rss-mcp.git
31
+ cd honest-rss-mcp
32
+ python3 -m venv venv
33
+ ./venv/bin/pip install -r requirements.txt
34
+ ```
35
+
36
+ On Windows use `python` instead of `python3`, and `venv\Scripts\pip` / `venv\Scripts\python` instead of the `venv/bin/...` paths shown here and in the configs below.
37
+
38
+ Register with Claude Code:
39
+
40
+ ```bash
41
+ claude mcp add rss /absolute/path/to/venv/bin/python /absolute/path/to/server.py
42
+ ```
43
+
44
+ Claude Desktop `claude_desktop_config.json`:
45
+
46
+ ```json
47
+ {
48
+ "mcpServers": {
49
+ "rss": {
50
+ "command": "/absolute/path/to/venv/bin/python",
51
+ "args": ["/absolute/path/to/server.py"]
52
+ }
53
+ }
54
+ }
55
+ ```
56
+
57
+ ### Alternative: install from PyPI (`uvx`)
58
+
59
+ The server is also published on PyPI as `honest-rss-mcp`, so you can skip the clone and the venv. With [uv](https://docs.astral.sh/uv/) installed:
60
+
61
+ ```bash
62
+ claude mcp add rss -- uvx honest-rss-mcp
63
+ ```
64
+
65
+ Claude Desktop `claude_desktop_config.json`:
66
+
67
+ ```json
68
+ {
69
+ "mcpServers": {
70
+ "rss": {
71
+ "command": "uvx",
72
+ "args": ["honest-rss-mcp"]
73
+ }
74
+ }
75
+ }
76
+ ```
77
+
78
+ `pip install honest-rss-mcp` works too; it installs the `honest-rss-mcp` command.
79
+
80
+ ## Example usage
81
+
82
+ > "What's on Hacker News right now?"
83
+
84
+ `fetch_feed(url="https://news.ycombinator.com/rss", limit=10)`
85
+
86
+ > "Anything about Copilot on the GitHub blog?"
87
+
88
+ `search_entries(url="https://github.blog/feed/", query="Copilot")`
89
+
90
+ > "Give me a summary line for each of these five feeds."
91
+
92
+ `list_feed_metadata(urls=["...", "...", ...])`
93
+
94
+ Only `http://` and `https://` feed URLs are accepted — local file paths and `file://` URLs are rejected, so the server never reads files from your disk.
95
+
96
+ ## Data flow
97
+
98
+ ```
99
+ Your AI client
100
+ ↕ MCP stdio
101
+ This server (Python, on your machine)
102
+ ↕ HTTPS
103
+ Feed URL
104
+ ```
105
+
106
+ Nothing else. No aggregator server, no analytics.
107
+
108
+ ## Author
109
+
110
+ **Bartosz Kuć** — Warsaw-based developer, JDG owner running [skanfirmy.pl](https://skanfirmy.pl).
111
+
112
+ - GitHub: https://github.com/bartosz-kuc
113
+
114
+ - Email: firma@bartosza.pl
115
+
116
+ ## Consulting
117
+
118
+ Available for consulting on Polish tax and business integrations (KSeF, GUS/NFZ/GIOŚ APIs, mBank data), MCP server design, and AI-assisted tooling for JDGs and small teams. See **[skanfirmy.pl/uslugi](https://skanfirmy.pl/uslugi)** for productized packages (audit 3k PLN, setup 8-15k PLN, retainer 2-4k PLN/mo), or reach out via email.
119
+
120
+ ## License
121
+
122
+ MIT — see [LICENSE](LICENSE).
123
+
124
+ ## Related
125
+
126
+ - Part of the honest-mcp family — see the [family index](https://github.com/bartosz-kuc?tab=repositories).
@@ -0,0 +1,35 @@
1
+ # Security Policy
2
+
3
+ ## Reporting a vulnerability
4
+
5
+ If you find a security issue in this MCP server, please email **firma@bartosza.pl**. Do **not** open a public GitHub issue.
6
+
7
+ - I aim to respond within 48 hours. This is a solo hobby project — there is no formal SLA — but security reports are the fastest path to my attention.
8
+ - Please include: version / commit hash affected, steps to reproduce, and the impact scenario.
9
+ - PGP key available on request. Otherwise, plain email is fine.
10
+
11
+ ## Scope
12
+
13
+ This server is one member of the [honest-mcp family](https://github.com/bartosz-kuc?tab=repositories). If your report affects the family pattern broadly, I will coordinate cross-repository disclosure.
14
+
15
+ **In scope:**
16
+ - Code execution paths in `server.py` that could be triggered by AI-client input
17
+ - Handling of authentication material (OAuth tokens, API keys, session state)
18
+ - Any path that could exfiltrate data past the documented "AI ↔ MCP server ↔ upstream API" trust boundary
19
+ - Dependency vulnerabilities that materially expand attack surface
20
+
21
+ **Not in scope:**
22
+ - Whatever your AI client itself can reach — that is the intended data flow. Trust boundaries are between your AI client and the external service the server wraps.
23
+ - Local credential files (e.g. `credentials.json`, `token.json`) that you generate on your own machine per the setup instructions. These are your responsibility; the shipped `.gitignore` prevents accidental commits.
24
+ - Denial-of-service via upstream rate limits (each server documents which public APIs it hits).
25
+
26
+ ## Supported versions
27
+
28
+ Only the current `main` branch is supported. Releases are tagged from `main` and any accepted security fix will be published as a new tagged patch release.
29
+
30
+ ## Automated safeguards enabled on this repo
31
+
32
+ - Dependabot alerts and version updates (weekly)
33
+ - Automated security fixes for published CVEs in dependencies
34
+ - Secret scanning + push protection (blocks accidental credential commits)
35
+ - CodeQL static analysis on push and PR
@@ -0,0 +1,47 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "honest-rss-mcp"
7
+ version = "0.2.0"
8
+ description = "Local MCP server for RSS/Atom feeds — fetch and parse without cloud middle."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.10"
12
+ authors = [{ name = "Bartosz Kuć", email = "firma@bartosza.pl" }]
13
+ keywords = ["mcp", "rss", "atom", "feeds"]
14
+ classifiers = [
15
+ "Development Status :: 4 - Beta",
16
+ "Intended Audience :: Developers",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Operating System :: OS Independent",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Programming Language :: Python :: 3.13",
24
+ ]
25
+ dependencies = [
26
+ "mcp>=2.0.0,<3.0.0",
27
+ "feedparser>=6.0.12,<7",
28
+ ]
29
+
30
+ [project.urls]
31
+ Homepage = "https://github.com/bartosz-kuc/honest-rss-mcp"
32
+ Repository = "https://github.com/bartosz-kuc/honest-rss-mcp"
33
+ Issues = "https://github.com/bartosz-kuc/honest-rss-mcp/issues"
34
+
35
+ [project.scripts]
36
+ honest-rss-mcp = "honest_rss_mcp:sync_main"
37
+ rss-mcp = "honest_rss_mcp:sync_main"
38
+
39
+ [tool.hatch.build.targets.wheel]
40
+ sources = ["."]
41
+ only-include = ["server.py"]
42
+
43
+ [tool.hatch.build.targets.wheel.force-include]
44
+ "server.py" = "honest_rss_mcp.py"
45
+
46
+ [tool.hatch.build.targets.sdist]
47
+ include = ["server.py", "README.md", "LICENSE", "SECURITY.md", "pyproject.toml"]
@@ -0,0 +1,227 @@
1
+ """rss-mcp — MCP server for RSS and Atom feeds.
2
+
3
+ Fetches, parses, and filters RSS 1.0/2.0 and Atom feeds using the standard
4
+ `feedparser` library. Works with any public feed URL. Nothing leaves your
5
+ machine except the HTTPS GET to the feed URL.
6
+
7
+ Tools: fetch_feed, search_entries, list_feed_metadata.
8
+
9
+ Author: Bartosz Kuć <firma@bartosza.pl>
10
+ Repo: https://github.com/bartosz-kuc/honest-rss-mcp
11
+ License: MIT
12
+ """
13
+
14
+ import asyncio
15
+ import json
16
+ import urllib.error
17
+ import urllib.parse
18
+ import urllib.request
19
+ from typing import Any
20
+
21
+ import feedparser
22
+ from mcp import types
23
+ from mcp.server import Server
24
+ from mcp.server.stdio import stdio_server
25
+ from mcp.types import CallToolResult, ListToolsResult, TextContent, Tool
26
+
27
+ USER_AGENT = "rss-mcp/1.0 (+https://github.com/bartosz-kuc/honest-rss-mcp)"
28
+ FETCH_TIMEOUT = 15 # seconds; socket timeout for connecting and for each read
29
+ MAX_URLS = 20 # cap for list_feed_metadata
30
+
31
+
32
+ class _TimeoutHandler(urllib.request.BaseHandler):
33
+ """Sets a socket timeout on every request feedparser makes (feedparser 6 has no timeout option)."""
34
+
35
+ def _set_timeout(self, req: urllib.request.Request) -> urllib.request.Request:
36
+ req.timeout = FETCH_TIMEOUT
37
+ return req
38
+
39
+ http_request = https_request = ftp_request = _set_timeout
40
+
41
+
42
+ def _entry_to_dict(e: Any) -> dict:
43
+ return {
44
+ "title": getattr(e, "title", None),
45
+ "link": getattr(e, "link", None),
46
+ "published": getattr(e, "published", None) or getattr(e, "updated", None),
47
+ "author": getattr(e, "author", None),
48
+ "summary": getattr(e, "summary", None),
49
+ "id": getattr(e, "id", None) or getattr(e, "link", None),
50
+ "tags": [t.term for t in getattr(e, "tags", [])] if hasattr(e, "tags") else [],
51
+ }
52
+
53
+
54
+ def _feed_info(f: feedparser.FeedParserDict, url: str, entry_count: int | None) -> dict:
55
+ channel = f.feed
56
+ info = {
57
+ "url": url,
58
+ "title": getattr(channel, "title", None),
59
+ "subtitle": getattr(channel, "subtitle", None),
60
+ "link": getattr(channel, "link", None),
61
+ "language": getattr(channel, "language", None),
62
+ "updated": getattr(channel, "updated", None),
63
+ "generator": getattr(channel, "generator", None),
64
+ }
65
+ if entry_count is not None:
66
+ info["total_entries"] = len(f.entries)
67
+ info["returned"] = entry_count
68
+ if f.bozo:
69
+ info["parser_warning"] = str(f.bozo_exception)[:200] if f.bozo_exception else "feed is not fully well-formed"
70
+ return info
71
+
72
+
73
+ def _check_url(url: str) -> None:
74
+ # feedparser.parse() also accepts local file paths, file:// URLs and raw XML strings.
75
+ # Only remote http(s) feeds are allowed, so a tool call (or text injected via feed
76
+ # content) cannot make the server read local files.
77
+ parts = urllib.parse.urlsplit(url.strip())
78
+ if parts.scheme.lower() not in ("http", "https") or not parts.netloc:
79
+ raise ValueError(f"only http(s) feed URLs are allowed, got: {url[:100]!r}")
80
+
81
+
82
+ def _parse(url: str) -> feedparser.FeedParserDict:
83
+ _check_url(url)
84
+ timeout_msg = f"timed out after {FETCH_TIMEOUT}s fetching {url}"
85
+ try:
86
+ f = feedparser.parse(url, agent=USER_AGENT, handlers=[_TimeoutHandler()])
87
+ except TimeoutError as exc: # stalled while reading the response body
88
+ raise TimeoutError(timeout_msg) from exc
89
+ exc = f.get("bozo_exception")
90
+ if isinstance(exc, urllib.error.URLError) and isinstance(exc.reason, TimeoutError):
91
+ # stalled while connecting or waiting for headers (feedparser reports URLError as bozo)
92
+ raise TimeoutError(timeout_msg) from exc
93
+ return f
94
+
95
+
96
+ server = Server("rss")
97
+
98
+
99
+ async def _list_tools() -> list[Tool]:
100
+ return [
101
+ Tool(
102
+ name="fetch_feed",
103
+ description=(
104
+ "Fetch and parse an RSS or Atom feed. Returns feed metadata (title, subtitle, language) and the "
105
+ "first `limit` entries in the order the feed lists them (title, link, published date, author, "
106
+ "summary, tags). Entries are not re-sorted: most feeds list newest first, but that is not "
107
+ "guaranteed. Use `limit` to cap how many entries you get back — feeds can be huge. Works with any "
108
+ "publicly-accessible feed URL."
109
+ ),
110
+ inputSchema={
111
+ "type": "object",
112
+ "properties": {
113
+ "url": {"type": "string", "description": "Feed URL (RSS 1.0, RSS 2.0, or Atom)"},
114
+ "limit": {"type": "integer", "default": 20, "description": "Maximum number of entries to return, taken from the start of the feed (default 20)"},
115
+ },
116
+ "required": ["url"],
117
+ },
118
+ ),
119
+ Tool(
120
+ name="search_entries",
121
+ description=(
122
+ "Fetch a feed and return only entries whose title or summary contain a keyword (case-insensitive). "
123
+ "Useful when you want the AI to check a feed for specific topics without wading through everything."
124
+ ),
125
+ inputSchema={
126
+ "type": "object",
127
+ "properties": {
128
+ "url": {"type": "string", "description": "Feed URL"},
129
+ "query": {"type": "string", "description": "Keyword to match against title or summary (case-insensitive substring)"},
130
+ "limit": {"type": "integer", "default": 20, "description": "Maximum matches to return"},
131
+ },
132
+ "required": ["url", "query"],
133
+ },
134
+ ),
135
+ Tool(
136
+ name="list_feed_metadata",
137
+ description=(
138
+ f"Fetch metadata for one or more feeds (up to {MAX_URLS}) without returning their entries — title, "
139
+ "subtitle, entry count, last update time. Useful for building a dashboard of feeds you follow."
140
+ ),
141
+ inputSchema={
142
+ "type": "object",
143
+ "properties": {
144
+ "urls": {
145
+ "type": "array",
146
+ "items": {"type": "string"},
147
+ "maxItems": MAX_URLS,
148
+ "description": f"List of feed URLs (max {MAX_URLS})",
149
+ },
150
+ },
151
+ "required": ["urls"],
152
+ },
153
+ ),
154
+ ]
155
+
156
+
157
+ async def _call_tool(name: str, arguments: dict[str, Any]) -> list[TextContent]:
158
+ if name == "fetch_feed":
159
+ url = arguments["url"]
160
+ limit = int(arguments.get("limit", 20))
161
+ f = _parse(url)
162
+ entries = [_entry_to_dict(e) for e in f.entries[:limit]]
163
+ result = {"feed": _feed_info(f, url, len(entries)), "entries": entries}
164
+ return [TextContent(type="text", text=json.dumps(result, ensure_ascii=False, indent=2))]
165
+
166
+ if name == "search_entries":
167
+ url = arguments["url"]
168
+ query = arguments["query"].lower().strip()
169
+ if not query:
170
+ raise ValueError("query must be non-empty")
171
+ limit = int(arguments.get("limit", 20))
172
+ f = _parse(url)
173
+ matches: list[dict] = []
174
+ for e in f.entries:
175
+ title = (getattr(e, "title", "") or "").lower()
176
+ summary = (getattr(e, "summary", "") or "").lower()
177
+ if query in title or query in summary:
178
+ matches.append(_entry_to_dict(e))
179
+ if len(matches) >= limit:
180
+ break
181
+ result = {"feed": _feed_info(f, url, len(matches)), "query": arguments["query"], "matches": matches}
182
+ return [TextContent(type="text", text=json.dumps(result, ensure_ascii=False, indent=2))]
183
+
184
+ if name == "list_feed_metadata":
185
+ urls = arguments["urls"]
186
+ if not isinstance(urls, list) or not urls:
187
+ raise ValueError("urls must be a non-empty list")
188
+ if len(urls) > MAX_URLS:
189
+ raise ValueError(f"too many urls ({len(urls)}); list_feed_metadata accepts at most {MAX_URLS} per call")
190
+ feeds = []
191
+ for url in urls:
192
+ try:
193
+ f = _parse(url)
194
+ info = _feed_info(f, url, None)
195
+ info["total_entries"] = len(f.entries)
196
+ feeds.append(info)
197
+ except Exception as exc: # noqa: BLE001
198
+ feeds.append({"url": url, "error": f"{type(exc).__name__}: {exc}"})
199
+ return [TextContent(type="text", text=json.dumps({"feeds": feeds}, ensure_ascii=False, indent=2))]
200
+
201
+ raise ValueError(f"Unknown tool: {name}")
202
+
203
+
204
+ async def on_list_tools(ctx, params) -> ListToolsResult:
205
+ return ListToolsResult(tools=await _list_tools())
206
+
207
+
208
+ async def on_call_tool(ctx, params) -> CallToolResult:
209
+ return CallToolResult(content=await _call_tool(params.name, params.arguments or {}))
210
+
211
+
212
+ server.add_request_handler("tools/list", types.PaginatedRequestParams, on_list_tools)
213
+ server.add_request_handler("tools/call", types.CallToolRequestParams, on_call_tool)
214
+
215
+
216
+ async def main():
217
+ async with stdio_server() as (read, write):
218
+ await server.run(read, write, server.create_initialization_options())
219
+
220
+
221
+ def sync_main():
222
+ """Sync entry point for console script."""
223
+ asyncio.run(main())
224
+
225
+
226
+ if __name__ == "__main__":
227
+ sync_main()