repro-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.
- repro_mcp-0.1.0/.gitignore +12 -0
- repro_mcp-0.1.0/PKG-INFO +318 -0
- repro_mcp-0.1.0/README.md +293 -0
- repro_mcp-0.1.0/pyproject.toml +42 -0
- repro_mcp-0.1.0/repro_defaults/rules.yaml +29 -0
- repro_mcp-0.1.0/src/repro_mcp/__init__.py +0 -0
- repro_mcp-0.1.0/src/repro_mcp/cli.py +113 -0
- repro_mcp-0.1.0/src/repro_mcp/environment.py +75 -0
- repro_mcp-0.1.0/src/repro_mcp/logger.py +165 -0
- repro_mcp-0.1.0/src/repro_mcp/rules.py +168 -0
- repro_mcp-0.1.0/src/repro_mcp/server.py +380 -0
- repro_mcp-0.1.0/src/repro_mcp/session.py +87 -0
- repro_mcp-0.1.0/tests/test_core.py +169 -0
repro_mcp-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: repro-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Reproducibility logging and rule enforcement MCP server for scientific computing
|
|
5
|
+
Project-URL: Homepage, https://github.com/ABindoff/repro-mcp
|
|
6
|
+
Project-URL: Repository, https://github.com/ABindoff/repro-mcp
|
|
7
|
+
Project-URL: Issues, https://github.com/ABindoff/repro-mcp/issues
|
|
8
|
+
Author: ABindoff
|
|
9
|
+
License: MIT
|
|
10
|
+
Keywords: ai,logging,mcp,reproducibility,science
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering
|
|
19
|
+
Requires-Python: >=3.11
|
|
20
|
+
Requires-Dist: mcp[cli]>=1.0.0
|
|
21
|
+
Requires-Dist: pyyaml>=6.0
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# repro-mcp
|
|
27
|
+
|
|
28
|
+
An MCP server that brings reproducibility logging to AI-assisted scientific computing.
|
|
29
|
+
|
|
30
|
+
Git records *what* changed. `repro-mcp` records *why* — logging prompts, responses, methodological decisions, and environment snapshots to human-readable markdown files that live alongside your code.
|
|
31
|
+
|
|
32
|
+
Built for researchers working under privacy or funding constraints who run models locally and need an audit trail that holds up to peer review.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Why this exists
|
|
37
|
+
|
|
38
|
+
AI coding assistants are increasingly used in scientific workflows, but the interaction between a researcher and an AI — the prompts, the reasoning, the alternatives considered — disappears when the session ends. This matters because:
|
|
39
|
+
|
|
40
|
+
- A methods section can't cite a conversation
|
|
41
|
+
- A future collaborator can't reproduce your reasoning, only your code
|
|
42
|
+
- Environment drift silently breaks analyses months later
|
|
43
|
+
|
|
44
|
+
`repro-mcp` captures all of this locally. No cloud dependency. No data leaves the machine.
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## How it works
|
|
49
|
+
|
|
50
|
+
`repro-mcp` is a [Model Context Protocol](https://modelcontextprotocol.io) server. Any MCP-compatible AI client (Claude Code, Cline, Cursor, Continue) can connect to it. It exposes tools the AI can call to:
|
|
51
|
+
|
|
52
|
+
- Open a session and snapshot the environment
|
|
53
|
+
- Log each prompt/response exchange
|
|
54
|
+
- Record significant decisions and the alternatives that were rejected
|
|
55
|
+
- Check code against reproducibility rules before it runs
|
|
56
|
+
- Close the session with a git diff summary
|
|
57
|
+
|
|
58
|
+
All output goes to `.repro/` in your project directory — plain markdown, git-friendly, human-readable.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Installation
|
|
63
|
+
|
|
64
|
+
Requires Python 3.11+. The recommended way is via [`uv`](https://docs.astral.sh/uv/):
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# No install step — uvx runs it in an isolated environment
|
|
68
|
+
uvx repro-mcp
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Or with pip:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
pip install repro-mcp
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Or from source:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
git clone https://github.com/ABindoff/repro-mcp.git
|
|
81
|
+
cd repro-mcp
|
|
82
|
+
pip install -e .
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Configuration
|
|
88
|
+
|
|
89
|
+
### Claude Code
|
|
90
|
+
|
|
91
|
+
Add it manually to `.mcp.json` in your project root (recommended — checked into git alongside your code):
|
|
92
|
+
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"mcpServers": {
|
|
96
|
+
"repro-mcp": {
|
|
97
|
+
"command": "uvx",
|
|
98
|
+
"args": ["repro-mcp"]
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Or register globally via the Claude Code CLI:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
claude mcp add repro-mcp --scope user -- uvx repro-mcp
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Verify it's running with `claude mcp list`.
|
|
111
|
+
|
|
112
|
+
#### Auto-start via hooks (recommended)
|
|
113
|
+
|
|
114
|
+
Calling `session_start` manually triggers a permission prompt. The better approach is a `UserPromptSubmit` hook that auto-starts a session on your first message — no prompts, no manual steps.
|
|
115
|
+
|
|
116
|
+
Add this to `~/.claude/settings.json` (global, applies to all projects):
|
|
117
|
+
|
|
118
|
+
```json
|
|
119
|
+
{
|
|
120
|
+
"hooks": {
|
|
121
|
+
"UserPromptSubmit": [
|
|
122
|
+
{
|
|
123
|
+
"hooks": [
|
|
124
|
+
{
|
|
125
|
+
"type": "command",
|
|
126
|
+
"command": "repro start",
|
|
127
|
+
"timeout": 30
|
|
128
|
+
}
|
|
129
|
+
]
|
|
130
|
+
}
|
|
131
|
+
]
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
The `repro` command is installed alongside `repro-mcp`. It auto-detects the project name from your current directory and uses `"Claude Code session"` as the default goal. You can override either:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
repro start my-project "Fit Cox model to patient cohort"
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
The hook is idempotent — if a session is already active it exits silently, so firing on every message is safe.
|
|
143
|
+
|
|
144
|
+
#### Ending a session
|
|
145
|
+
|
|
146
|
+
Close the active session from the terminal when you're done:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
repro end success # or: abandoned, inconclusive
|
|
150
|
+
repro end success --notes "Switched to Efron method"
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Or call `session_end` via the MCP tool if you've allowlisted repro-mcp tools (add `"mcp__repro-mcp__*"` to the `permissions.allow` array in `~/.claude/settings.local.json`).
|
|
154
|
+
|
|
155
|
+
#### Allowlisting MCP tools (optional)
|
|
156
|
+
|
|
157
|
+
If you want to call repro-mcp tools directly (e.g. `log_decision`, `log_exchange`) without permission prompts, add this to `~/.claude/settings.local.json`:
|
|
158
|
+
|
|
159
|
+
```json
|
|
160
|
+
{
|
|
161
|
+
"permissions": {
|
|
162
|
+
"allow": ["mcp__repro-mcp__*"]
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Cline (VS Code extension)
|
|
168
|
+
|
|
169
|
+
Open Cline settings → MCP Servers → add:
|
|
170
|
+
|
|
171
|
+
```json
|
|
172
|
+
{
|
|
173
|
+
"repro-mcp": {
|
|
174
|
+
"command": "python",
|
|
175
|
+
"args": ["-m", "repro_mcp.server"],
|
|
176
|
+
"cwd": "${workspaceFolder}"
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Cline SDK / CLI
|
|
182
|
+
|
|
183
|
+
Use the `afterModel` hook to log every turn automatically:
|
|
184
|
+
|
|
185
|
+
```python
|
|
186
|
+
from cline import AgentPlugin
|
|
187
|
+
|
|
188
|
+
repro_plugin: AgentPlugin = {
|
|
189
|
+
"hooks": {
|
|
190
|
+
"afterModel": async ({ snapshot, assistantMessage }) => {
|
|
191
|
+
await mcpClient.callTool("log_exchange", {
|
|
192
|
+
"session_id": your_session_id,
|
|
193
|
+
"prompt": snapshot.lastUserMessage,
|
|
194
|
+
"response": assistantMessage.content,
|
|
195
|
+
})
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Tools
|
|
204
|
+
|
|
205
|
+
| Tool | Description |
|
|
206
|
+
|---|---|
|
|
207
|
+
| `session_start` | Open a session, snapshot the environment, create the log file |
|
|
208
|
+
| `session_end` | Close the session, write git diff summary, update the index |
|
|
209
|
+
| `log_exchange` | Log a prompt/response pair with optional tags |
|
|
210
|
+
| `log_decision` | Log a methodological decision with rationale and alternatives |
|
|
211
|
+
| `snapshot_environment` | Capture a mid-session environment snapshot |
|
|
212
|
+
| `check_rules` | Check code against reproducibility rules before running |
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## Log format
|
|
217
|
+
|
|
218
|
+
Each session produces `.repro/logs/YYYY-MM-DDTHHMMSS.md`:
|
|
219
|
+
|
|
220
|
+
```markdown
|
|
221
|
+
# Session: 2026-05-14T143022
|
|
222
|
+
**Project:** survival-analysis
|
|
223
|
+
**Goal:** Fit Cox model to patient cohort, compare AIC across covariates
|
|
224
|
+
**Branch:** feature/cox-model
|
|
225
|
+
**Git hash:** a3f9c12d8e41
|
|
226
|
+
|
|
227
|
+
### Environment snapshot `2026-05-14T14:30:22+00:00`
|
|
228
|
+
- **Python:** 3.11.4
|
|
229
|
+
- **Platform:** Linux 6.5.0 (x86_64)
|
|
230
|
+
- **Git:** `a3f9c12d8e41` (feature/cox-model)
|
|
231
|
+
|
|
232
|
+
**Packages:**
|
|
233
|
+
```
|
|
234
|
+
lifelines==0.29.0
|
|
235
|
+
numpy==1.26.4
|
|
236
|
+
pandas==2.2.1
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## Exchange — 14:30:45
|
|
242
|
+
**Prompt:** How should I handle tied survival times in the Cox model?
|
|
243
|
+
**Response:** The three standard methods are Breslow, Efron, and Exact...
|
|
244
|
+
**Tags:** `model-fit`
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## Decision — 14:47:12
|
|
249
|
+
**Decision:** Use Efron method for tie handling
|
|
250
|
+
**Rationale:** More accurate than Breslow when tie rate exceeds ~5%; our cohort has ~12% tied events
|
|
251
|
+
**Alternatives considered:** Breslow (rejected — bias at this tie rate); Exact (rejected — O(n!) complexity at n=14k)
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## Session close — 15:45:00
|
|
256
|
+
**Outcome:** success
|
|
257
|
+
|
|
258
|
+
**Git diff summary:**
|
|
259
|
+
```
|
|
260
|
+
3 files changed, 142 insertions(+), 7 deletions(-)
|
|
261
|
+
```
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
An index of all sessions is maintained at `.repro/index.md`.
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
## Rules
|
|
269
|
+
|
|
270
|
+
`repro-mcp` ships with five built-in rules. Configure them by copying `repro_defaults/rules.yaml` to `.repro/rules.yaml` in your project.
|
|
271
|
+
|
|
272
|
+
| Rule | Severity | What it checks |
|
|
273
|
+
|---|---|---|
|
|
274
|
+
| `random-seed` | error | Any RNG call must have a seed set in scope |
|
|
275
|
+
| `env-pinned` | warn | `requirements.txt` / `environment.yml` must pin versions |
|
|
276
|
+
| `no-hardcoded-paths` | error | No absolute paths outside of config files |
|
|
277
|
+
| `no-inplace-data-mutation` | warn | Raw data directories should not be written to |
|
|
278
|
+
| `gpu-nondeterminism` | info | CUDA ops detected without determinism flags |
|
|
279
|
+
|
|
280
|
+
To disable a rule:
|
|
281
|
+
|
|
282
|
+
```yaml
|
|
283
|
+
# .repro/rules.yaml
|
|
284
|
+
rules:
|
|
285
|
+
gpu-nondeterminism:
|
|
286
|
+
enabled: false
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
## Project layout
|
|
292
|
+
|
|
293
|
+
```
|
|
294
|
+
your-project/
|
|
295
|
+
└── .repro/
|
|
296
|
+
├── index.md # table of all sessions
|
|
297
|
+
├── rules.yaml # rule configuration (optional)
|
|
298
|
+
└── logs/
|
|
299
|
+
├── 2026-05-14T143022.md
|
|
300
|
+
└── 2026-05-14T160011.md
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
Add `.repro/logs/` to `.gitignore` if you want to keep logs local, or commit them to give collaborators the full audit trail.
|
|
304
|
+
|
|
305
|
+
---
|
|
306
|
+
|
|
307
|
+
## Roadmap
|
|
308
|
+
|
|
309
|
+
- [x] Publish to PyPI
|
|
310
|
+
- [ ] Cline upstream PR: `PostAssistantTurn` hook for automatic `log_exchange` calls in the VS Code extension
|
|
311
|
+
- [ ] `data-provenance` rule: flag data loading that doesn't reference a hash or versioned source
|
|
312
|
+
- [ ] Export session log as a structured methods-section draft
|
|
313
|
+
|
|
314
|
+
---
|
|
315
|
+
|
|
316
|
+
## Contributing
|
|
317
|
+
|
|
318
|
+
Issues and PRs welcome. The Cline integration gap (automatic per-turn logging in the VS Code extension) is the most impactful open problem — see the [Cline repo](https://github.com/cline/cline) if you want to help.
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
# repro-mcp
|
|
2
|
+
|
|
3
|
+
An MCP server that brings reproducibility logging to AI-assisted scientific computing.
|
|
4
|
+
|
|
5
|
+
Git records *what* changed. `repro-mcp` records *why* — logging prompts, responses, methodological decisions, and environment snapshots to human-readable markdown files that live alongside your code.
|
|
6
|
+
|
|
7
|
+
Built for researchers working under privacy or funding constraints who run models locally and need an audit trail that holds up to peer review.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Why this exists
|
|
12
|
+
|
|
13
|
+
AI coding assistants are increasingly used in scientific workflows, but the interaction between a researcher and an AI — the prompts, the reasoning, the alternatives considered — disappears when the session ends. This matters because:
|
|
14
|
+
|
|
15
|
+
- A methods section can't cite a conversation
|
|
16
|
+
- A future collaborator can't reproduce your reasoning, only your code
|
|
17
|
+
- Environment drift silently breaks analyses months later
|
|
18
|
+
|
|
19
|
+
`repro-mcp` captures all of this locally. No cloud dependency. No data leaves the machine.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## How it works
|
|
24
|
+
|
|
25
|
+
`repro-mcp` is a [Model Context Protocol](https://modelcontextprotocol.io) server. Any MCP-compatible AI client (Claude Code, Cline, Cursor, Continue) can connect to it. It exposes tools the AI can call to:
|
|
26
|
+
|
|
27
|
+
- Open a session and snapshot the environment
|
|
28
|
+
- Log each prompt/response exchange
|
|
29
|
+
- Record significant decisions and the alternatives that were rejected
|
|
30
|
+
- Check code against reproducibility rules before it runs
|
|
31
|
+
- Close the session with a git diff summary
|
|
32
|
+
|
|
33
|
+
All output goes to `.repro/` in your project directory — plain markdown, git-friendly, human-readable.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
Requires Python 3.11+. The recommended way is via [`uv`](https://docs.astral.sh/uv/):
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# No install step — uvx runs it in an isolated environment
|
|
43
|
+
uvx repro-mcp
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Or with pip:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install repro-mcp
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Or from source:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
git clone https://github.com/ABindoff/repro-mcp.git
|
|
56
|
+
cd repro-mcp
|
|
57
|
+
pip install -e .
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Configuration
|
|
63
|
+
|
|
64
|
+
### Claude Code
|
|
65
|
+
|
|
66
|
+
Add it manually to `.mcp.json` in your project root (recommended — checked into git alongside your code):
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"mcpServers": {
|
|
71
|
+
"repro-mcp": {
|
|
72
|
+
"command": "uvx",
|
|
73
|
+
"args": ["repro-mcp"]
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Or register globally via the Claude Code CLI:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
claude mcp add repro-mcp --scope user -- uvx repro-mcp
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Verify it's running with `claude mcp list`.
|
|
86
|
+
|
|
87
|
+
#### Auto-start via hooks (recommended)
|
|
88
|
+
|
|
89
|
+
Calling `session_start` manually triggers a permission prompt. The better approach is a `UserPromptSubmit` hook that auto-starts a session on your first message — no prompts, no manual steps.
|
|
90
|
+
|
|
91
|
+
Add this to `~/.claude/settings.json` (global, applies to all projects):
|
|
92
|
+
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"hooks": {
|
|
96
|
+
"UserPromptSubmit": [
|
|
97
|
+
{
|
|
98
|
+
"hooks": [
|
|
99
|
+
{
|
|
100
|
+
"type": "command",
|
|
101
|
+
"command": "repro start",
|
|
102
|
+
"timeout": 30
|
|
103
|
+
}
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
The `repro` command is installed alongside `repro-mcp`. It auto-detects the project name from your current directory and uses `"Claude Code session"` as the default goal. You can override either:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
repro start my-project "Fit Cox model to patient cohort"
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
The hook is idempotent — if a session is already active it exits silently, so firing on every message is safe.
|
|
118
|
+
|
|
119
|
+
#### Ending a session
|
|
120
|
+
|
|
121
|
+
Close the active session from the terminal when you're done:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
repro end success # or: abandoned, inconclusive
|
|
125
|
+
repro end success --notes "Switched to Efron method"
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Or call `session_end` via the MCP tool if you've allowlisted repro-mcp tools (add `"mcp__repro-mcp__*"` to the `permissions.allow` array in `~/.claude/settings.local.json`).
|
|
129
|
+
|
|
130
|
+
#### Allowlisting MCP tools (optional)
|
|
131
|
+
|
|
132
|
+
If you want to call repro-mcp tools directly (e.g. `log_decision`, `log_exchange`) without permission prompts, add this to `~/.claude/settings.local.json`:
|
|
133
|
+
|
|
134
|
+
```json
|
|
135
|
+
{
|
|
136
|
+
"permissions": {
|
|
137
|
+
"allow": ["mcp__repro-mcp__*"]
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Cline (VS Code extension)
|
|
143
|
+
|
|
144
|
+
Open Cline settings → MCP Servers → add:
|
|
145
|
+
|
|
146
|
+
```json
|
|
147
|
+
{
|
|
148
|
+
"repro-mcp": {
|
|
149
|
+
"command": "python",
|
|
150
|
+
"args": ["-m", "repro_mcp.server"],
|
|
151
|
+
"cwd": "${workspaceFolder}"
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Cline SDK / CLI
|
|
157
|
+
|
|
158
|
+
Use the `afterModel` hook to log every turn automatically:
|
|
159
|
+
|
|
160
|
+
```python
|
|
161
|
+
from cline import AgentPlugin
|
|
162
|
+
|
|
163
|
+
repro_plugin: AgentPlugin = {
|
|
164
|
+
"hooks": {
|
|
165
|
+
"afterModel": async ({ snapshot, assistantMessage }) => {
|
|
166
|
+
await mcpClient.callTool("log_exchange", {
|
|
167
|
+
"session_id": your_session_id,
|
|
168
|
+
"prompt": snapshot.lastUserMessage,
|
|
169
|
+
"response": assistantMessage.content,
|
|
170
|
+
})
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Tools
|
|
179
|
+
|
|
180
|
+
| Tool | Description |
|
|
181
|
+
|---|---|
|
|
182
|
+
| `session_start` | Open a session, snapshot the environment, create the log file |
|
|
183
|
+
| `session_end` | Close the session, write git diff summary, update the index |
|
|
184
|
+
| `log_exchange` | Log a prompt/response pair with optional tags |
|
|
185
|
+
| `log_decision` | Log a methodological decision with rationale and alternatives |
|
|
186
|
+
| `snapshot_environment` | Capture a mid-session environment snapshot |
|
|
187
|
+
| `check_rules` | Check code against reproducibility rules before running |
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Log format
|
|
192
|
+
|
|
193
|
+
Each session produces `.repro/logs/YYYY-MM-DDTHHMMSS.md`:
|
|
194
|
+
|
|
195
|
+
```markdown
|
|
196
|
+
# Session: 2026-05-14T143022
|
|
197
|
+
**Project:** survival-analysis
|
|
198
|
+
**Goal:** Fit Cox model to patient cohort, compare AIC across covariates
|
|
199
|
+
**Branch:** feature/cox-model
|
|
200
|
+
**Git hash:** a3f9c12d8e41
|
|
201
|
+
|
|
202
|
+
### Environment snapshot `2026-05-14T14:30:22+00:00`
|
|
203
|
+
- **Python:** 3.11.4
|
|
204
|
+
- **Platform:** Linux 6.5.0 (x86_64)
|
|
205
|
+
- **Git:** `a3f9c12d8e41` (feature/cox-model)
|
|
206
|
+
|
|
207
|
+
**Packages:**
|
|
208
|
+
```
|
|
209
|
+
lifelines==0.29.0
|
|
210
|
+
numpy==1.26.4
|
|
211
|
+
pandas==2.2.1
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## Exchange — 14:30:45
|
|
217
|
+
**Prompt:** How should I handle tied survival times in the Cox model?
|
|
218
|
+
**Response:** The three standard methods are Breslow, Efron, and Exact...
|
|
219
|
+
**Tags:** `model-fit`
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## Decision — 14:47:12
|
|
224
|
+
**Decision:** Use Efron method for tie handling
|
|
225
|
+
**Rationale:** More accurate than Breslow when tie rate exceeds ~5%; our cohort has ~12% tied events
|
|
226
|
+
**Alternatives considered:** Breslow (rejected — bias at this tie rate); Exact (rejected — O(n!) complexity at n=14k)
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## Session close — 15:45:00
|
|
231
|
+
**Outcome:** success
|
|
232
|
+
|
|
233
|
+
**Git diff summary:**
|
|
234
|
+
```
|
|
235
|
+
3 files changed, 142 insertions(+), 7 deletions(-)
|
|
236
|
+
```
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
An index of all sessions is maintained at `.repro/index.md`.
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
## Rules
|
|
244
|
+
|
|
245
|
+
`repro-mcp` ships with five built-in rules. Configure them by copying `repro_defaults/rules.yaml` to `.repro/rules.yaml` in your project.
|
|
246
|
+
|
|
247
|
+
| Rule | Severity | What it checks |
|
|
248
|
+
|---|---|---|
|
|
249
|
+
| `random-seed` | error | Any RNG call must have a seed set in scope |
|
|
250
|
+
| `env-pinned` | warn | `requirements.txt` / `environment.yml` must pin versions |
|
|
251
|
+
| `no-hardcoded-paths` | error | No absolute paths outside of config files |
|
|
252
|
+
| `no-inplace-data-mutation` | warn | Raw data directories should not be written to |
|
|
253
|
+
| `gpu-nondeterminism` | info | CUDA ops detected without determinism flags |
|
|
254
|
+
|
|
255
|
+
To disable a rule:
|
|
256
|
+
|
|
257
|
+
```yaml
|
|
258
|
+
# .repro/rules.yaml
|
|
259
|
+
rules:
|
|
260
|
+
gpu-nondeterminism:
|
|
261
|
+
enabled: false
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## Project layout
|
|
267
|
+
|
|
268
|
+
```
|
|
269
|
+
your-project/
|
|
270
|
+
└── .repro/
|
|
271
|
+
├── index.md # table of all sessions
|
|
272
|
+
├── rules.yaml # rule configuration (optional)
|
|
273
|
+
└── logs/
|
|
274
|
+
├── 2026-05-14T143022.md
|
|
275
|
+
└── 2026-05-14T160011.md
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
Add `.repro/logs/` to `.gitignore` if you want to keep logs local, or commit them to give collaborators the full audit trail.
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## Roadmap
|
|
283
|
+
|
|
284
|
+
- [x] Publish to PyPI
|
|
285
|
+
- [ ] Cline upstream PR: `PostAssistantTurn` hook for automatic `log_exchange` calls in the VS Code extension
|
|
286
|
+
- [ ] `data-provenance` rule: flag data loading that doesn't reference a hash or versioned source
|
|
287
|
+
- [ ] Export session log as a structured methods-section draft
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
## Contributing
|
|
292
|
+
|
|
293
|
+
Issues and PRs welcome. The Cline integration gap (automatic per-turn logging in the VS Code extension) is the most impactful open problem — see the [Cline repo](https://github.com/cline/cline) if you want to help.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "repro-mcp"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Reproducibility logging and rule enforcement MCP server for scientific computing"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
authors = [{ name = "ABindoff" }]
|
|
12
|
+
requires-python = ">=3.11"
|
|
13
|
+
keywords = ["mcp", "reproducibility", "science", "logging", "ai"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Intended Audience :: Science/Research",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.11",
|
|
20
|
+
"Programming Language :: Python :: 3.12",
|
|
21
|
+
"Programming Language :: Python :: 3.13",
|
|
22
|
+
"Topic :: Scientific/Engineering",
|
|
23
|
+
]
|
|
24
|
+
dependencies = [
|
|
25
|
+
"mcp[cli]>=1.0.0",
|
|
26
|
+
"pyyaml>=6.0",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[project.optional-dependencies]
|
|
30
|
+
dev = ["pytest>=8.0"]
|
|
31
|
+
|
|
32
|
+
[project.urls]
|
|
33
|
+
Homepage = "https://github.com/ABindoff/repro-mcp"
|
|
34
|
+
Repository = "https://github.com/ABindoff/repro-mcp"
|
|
35
|
+
Issues = "https://github.com/ABindoff/repro-mcp/issues"
|
|
36
|
+
|
|
37
|
+
[project.scripts]
|
|
38
|
+
repro-mcp = "repro_mcp.server:main"
|
|
39
|
+
repro = "repro_mcp.cli:main"
|
|
40
|
+
|
|
41
|
+
[tool.hatch.build.targets.wheel]
|
|
42
|
+
packages = ["src/repro_mcp"]
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# repro-mcp rule configuration
|
|
2
|
+
# Copy this file to .repro/rules.yaml in your project to customise.
|
|
3
|
+
# All rules are enabled by default. Set enabled: false to silence a rule.
|
|
4
|
+
|
|
5
|
+
rules:
|
|
6
|
+
random-seed:
|
|
7
|
+
enabled: true
|
|
8
|
+
# Any RNG call must have a corresponding seed set in the same context.
|
|
9
|
+
# Severity: error — blocks reproducibility entirely if violated.
|
|
10
|
+
|
|
11
|
+
env-pinned:
|
|
12
|
+
enabled: true
|
|
13
|
+
# requirements.txt or environment.yml must pin package versions.
|
|
14
|
+
# Severity: warn — environment drift is a common silent failure mode.
|
|
15
|
+
|
|
16
|
+
no-hardcoded-paths:
|
|
17
|
+
enabled: true
|
|
18
|
+
# Absolute paths break portability across machines and users.
|
|
19
|
+
# Severity: error — use config files or relative paths instead.
|
|
20
|
+
|
|
21
|
+
no-inplace-data-mutation:
|
|
22
|
+
enabled: true
|
|
23
|
+
# Raw data directories should be read-only.
|
|
24
|
+
# Severity: warn — overwriting raw data is irreversible.
|
|
25
|
+
|
|
26
|
+
gpu-nondeterminism:
|
|
27
|
+
enabled: true
|
|
28
|
+
# CUDA operations can be nondeterministic by default.
|
|
29
|
+
# Severity: info — set torch.use_deterministic_algorithms(True) to fix.
|
|
File without changes
|