Auto-generate session names for connect command#136
Merged
Conversation
…mand The `mcpc connect <server>` command now auto-generates a session name from the server hostname (e.g. mcp.apify.com → @apify) or config entry name when the @session argument is omitted. If an existing session already matches the same server and auth settings, it is reused instead of creating a duplicate. https://claude.ai/code/session_01SRw2NArnxDKmgZLrNL72c6
…ertion - Cast opts.profile and opts.noProfile with explicit types to satisfy exactOptionalPropertyTypes (consistent with existing patterns in file) - Replace labels[0]! with nullish coalescing to satisfy no-non-null-assertion https://claude.ai/code/session_01SRw2NArnxDKmgZLrNL72c6
- Resolve CHANGELOG.md conflict (keep both entries) - Update README help block to match new connect command description https://claude.ai/code/session_01SRw2NArnxDKmgZLrNL72c6
…opts Use the properly-typed HandlerOptions from getOptionsFromCommand() instead of casting raw Commander opts, consistent with how connectSession receives its options via ...globalOpts spread. https://claude.ai/code/session_01SRw2NArnxDKmgZLrNL72c6
Build resolveSessionName options with conditional spreads to avoid passing
undefined values to optional properties, matching the pattern used by
connectSession (e.g. `...(headers && { headers })`).
https://claude.ai/code/session_01SRw2NArnxDKmgZLrNL72c6
- CHANGELOG: keep auto-generate session names entry + main's new entries - README/index.ts: take main's --json (removed -j alias from PR #146) - index.ts: combine session name help text with main's jsonHelp() output https://claude.ai/code/session_01SRw2NArnxDKmgZLrNL72c6
Keep our "Session name" help section (auto-generated names with matching criteria) alongside main's changes (error handling, CI, InitializeResult docs). https://claude.ai/code/session_01SRw2NArnxDKmgZLrNL72c6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
mcpc connectcommand now auto-generates session names when the@sessionargument is omitted, making it easier to connect to servers without requiring explicit session naming. If a session for the same server already exists with matching authentication settings, it is reused instead of creating a duplicate.Key Changes
Added
generateSessionName()function insrc/lib/utils.tsthat creates session names from server targets:mcp.apify.com→@apify)mcp.,api.,www.)localhost:3000→@localhost-3000)~/.vscode/mcp.json:filesystem→@filesystem)Added
resolveSessionName()function insrc/cli/commands/sessions.tsthat:@apify-2)Added
findMatchingSession()helper that compares sessions by:--no-profilesupport)Updated
connectcommand to make@sessionoptional:<server> <@session>to<server> [@session]resolveSessionName()when session name is omittedAdded comprehensive test coverage in
test/unit/lib/utils.test.tsforgenerateSessionName()with 20+ test cases covering URL parsing, hostname extraction, port handling, IP addresses, and config entriesNotable Implementation Details
normalizeServerUrl()ensures consistent comparison of URLs with different schemes/formatshttps://claude.ai/code/session_01SRw2NArnxDKmgZLrNL72c6