Skip to content

feat(pypi): add username-based package discovery - #10

Merged
paladini merged 1 commit into
mainfrom
feat/pypi-username-lookup
Jun 5, 2026
Merged

feat(pypi): add username-based package discovery#10
paladini merged 1 commit into
mainfrom
feat/pypi-username-lookup

Conversation

@paladini

@paladini paladini commented Jun 5, 2026

Copy link
Copy Markdown
Owner

Problem

The PyPI generator previously only accepted explicit comma-separated package names:

```yaml
pypi: requests,flask,django
```

Unlike npm, RubyGems and Docker Hub — which all accept a username and auto-discover your packages — PyPI required users to know and list every package name upfront. This was inconsistent and inconvenient.

Solution

When a single value (no commas) is passed to `pypi:`, the generator now first attempts a username lookup via the PyPI XMLRPC `user_packages` API. If the user owns packages, those are fetched automatically. If no user is found, it falls back to treating the value as a single package name (backwards-compatible).

```yaml

New: by username — auto-discovers all your packages

pypi: your-username

Existing: explicit package names (unchanged)

pypi: package1,package2
```

Changes

  • `src/generators/npm.ts`

    • Add `fetchPyPIUserPackages(username)` using the PyPI XMLRPC `user_packages` method
    • Update `pypiGenerator.generate()` to try username lookup when a single value is given, falling back to package-name mode
    • Populate `identity.contact.social` with the user's PyPI profile URL when resolved by username (mirrors npm/dockerhub behaviour)
    • Update `flagArg` and `description` to reflect both modes
  • `templates/.mcp-me.yaml`

    • Document both usage modes with inline comments

Verified working (smoke tests)

DockerHub — already implemented, confirmed end-to-end:
```
[DockerHub] Fetching repos for paladini...
[DockerHub] Found 3 repositories.
Projects found: 3
```

PyPI by username — new feature, confirmed end-to-end:
```
[PyPI] Looking up packages for user "paladini"...
[PyPI] Found 2 package(s) owned by "paladini".
[PyPI] ✔ faker-job-brazil v0.0.1.dev0
[PyPI] ✔ pySpark-connector-kairosdb v0.1.0
Projects found: 2
```

PyPI by package names — existing behaviour, unchanged:
```yaml
pypi: requests,flask # still works as before
```

Test plan

  • `pypi: paladini` → discovers 2 packages via username lookup, fetches metadata
  • `dockerhub: paladini` → discovers 3 container images, fetches metadata
  • `pypi: requests,flask` → fetches those packages explicitly (existing behaviour)
  • `pypi: nonexistent-user-xyz` → falls back to treating value as a package name, logs "not found"
  • TypeScript build passes (`npm run build`)

🤖 Generated with Claude Code

Previously the PyPI generator only accepted explicit comma-separated
package names (e.g. `pypi: requests,flask`), unlike npm, RubyGems and
Docker Hub which all look up packages by username.

Changes:
- Add `fetchPyPIUserPackages(username)` that calls the PyPI XMLRPC
  `user_packages` method to auto-discover all packages owned or
  maintained by a given username
- When a single value with no commas is provided, first attempt a
  username lookup; if that returns packages, use them — otherwise fall
  back to treating the value as a single package name (backwards-
  compatible)
- When multiple comma-separated values are provided, keep existing
  behaviour (explicit package names)
- Include the user's PyPI profile URL in `identity.contact.social`
  when resolved by username (mirrors behaviour of npm/dockerhub)
- Update `templates/.mcp-me.yaml` to document both usage modes

Now both forms work:
  pypi: your-username          # auto-discovers all your packages
  pypi: package1,package2     # explicit package names (unchanged)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@paladini
paladini merged commit 6a4bf06 into main Jun 5, 2026
2 checks passed
gusbepapi pushed a commit to gusbepapi/mcp-me that referenced this pull request Jul 11, 2026
Previously the PyPI generator only accepted explicit comma-separated
package names (e.g. `pypi: requests,flask`), unlike npm, RubyGems and
Docker Hub which all look up packages by username.

Changes:
- Add `fetchPyPIUserPackages(username)` that calls the PyPI XMLRPC
  `user_packages` method to auto-discover all packages owned or
  maintained by a given username
- When a single value with no commas is provided, first attempt a
  username lookup; if that returns packages, use them — otherwise fall
  back to treating the value as a single package name (backwards-
  compatible)
- When multiple comma-separated values are provided, keep existing
  behaviour (explicit package names)
- Include the user's PyPI profile URL in `identity.contact.social`
  when resolved by username (mirrors behaviour of npm/dockerhub)
- Update `templates/.mcp-me.yaml` to document both usage modes

Now both forms work:
  pypi: your-username          # auto-discovers all your packages
  pypi: package1,package2     # explicit package names (unchanged)

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant