runout-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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Pavel Mikhailov
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,190 @@
1
+ Metadata-Version: 2.4
2
+ Name: runout-mcp
3
+ Version: 0.1.0
4
+ Summary: Runout for Discogs: an MCP server for your Discogs Collection, Wantlist, Releases and Marketplace prices.
5
+ Keywords: mcp,discogs,vinyl,claude,record-collection
6
+ Author: Pavel Mikhailov
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Classifier: Programming Language :: Python :: 3.13
12
+ Classifier: Programming Language :: Python :: 3.14
13
+ Classifier: Programming Language :: Python :: 3.15
14
+ Requires-Dist: fastmcp>=4.2.3,<4.3
15
+ Requires-Dist: httpx2>=2.16,<3
16
+ Requires-Dist: pydantic-settings>=2.16,<3
17
+ Requires-Python: >=3.12
18
+ Project-URL: Repository, https://github.com/badta5te/runout-mcp
19
+ Project-URL: Issues, https://github.com/badta5te/runout-mcp/issues
20
+ Description-Content-Type: text/markdown
21
+
22
+ # Runout for Discogs
23
+
24
+ <!-- mcp-name: io.github.badta5te/runout-mcp -->
25
+
26
+ `runout-mcp` is a small local [MCP](https://modelcontextprotocol.io) server that lets Claude
27
+ answer everyday questions about your Discogs world: Releases and pressings in the catalog,
28
+ Marketplace prices, and your own Collection and Wantlist.
29
+
30
+ - "Which pressings of *Kind of Blue* exist, and how do they differ?"
31
+ - "What does this Release cost on Discogs right now?"
32
+ - "Do I have anything by Can? On vinyl or only on CD?"
33
+ - "Which of my 50 most-played albums on Last.fm are not on my shelf yet?"
34
+ - "What on my Wantlist is under 20 EUR right now?"
35
+
36
+ It runs on your machine over stdio, talks to the Discogs API with your own personal access token
37
+ and stores nothing on disk.
38
+
39
+ The name follows the Discogs rule for applications built on its API ("… for Discogs"). The
40
+ package and the command are both called `runout-mcp`.
41
+
42
+ ## Tools
43
+
44
+ | Tool | What it answers |
45
+ |---|---|
46
+ | `discogs_search` | Find Releases (pressings), Masters, artists or labels in the catalog by free text, narrowed by artist, year, Format, country, catalog number or barcode |
47
+ | `discogs_get_release` | The card of one Release: label, catalog number, Format, country, year, tracklist, have/want counts and Master; the detailed form adds matrix/runout, barcode and notes |
48
+ | `discogs_list_master_releases` | Every Release of a Master, to compare the Releases of an album by country, year, label, catalog number and Format |
49
+ | `discogs_get_prices` | The Lowest price, the number of copies for sale and the blocked-from-sale flag of 1 to 10 Releases |
50
+ | `discogs_list_collection` | The Copies in your Collection, newest first, filtered by artist or title, by Discogs genre or style, by folder, with Format, genres and condition |
51
+ | `discogs_collection_summary` | How many Copies each folder holds, and Discogs' minimum/median/maximum estimate of the Collection's value |
52
+ | `discogs_match_collection` | Which of up to 200 albums from another source (Last.fm, Spotify, a pasted list) are in your Collection, on your Wantlist, possible matches or absent |
53
+ | `discogs_list_wantlist` | The Wants on your Wantlist, newest first, filtered by artist or title and by Discogs genre or style |
54
+ | `discogs_wantlist_prices` | The Lowest price of up to 30 Wants per call, cheapest first, optionally under a maximum price or of one genre or style |
55
+ | `discogs_wantlist_add` | Adds a Release to your Wantlist; adding one that is already wanted changes nothing |
56
+ | `discogs_wantlist_remove` | Removes a Want; marked destructive, so Claude asks you to confirm every call |
57
+
58
+ And one prompt, `identify_release`, that walks Claude through finding the exact Release you hold
59
+ from its barcode, catalog number and matrix/runout etchings.
60
+
61
+ No tool changes your Collection. A Lowest price is the cheapest current listing in any
62
+ condition, excluding shipping: not a market value. There is no price watch; Discogs' own
63
+ Wantlister sends alerts for your Wants.
64
+
65
+ ## Requirements
66
+
67
+ - [uv](https://docs.astral.sh/uv/), which provides `uvx`.
68
+ - A Discogs personal access token: open
69
+ [Discogs → Settings → Developers](https://www.discogs.com/settings/developers) and click
70
+ **Generate new token**. The server refuses to start without it, and finds your Discogs
71
+ username from it.
72
+
73
+ ## Installation
74
+
75
+ There is nothing to install by hand: Claude starts the server with
76
+
77
+ ```sh
78
+ uvx runout-mcp
79
+ ```
80
+
81
+ which downloads the package from PyPI on first use and runs it in an isolated environment. Pin a
82
+ version with `uvx runout-mcp@0.1.0`.
83
+
84
+ ### Claude Desktop
85
+
86
+ Claude Desktop does not see your shell `PATH`, so give it the **absolute path to `uvx`**: find
87
+ it with `which uvx` (macOS) or `where uvx` (Windows). Open **Settings → Developer → Edit
88
+ Config**, or edit the file directly:
89
+
90
+ - macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
91
+ - Windows: `%APPDATA%\Claude\claude_desktop_config.json`
92
+
93
+ ```json
94
+ {
95
+ "mcpServers": {
96
+ "runout": {
97
+ "command": "/absolute/path/to/uvx",
98
+ "args": ["runout-mcp"],
99
+ "env": { "DISCOGS_TOKEN": "your-personal-access-token" }
100
+ }
101
+ }
102
+ }
103
+ ```
104
+
105
+ Restart Claude Desktop.
106
+
107
+ ### Claude Code
108
+
109
+ ```sh
110
+ claude mcp add runout --scope user -e DISCOGS_TOKEN=your-personal-access-token \
111
+ -- uvx runout-mcp
112
+ ```
113
+
114
+ `--scope user` makes the server available in every project; leave it out to add it to the
115
+ current project only. Check the connection with `claude mcp list` or `/mcp` inside Claude Code.
116
+
117
+ Then ask, for example: "Show me Discogs release 249504 in detail."
118
+
119
+ ## Configuration
120
+
121
+ The server reads its settings from the environment, which the Claude configuration above sets.
122
+
123
+ | Environment variable | Required | Meaning |
124
+ |---|---|---|
125
+ | `DISCOGS_TOKEN` | yes | Your Discogs personal access token |
126
+ | `DISCOGS_CURRENCY` | no | Currency of prices: USD, GBP, EUR (default), CAD, AUD, JPY, CHF, MXN, BRL, NZD, SEK or ZAR. A tool call can still ask for another one. |
127
+
128
+ ## How it treats your data
129
+
130
+ - **Nothing is stored on disk.** Discogs data lives only in memory while the server runs:
131
+ catalog lookups and prices for an hour, the Collection and the Wantlist for at most five
132
+ minutes, and the first page of each is checked again on every call, so a Copy or Want you add
133
+ on Discogs shows at once.
134
+ - **The token stays private.** It is sent only to `api.discogs.com` and never appears in logs,
135
+ tool output or error messages.
136
+ - **The server paces itself** on the Discogs rate-limit headers and retries briefly when Discogs
137
+ asks it to slow down.
138
+ - Your Collection, Wantlist and prices reach Claude as tool results, like anything else you ask
139
+ Claude about.
140
+
141
+ ## Development
142
+
143
+ Requires uv 0.13.x and [just](https://just.systems).
144
+
145
+ ```sh
146
+ uv sync # create .venv from uv.lock
147
+ just check # ruff, mypy and pytest: the same command CI runs on Python 3.12–3.15
148
+ just fix # apply ruff fixes and formatting
149
+ just serve # run the server over stdio from the checkout (needs DISCOGS_TOKEN)
150
+ ```
151
+
152
+ To try a local checkout in Claude, use `uv run --directory /absolute/path/to/runout-mcp
153
+ runout-mcp` as the command. It runs the code as it is in the checkout; `uvx --from` would keep
154
+ serving the build it cached first.
155
+
156
+ Tests build the server through `create_server()` and call its tools through FastMCP's in-memory
157
+ client against a fake Discogs (`httpx2.MockTransport`) serving anonymized fixtures. No test touches
158
+ the network.
159
+
160
+ ### Releasing
161
+
162
+ Pushing a version tag publishes the package to PyPI through
163
+ [Trusted Publishing](https://docs.pypi.org/trusted-publishers/): GitHub Actions proves its
164
+ identity to PyPI with OIDC, so no PyPI token is stored anywhere.
165
+
166
+ 1. Set the new version in `pyproject.toml` and in both `version` fields of `server.json`, then
167
+ run `uv lock` and commit.
168
+ 2. Tag and push: `git tag -a v0.1.0 -m v0.1.0 && git push origin v0.1.0`. The release workflow
169
+ checks that the tag and both files name the same version, runs the checks, builds and
170
+ publishes.
171
+ 3. Publish the entry to the [MCP Registry](https://registry.modelcontextprotocol.io) once the
172
+ version is on PyPI: `mcp-publisher login github`, then `mcp-publisher publish`.
173
+
174
+ One-time setup before the first release: on PyPI, add a pending trusted publisher for the
175
+ project `runout-mcp` with owner `badta5te`, repository `runout-mcp`, workflow
176
+ `release.yml` and environment `pypi`; on GitHub, create the `pypi` environment under
177
+ **Settings → Environments**.
178
+
179
+ ## Discogs
180
+
181
+ Every response that contains Discogs data ends with "Data provided by Discogs" and a link to the
182
+ data on discogs.com.
183
+
184
+ This application uses Discogs’ API but is not affiliated with, sponsored or endorsed by Discogs.
185
+ ‘Discogs’ is a trademark of Zink Media, LLC.
186
+
187
+ ## License
188
+
189
+ Released under the [MIT License](https://github.com/badta5te/runout-mcp/blob/main/LICENSE).
190
+ Copyright (c) 2026 Pavel Mikhailov.
@@ -0,0 +1,169 @@
1
+ # Runout for Discogs
2
+
3
+ <!-- mcp-name: io.github.badta5te/runout-mcp -->
4
+
5
+ `runout-mcp` is a small local [MCP](https://modelcontextprotocol.io) server that lets Claude
6
+ answer everyday questions about your Discogs world: Releases and pressings in the catalog,
7
+ Marketplace prices, and your own Collection and Wantlist.
8
+
9
+ - "Which pressings of *Kind of Blue* exist, and how do they differ?"
10
+ - "What does this Release cost on Discogs right now?"
11
+ - "Do I have anything by Can? On vinyl or only on CD?"
12
+ - "Which of my 50 most-played albums on Last.fm are not on my shelf yet?"
13
+ - "What on my Wantlist is under 20 EUR right now?"
14
+
15
+ It runs on your machine over stdio, talks to the Discogs API with your own personal access token
16
+ and stores nothing on disk.
17
+
18
+ The name follows the Discogs rule for applications built on its API ("… for Discogs"). The
19
+ package and the command are both called `runout-mcp`.
20
+
21
+ ## Tools
22
+
23
+ | Tool | What it answers |
24
+ |---|---|
25
+ | `discogs_search` | Find Releases (pressings), Masters, artists or labels in the catalog by free text, narrowed by artist, year, Format, country, catalog number or barcode |
26
+ | `discogs_get_release` | The card of one Release: label, catalog number, Format, country, year, tracklist, have/want counts and Master; the detailed form adds matrix/runout, barcode and notes |
27
+ | `discogs_list_master_releases` | Every Release of a Master, to compare the Releases of an album by country, year, label, catalog number and Format |
28
+ | `discogs_get_prices` | The Lowest price, the number of copies for sale and the blocked-from-sale flag of 1 to 10 Releases |
29
+ | `discogs_list_collection` | The Copies in your Collection, newest first, filtered by artist or title, by Discogs genre or style, by folder, with Format, genres and condition |
30
+ | `discogs_collection_summary` | How many Copies each folder holds, and Discogs' minimum/median/maximum estimate of the Collection's value |
31
+ | `discogs_match_collection` | Which of up to 200 albums from another source (Last.fm, Spotify, a pasted list) are in your Collection, on your Wantlist, possible matches or absent |
32
+ | `discogs_list_wantlist` | The Wants on your Wantlist, newest first, filtered by artist or title and by Discogs genre or style |
33
+ | `discogs_wantlist_prices` | The Lowest price of up to 30 Wants per call, cheapest first, optionally under a maximum price or of one genre or style |
34
+ | `discogs_wantlist_add` | Adds a Release to your Wantlist; adding one that is already wanted changes nothing |
35
+ | `discogs_wantlist_remove` | Removes a Want; marked destructive, so Claude asks you to confirm every call |
36
+
37
+ And one prompt, `identify_release`, that walks Claude through finding the exact Release you hold
38
+ from its barcode, catalog number and matrix/runout etchings.
39
+
40
+ No tool changes your Collection. A Lowest price is the cheapest current listing in any
41
+ condition, excluding shipping: not a market value. There is no price watch; Discogs' own
42
+ Wantlister sends alerts for your Wants.
43
+
44
+ ## Requirements
45
+
46
+ - [uv](https://docs.astral.sh/uv/), which provides `uvx`.
47
+ - A Discogs personal access token: open
48
+ [Discogs → Settings → Developers](https://www.discogs.com/settings/developers) and click
49
+ **Generate new token**. The server refuses to start without it, and finds your Discogs
50
+ username from it.
51
+
52
+ ## Installation
53
+
54
+ There is nothing to install by hand: Claude starts the server with
55
+
56
+ ```sh
57
+ uvx runout-mcp
58
+ ```
59
+
60
+ which downloads the package from PyPI on first use and runs it in an isolated environment. Pin a
61
+ version with `uvx runout-mcp@0.1.0`.
62
+
63
+ ### Claude Desktop
64
+
65
+ Claude Desktop does not see your shell `PATH`, so give it the **absolute path to `uvx`**: find
66
+ it with `which uvx` (macOS) or `where uvx` (Windows). Open **Settings → Developer → Edit
67
+ Config**, or edit the file directly:
68
+
69
+ - macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
70
+ - Windows: `%APPDATA%\Claude\claude_desktop_config.json`
71
+
72
+ ```json
73
+ {
74
+ "mcpServers": {
75
+ "runout": {
76
+ "command": "/absolute/path/to/uvx",
77
+ "args": ["runout-mcp"],
78
+ "env": { "DISCOGS_TOKEN": "your-personal-access-token" }
79
+ }
80
+ }
81
+ }
82
+ ```
83
+
84
+ Restart Claude Desktop.
85
+
86
+ ### Claude Code
87
+
88
+ ```sh
89
+ claude mcp add runout --scope user -e DISCOGS_TOKEN=your-personal-access-token \
90
+ -- uvx runout-mcp
91
+ ```
92
+
93
+ `--scope user` makes the server available in every project; leave it out to add it to the
94
+ current project only. Check the connection with `claude mcp list` or `/mcp` inside Claude Code.
95
+
96
+ Then ask, for example: "Show me Discogs release 249504 in detail."
97
+
98
+ ## Configuration
99
+
100
+ The server reads its settings from the environment, which the Claude configuration above sets.
101
+
102
+ | Environment variable | Required | Meaning |
103
+ |---|---|---|
104
+ | `DISCOGS_TOKEN` | yes | Your Discogs personal access token |
105
+ | `DISCOGS_CURRENCY` | no | Currency of prices: USD, GBP, EUR (default), CAD, AUD, JPY, CHF, MXN, BRL, NZD, SEK or ZAR. A tool call can still ask for another one. |
106
+
107
+ ## How it treats your data
108
+
109
+ - **Nothing is stored on disk.** Discogs data lives only in memory while the server runs:
110
+ catalog lookups and prices for an hour, the Collection and the Wantlist for at most five
111
+ minutes, and the first page of each is checked again on every call, so a Copy or Want you add
112
+ on Discogs shows at once.
113
+ - **The token stays private.** It is sent only to `api.discogs.com` and never appears in logs,
114
+ tool output or error messages.
115
+ - **The server paces itself** on the Discogs rate-limit headers and retries briefly when Discogs
116
+ asks it to slow down.
117
+ - Your Collection, Wantlist and prices reach Claude as tool results, like anything else you ask
118
+ Claude about.
119
+
120
+ ## Development
121
+
122
+ Requires uv 0.13.x and [just](https://just.systems).
123
+
124
+ ```sh
125
+ uv sync # create .venv from uv.lock
126
+ just check # ruff, mypy and pytest: the same command CI runs on Python 3.12–3.15
127
+ just fix # apply ruff fixes and formatting
128
+ just serve # run the server over stdio from the checkout (needs DISCOGS_TOKEN)
129
+ ```
130
+
131
+ To try a local checkout in Claude, use `uv run --directory /absolute/path/to/runout-mcp
132
+ runout-mcp` as the command. It runs the code as it is in the checkout; `uvx --from` would keep
133
+ serving the build it cached first.
134
+
135
+ Tests build the server through `create_server()` and call its tools through FastMCP's in-memory
136
+ client against a fake Discogs (`httpx2.MockTransport`) serving anonymized fixtures. No test touches
137
+ the network.
138
+
139
+ ### Releasing
140
+
141
+ Pushing a version tag publishes the package to PyPI through
142
+ [Trusted Publishing](https://docs.pypi.org/trusted-publishers/): GitHub Actions proves its
143
+ identity to PyPI with OIDC, so no PyPI token is stored anywhere.
144
+
145
+ 1. Set the new version in `pyproject.toml` and in both `version` fields of `server.json`, then
146
+ run `uv lock` and commit.
147
+ 2. Tag and push: `git tag -a v0.1.0 -m v0.1.0 && git push origin v0.1.0`. The release workflow
148
+ checks that the tag and both files name the same version, runs the checks, builds and
149
+ publishes.
150
+ 3. Publish the entry to the [MCP Registry](https://registry.modelcontextprotocol.io) once the
151
+ version is on PyPI: `mcp-publisher login github`, then `mcp-publisher publish`.
152
+
153
+ One-time setup before the first release: on PyPI, add a pending trusted publisher for the
154
+ project `runout-mcp` with owner `badta5te`, repository `runout-mcp`, workflow
155
+ `release.yml` and environment `pypi`; on GitHub, create the `pypi` environment under
156
+ **Settings → Environments**.
157
+
158
+ ## Discogs
159
+
160
+ Every response that contains Discogs data ends with "Data provided by Discogs" and a link to the
161
+ data on discogs.com.
162
+
163
+ This application uses Discogs’ API but is not affiliated with, sponsored or endorsed by Discogs.
164
+ ‘Discogs’ is a trademark of Zink Media, LLC.
165
+
166
+ ## License
167
+
168
+ Released under the [MIT License](https://github.com/badta5te/runout-mcp/blob/main/LICENSE).
169
+ Copyright (c) 2026 Pavel Mikhailov.
@@ -0,0 +1,87 @@
1
+ [project]
2
+ name = "runout-mcp"
3
+ version = "0.1.0"
4
+ description = "Runout for Discogs: an MCP server for your Discogs Collection, Wantlist, Releases and Marketplace prices."
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ requires-python = ">=3.12"
9
+ keywords = [
10
+ "mcp",
11
+ "discogs",
12
+ "vinyl",
13
+ "claude",
14
+ "record-collection",
15
+ ]
16
+ classifiers = [
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.12",
19
+ "Programming Language :: Python :: 3.13",
20
+ "Programming Language :: Python :: 3.14",
21
+ "Programming Language :: Python :: 3.15",
22
+ ]
23
+ dependencies = [
24
+ "fastmcp>=4.2.3,<4.3",
25
+ "httpx2>=2.16,<3",
26
+ "pydantic-settings>=2.16,<3",
27
+ ]
28
+
29
+ [[project.authors]]
30
+ name = "Pavel Mikhailov"
31
+
32
+ [project.urls]
33
+ Repository = "https://github.com/badta5te/runout-mcp"
34
+ Issues = "https://github.com/badta5te/runout-mcp/issues"
35
+
36
+ [project.scripts]
37
+ runout-mcp = "runout_mcp.server:main"
38
+
39
+ [build-system]
40
+ requires = ["uv_build>=0.13.9,<0.14.0"]
41
+ build-backend = "uv_build"
42
+
43
+ [dependency-groups]
44
+ dev = [
45
+ "inline-snapshot>=0.37.0",
46
+ "mypy>=2.4",
47
+ "pytest>=9",
48
+ "pytest-asyncio>=1.5",
49
+ "ruff>=0.17",
50
+ ]
51
+
52
+ [tool.pytest.ini_options]
53
+ asyncio_mode = "auto"
54
+ asyncio_default_fixture_loop_scope = "function"
55
+ testpaths = ["tests"]
56
+
57
+ [tool.ruff]
58
+ target-version = "py312"
59
+ line-length = 100
60
+ extend-exclude = ["docs"]
61
+
62
+ [tool.ruff.lint]
63
+ select = [
64
+ "E",
65
+ "F",
66
+ "W",
67
+ "I",
68
+ "UP",
69
+ "B",
70
+ "SIM",
71
+ "RUF",
72
+ "ASYNC",
73
+ "PT",
74
+ ]
75
+ allowed-confusables = [
76
+ "–",
77
+ "×",
78
+ ]
79
+
80
+ [tool.mypy]
81
+ python_version = "3.12"
82
+ strict = true
83
+ files = [
84
+ "src",
85
+ "tests",
86
+ ]
87
+ plugins = ["pydantic.mypy"]
@@ -0,0 +1,63 @@
1
+ [project]
2
+ name = "runout-mcp"
3
+ version = "0.1.0"
4
+ description = "Runout for Discogs: an MCP server for your Discogs Collection, Wantlist, Releases and Marketplace prices."
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ authors = [{ name = "Pavel Mikhailov" }]
9
+ requires-python = ">=3.12"
10
+ keywords = ["mcp", "discogs", "vinyl", "claude", "record-collection"]
11
+ classifiers = [
12
+ "Programming Language :: Python :: 3",
13
+ "Programming Language :: Python :: 3.12",
14
+ "Programming Language :: Python :: 3.13",
15
+ "Programming Language :: Python :: 3.14",
16
+ "Programming Language :: Python :: 3.15",
17
+ ]
18
+ dependencies = [
19
+ "fastmcp>=4.2.3,<4.3",
20
+ "httpx2>=2.16,<3",
21
+ "pydantic-settings>=2.16,<3",
22
+ ]
23
+
24
+ [project.urls]
25
+ Repository = "https://github.com/badta5te/runout-mcp"
26
+ Issues = "https://github.com/badta5te/runout-mcp/issues"
27
+
28
+ [project.scripts]
29
+ runout-mcp = "runout_mcp.server:main"
30
+
31
+ [build-system]
32
+ requires = ["uv_build>=0.13.9,<0.14.0"]
33
+ build-backend = "uv_build"
34
+
35
+ [dependency-groups]
36
+ dev = [
37
+ "inline-snapshot>=0.37.0",
38
+ "mypy>=2.4",
39
+ "pytest>=9",
40
+ "pytest-asyncio>=1.5",
41
+ "ruff>=0.17",
42
+ ]
43
+
44
+ [tool.pytest.ini_options]
45
+ asyncio_mode = "auto"
46
+ asyncio_default_fixture_loop_scope = "function"
47
+ testpaths = ["tests"]
48
+
49
+ [tool.ruff]
50
+ target-version = "py312"
51
+ line-length = 100
52
+ extend-exclude = ["docs"]
53
+
54
+ [tool.ruff.lint]
55
+ select = ["E", "F", "W", "I", "UP", "B", "SIM", "RUF", "ASYNC", "PT"]
56
+ # Typographic characters used on purpose in the cards Claude reads.
57
+ allowed-confusables = ["–", "×"]
58
+
59
+ [tool.mypy]
60
+ python_version = "3.12"
61
+ strict = true
62
+ files = ["src", "tests"]
63
+ plugins = ["pydantic.mypy"]
@@ -0,0 +1,5 @@
1
+ """Runout for Discogs: an MCP server over the Owner's Discogs world."""
2
+
3
+ from importlib.metadata import version
4
+
5
+ __version__ = version("runout-mcp")
@@ -0,0 +1,77 @@
1
+ """An in-memory cache with per-entry time to live.
2
+
3
+ Nothing is persisted: Discogs data lives only as long as the process (ADR-0002). The Owner's
4
+ Collection and Wantlist snapshots are checked against Discogs on every call (ADR-0003).
5
+ """
6
+
7
+ from collections.abc import Awaitable, Callable, Hashable
8
+ from datetime import datetime, timedelta
9
+ from typing import Any, NamedTuple, cast
10
+
11
+ from runout_mcp.clock import Clock
12
+
13
+ CATALOG_TTL = timedelta(hours=1)
14
+ PRICE_TTL = timedelta(hours=1)
15
+ # The longest a Collection or Wantlist snapshot is reused, however often its first page is
16
+ # confirmed unchanged: a backstop for changes that page cannot reveal (ADR-0003).
17
+ OWNER_SNAPSHOT_TTL = timedelta(minutes=5)
18
+
19
+
20
+ class _Entry(NamedTuple):
21
+ expires_at: datetime
22
+ value: Any
23
+
24
+
25
+ class TtlCache:
26
+ def __init__(self, clock: Clock) -> None:
27
+ self._clock = clock
28
+ self._entries: dict[Hashable, _Entry] = {}
29
+
30
+ async def get_or_load[T](
31
+ self, key: Hashable, ttl: timedelta, load: Callable[[], Awaitable[T]]
32
+ ) -> T:
33
+ """The cached value for `key`, or the result of `load()` kept for `ttl`.
34
+
35
+ The time to live counts from when `load()` returned, however long it waited. A failing
36
+ `load()` caches nothing, so the next call tries again.
37
+ """
38
+ entry = self._entries.get(key)
39
+ if entry is not None and self._clock.now() < entry.expires_at:
40
+ return cast(T, entry.value)
41
+ return self._store(key, ttl, await load())
42
+
43
+ async def revalidate[T](
44
+ self, key: Hashable, ttl: timedelta, load: Callable[[T | None], Awaitable[T]]
45
+ ) -> T:
46
+ """The result of `load(previous)`, where `previous` is the live value for `key` or None.
47
+
48
+ `load` returns `previous` itself to confirm it is still current: its time to live then
49
+ runs on, so repeated confirmations never postpone a full reload. Any other value is kept
50
+ for `ttl` from when `load()` returned. A failing `load()` leaves the entry as it was.
51
+ """
52
+ entry = self._entries.get(key)
53
+ previous = (
54
+ cast(T, entry.value)
55
+ if entry is not None and self._clock.now() < entry.expires_at
56
+ else None
57
+ )
58
+ value = await load(previous)
59
+ if previous is not None and value is previous:
60
+ return value
61
+ return self._store(key, ttl, value)
62
+
63
+ def drop(self, key: Hashable) -> None:
64
+ """Forget the value for `key`, so that the next call loads it afresh."""
65
+ self._entries.pop(key, None)
66
+
67
+ def _store[T](self, key: Hashable, ttl: timedelta, value: T) -> T:
68
+ """Keep `value` for `ttl` from now."""
69
+ loaded_at = self._clock.now()
70
+ self._evict_expired(loaded_at)
71
+ self._entries[key] = _Entry(loaded_at + ttl, value)
72
+ return value
73
+
74
+ def _evict_expired(self, now: datetime) -> None:
75
+ expired = [key for key, entry in self._entries.items() if entry.expires_at <= now]
76
+ for key in expired:
77
+ del self._entries[key]
@@ -0,0 +1,30 @@
1
+ """Time as the server sees it: the current moment and waiting.
2
+
3
+ Everything that depends on time (rate-limit pacing, retry backoff, cache expiry) goes through a
4
+ `Clock`, so tests can drive time without real waiting.
5
+ """
6
+
7
+ import asyncio
8
+ from datetime import UTC, datetime
9
+ from typing import Protocol
10
+
11
+
12
+ class Clock(Protocol):
13
+ def now(self) -> datetime:
14
+ """The current moment, timezone-aware."""
15
+ ...
16
+
17
+ async def sleep(self, seconds: float) -> None:
18
+ """Wait for `seconds` before returning."""
19
+ ...
20
+
21
+
22
+ class SystemClock:
23
+ """The real clock. Wall-clock UTC keeps advancing while the Mac sleeps, unlike a monotonic
24
+ clock, so cache entries still expire across a sleep."""
25
+
26
+ def now(self) -> datetime:
27
+ return datetime.now(UTC)
28
+
29
+ async def sleep(self, seconds: float) -> None:
30
+ await asyncio.sleep(seconds)