|
| 1 | +# Goose MCP Extension Fix: pubmed-mcp and simple-pubmed |
| 2 | + |
| 3 | +**Date:** November 4, 2025 |
| 4 | +**Issue:** 100% execution failures for pubmed-mcp and simple-pubmed with Goose |
| 5 | +**Status:** ✅ FIXED |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## Problem Summary |
| 10 | + |
| 11 | +All 25 tests (100%) for both `pubmed-mcp` and `simple-pubmed` failed when run with Goose, with the error: |
| 12 | +``` |
| 13 | +Error: Command '[...goose', 'run', '-t', '...', '--with-extension', '...']' |
| 14 | +returned non-zero exit status 1. |
| 15 | +``` |
| 16 | + |
| 17 | +This resulted in 0% pass rate for these two MCP servers in the cross-agent comparison, making the comparison invalid. |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +## Root Cause |
| 22 | + |
| 23 | +**Missing environment variables** when Goose launches MCP extensions. |
| 24 | + |
| 25 | +### What Was Happening |
| 26 | + |
| 27 | +1. Metacoder config defined environment variables for each MCP server: |
| 28 | + ```yaml |
| 29 | + simple-pubmed: |
| 30 | + env: |
| 31 | + PUBMED_EMAIL: ctparker@lbl.gov |
| 32 | + |
| 33 | + pubmed-mcp: |
| 34 | + env: |
| 35 | + PUBMED_API_KEY: "01eec0a16472164c6d69163bd28368311808" |
| 36 | + ``` |
| 37 | +
|
| 38 | +2. However, `pubmed-mcp` was **missing** the `PUBMED_EMAIL` env var that it actually requires |
| 39 | + |
| 40 | +3. When Goose runs with `--with-extension`, the MCP server initialization fails if required env vars are not present in the shell environment |
| 41 | + |
| 42 | +### Error Messages |
| 43 | + |
| 44 | +**simple-pubmed:** |
| 45 | +``` |
| 46 | +ValueError: PUBMED_EMAIL environment variable is required |
| 47 | +``` |
| 48 | +
|
| 49 | +**pubmed-mcp:** |
| 50 | +``` |
| 51 | +2025-11-04 11:08:12,411 - __main__ - ERROR - PUBMED_EMAIL environment variable is required |
| 52 | +``` |
| 53 | +
|
| 54 | +--- |
| 55 | +
|
| 56 | +## Investigation & Testing |
| 57 | +
|
| 58 | +### Manual Testing |
| 59 | +
|
| 60 | +**Test 1: simple-pubmed WITHOUT PUBMED_EMAIL** |
| 61 | +```bash |
| 62 | +goose run -t "Test" --with-extension "uvx mcp-simple-pubmed" |
| 63 | +# Result: Failed - "PUBMED_EMAIL environment variable is required" |
| 64 | +``` |
| 65 | + |
| 66 | +**Test 2: simple-pubmed WITH PUBMED_EMAIL** |
| 67 | +```bash |
| 68 | +export PUBMED_EMAIL=justinreese@lbl.gov |
| 69 | +goose run -t "Test" --with-extension "uvx mcp-simple-pubmed" |
| 70 | +# Result: ✅ Success - "The connection appears to be working properly" |
| 71 | +``` |
| 72 | + |
| 73 | +**Test 3: pubmed-mcp WITH ONLY PUBMED_API_KEY** |
| 74 | +```bash |
| 75 | +export PUBMED_API_KEY=01eec0a16472164c6d69163bd28368311808 |
| 76 | +goose run -t "Test" --with-extension "uv run --with git+https://github.com/chrismannina/pubmed-mcp@main -m src.main" |
| 77 | +# Result: Failed - "PUBMED_EMAIL environment variable is required" |
| 78 | +``` |
| 79 | + |
| 80 | +**Test 4: pubmed-mcp WITH BOTH ENV VARS** |
| 81 | +```bash |
| 82 | +export PUBMED_API_KEY=01eec0a16472164c6d69163bd28368311808 |
| 83 | +export PUBMED_EMAIL=justinreese@lbl.gov |
| 84 | +goose run -t "Test" --with-extension "uv run --with git+https://github.com/chrismannina/pubmed-mcp@main -m src.main" |
| 85 | +# Result: ✅ Success - "The connection is working properly" |
| 86 | +``` |
| 87 | + |
| 88 | +--- |
| 89 | + |
| 90 | +## The Fix |
| 91 | + |
| 92 | +### Changes to `project/literature_mcp_eval_config.yaml` |
| 93 | + |
| 94 | +**1. Update simple-pubmed email:** |
| 95 | +```yaml |
| 96 | +# BEFORE |
| 97 | +simple-pubmed: |
| 98 | + env: |
| 99 | + PUBMED_EMAIL: ctparker@lbl.gov |
| 100 | + |
| 101 | +# AFTER |
| 102 | +simple-pubmed: |
| 103 | + env: |
| 104 | + PUBMED_EMAIL: justinreese@lbl.gov |
| 105 | +``` |
| 106 | +
|
| 107 | +**2. Add PUBMED_EMAIL to pubmed-mcp:** |
| 108 | +```yaml |
| 109 | +# BEFORE |
| 110 | +pubmed-mcp: |
| 111 | + env: |
| 112 | + PUBMED_API_KEY: "01eec0a16472164c6d69163bd28368311808" |
| 113 | + |
| 114 | +# AFTER |
| 115 | +pubmed-mcp: |
| 116 | + env: |
| 117 | + PUBMED_API_KEY: "01eec0a16472164c6d69163bd28368311808" |
| 118 | + PUBMED_EMAIL: justinreese@lbl.gov |
| 119 | +``` |
| 120 | +
|
| 121 | +--- |
| 122 | +
|
| 123 | +## How Metacoder Should Handle This |
| 124 | +
|
| 125 | +The metacoder Goose coder implementation needs to: |
| 126 | +
|
| 127 | +1. **Extract environment variables** from the server config |
| 128 | +2. **Set them in the subprocess environment** when launching Goose |
| 129 | +3. **Pass them through** to the MCP extensions |
| 130 | +
|
| 131 | +### Current Implementation Gap |
| 132 | +
|
| 133 | +Metacoder currently builds the Goose command like this: |
| 134 | +```python |
| 135 | +command = ["goose", "run", "-t", text, "--with-extension", "uvx mcp-simple-pubmed"] |
| 136 | +subprocess.run(command, env=os.environ.copy()) |
| 137 | +``` |
| 138 | + |
| 139 | +### What It Should Do |
| 140 | + |
| 141 | +```python |
| 142 | +# Build environment with MCP server env vars |
| 143 | +env = os.environ.copy() |
| 144 | +for mcp in self.config.extensions: |
| 145 | + if mcp.env: |
| 146 | + env.update(mcp.env) |
| 147 | + |
| 148 | +# Run Goose with enhanced environment |
| 149 | +command = ["goose", "run", "-t", text, "--with-extension", "uvx mcp-simple-pubmed"] |
| 150 | +subprocess.run(command, env=env) |
| 151 | +``` |
| 152 | + |
| 153 | +**Note:** This fix may already be implemented in the local metacoder patches. Check `.venv/lib/python3.10/site-packages/metacoder/coders/goose.py` for the current implementation. |
| 154 | + |
| 155 | +--- |
| 156 | + |
| 157 | +## Expected Impact |
| 158 | + |
| 159 | +After this fix, re-running the Goose evaluation should: |
| 160 | + |
| 161 | +1. **pubmed-mcp**: Move from 0% pass rate (all crashes) to actual test results |
| 162 | +2. **simple-pubmed**: Move from 0% pass rate (all crashes) to actual test results |
| 163 | +3. **Valid cross-agent comparison**: Can now properly compare Claude vs Goose for all 4 MCPs |
| 164 | + |
| 165 | +### Predicted Pass Rates |
| 166 | + |
| 167 | +Based on artl and biomcp performance (both at 20% with Goose), we estimate: |
| 168 | +- **pubmed-mcp with Goose**: ~15-25% pass rate |
| 169 | +- **simple-pubmed with Goose**: ~15-25% pass rate |
| 170 | + |
| 171 | +This would still show Claude Code significantly outperforming Goose, but with valid data across all MCPs. |
| 172 | + |
| 173 | +--- |
| 174 | + |
| 175 | +## Next Steps |
| 176 | + |
| 177 | +1. ✅ Fix configuration files (DONE) |
| 178 | +2. ⏳ Re-run Goose evaluation: `./run_goose_eval_fixed.sh` |
| 179 | +3. ⏳ Re-run cross-agent analysis notebook |
| 180 | +4. ⏳ Update `EXPERIMENT_1_RESULTS.md` with corrected findings |
| 181 | +5. ⏳ Commit and push updated results |
| 182 | + |
| 183 | +--- |
| 184 | + |
| 185 | +## Lessons Learned |
| 186 | + |
| 187 | +### 1. Environment Variable Requirements are Implicit |
| 188 | + |
| 189 | +Both `simple-pubmed` and `pubmed-mcp` require `PUBMED_EMAIL`, but: |
| 190 | +- This wasn't obvious from the MCP names |
| 191 | +- Documentation may not clearly state all required env vars |
| 192 | +- Trial and error testing revealed the requirement |
| 193 | + |
| 194 | +### 2. Config Inconsistency |
| 195 | + |
| 196 | +The config had: |
| 197 | +- `PUBMED_EMAIL` for simple-pubmed ✓ |
| 198 | +- `PUBMED_API_KEY` for pubmed-mcp ✓ |
| 199 | +- But **missing** `PUBMED_EMAIL` for pubmed-mcp ✗ |
| 200 | + |
| 201 | +### 3. Evaluation Framework Complexity |
| 202 | + |
| 203 | +When using evaluation frameworks like metacoder with multiple agents and MCP servers: |
| 204 | +- Environment variable passing becomes complex |
| 205 | +- Agent-specific quirks (Goose's `--with-extension`) add layers |
| 206 | +- Manual testing of individual commands is essential |
| 207 | + |
| 208 | +### 4. Error Messages Can Be Hidden |
| 209 | + |
| 210 | +The actual error messages were buried in subprocess stderr output, marked as "execution errors" rather than being surfaced clearly in the evaluation results. |
| 211 | + |
| 212 | +--- |
| 213 | + |
| 214 | +## Related Documentation |
| 215 | + |
| 216 | +- **Metacoder Fixes:** `METACODER_FIXES.md` |
| 217 | +- **Experiment 1 Results:** `notes/EXPERIMENT_1_RESULTS.md` |
| 218 | +- **How to Run:** `notebook/experiment_1_how_to_run.ipynb` |
| 219 | +- **Goose Extension Fix Patch:** `metacoder_goose_extension_fix.patch` |
0 commit comments