feat(mcp): add multi-account profile support#263
Merged
Conversation
|
Related Knowledge 2 documents with suggested updates are ready for review. gittensory Getting StartedView Suggested Changes@@ -208,6 +208,7 @@
| Variable | Purpose |
|---|---|
| `GITTENSORY_API_URL` | Override the API endpoint (e.g., point at your local Worker: `http://localhost:8787`) |
+| `GITTENSORY_PROFILE` | Specifies which named profile to use for authentication. Profiles enable multi-account session isolation. If not set, the default profile is used. |
| `GITTENSORY_CONFIG_PATH` or `GITTENSORY_CONFIG_DIR` | Override the default config storage location |
| `GITTENSORY_API_TOKEN`, `GITTENSORY_MCP_TOKEN`, or `GITTENSORY_TOKEN` | Static token, as an alternative to running `gittensory-mcp login` |
| `GITHUB_TOKEN` | Used for non-interactive login bootstrap via `gittensory-mcp login` |✅ Accepted MCP & Agent IntegrationView Suggested Changes@@ -69,7 +69,7 @@
1. `GITTENSORY_API_TOKEN` environment variable
2. `GITTENSORY_TOKEN` environment variable
3. `GITTENSORY_MCP_TOKEN` environment variable
-4. Session token from the config file (stored by `gittensory-mcp login`)
+4. Active profile's session token from the config file (stored by `gittensory-mcp login`)
Session tokens carry a `login`, `expiresAt`, and `scopes` payload [[11]](https://github.com/JSONbored/gittensory/blob/1e7506f4c5226d0b9b5da8fcd219309d84bacfcd/packages/gittensory-mcp/bin/gittensory-mcp.js#L707-L712). Static beta tokens may not have a verifiable session — this is expected behavior for pre-release access.
@@ -108,10 +108,71 @@
### Logging out
```sh
-gittensory-mcp logout
-```
-
-This revokes the remote session and removes the local config file.
+gittensory-mcp logout [--profile <name>]
+```
+
+This revokes the remote session and removes the local profile config. Pass `--all` to clear all profiles at once.
+
+### Multi-Account Profiles
+
+The default profile keeps single-account usage simple. For multiple GitHub/Gittensory identities — personal vs. work, different orgs, or client-specific accounts — use named profiles to keep sessions isolated.
+
+#### Creating and switching profiles
+
+```sh
+# Create a new profile
+gittensory-mcp profile create work
+
+# Log in to the new profile
+gittensory-mcp login --profile work --github-token "$WORK_GITHUB_TOKEN"
+
+# Switch between profiles
+gittensory-mcp profile switch work
+gittensory-mcp whoami
+
+# List all profiles
+gittensory-mcp profile list
+```
+
+Profiles persist in the same config file (`~/.config/gittensory/config.json`) but maintain isolated sessions, tokens, and API URLs.
+
+#### Using profiles with commands
+
+All authentication and diagnostic commands support the `--profile <name>` flag:
+
+```sh
+gittensory-mcp login --profile personal
+gittensory-mcp status --profile personal
+gittensory-mcp doctor --profile work
+gittensory-mcp whoami --profile work
+gittensory-mcp logout --profile personal
+```
+
+You can also set `GITTENSORY_PROFILE` to select the active profile for all commands and MCP API calls:
+
+```sh
+export GITTENSORY_PROFILE=work
+gittensory-mcp whoami
+gittensory-mcp --stdio
+```
+
+#### Logout behavior
+
+By default, `logout` only clears the selected profile:
+
+```sh
+gittensory-mcp logout --profile work
+```
+
+To revoke all profile sessions at once:
+
+```sh
+gittensory-mcp logout --all
+```
+
+#### Profile output redaction
+
+Profile commands redact session tokens and local config paths from their output to prevent accidental exposure in logs or screenshots. Use `--json` for structured output suitable for automation.
## Running as an MCP Server
@@ -507,7 +568,7 @@
}
```
-The token priority order is: `GITTENSORY_API_TOKEN` > `GITTENSORY_TOKEN` > `GITTENSORY_MCP_TOKEN` > config file session [[10]](https://github.com/JSONbored/gittensory/blob/1e7506f4c5226d0b9b5da8fcd219309d84bacfcd/packages/gittensory-mcp/bin/gittensory-mcp.js#L968-L970).
+The token priority order is: `GITTENSORY_API_TOKEN` > `GITTENSORY_TOKEN` > `GITTENSORY_MCP_TOKEN` > active profile's session token [[10]](https://github.com/JSONbored/gittensory/blob/1e7506f4c5226d0b9b5da8fcd219309d84bacfcd/packages/gittensory-mcp/bin/gittensory-mcp.js#L968-L970).
***
@@ -529,11 +590,12 @@
| Command | Purpose |
|---------|---------|
-| `gittensory-mcp login [--github-token <token>]` | Authenticate via GitHub Device Flow (or a static token). Stores a Gittensory session in `~/.config/gittensory/config.json` |
-| `gittensory-mcp logout` | Revoke the remote session and delete the local config |
-| `gittensory-mcp whoami` | Print the authenticated GitHub login |
-| `gittensory-mcp status` | Report package version, npm latest, API health, auth state, and source-upload posture |
-| `gittensory-mcp doctor [--cwd path]` | Run the full diagnostic suite (API health, compatibility, auth, PATH, local scorer) |
+| `gittensory-mcp login [--profile <name>] [--github-token <token>]` | Authenticate via GitHub Device Flow (or a static token). Stores a Gittensory session in `~/.config/gittensory/config.json` |
+| `gittensory-mcp logout [--profile <name>] [--all]` | Revoke the remote session and delete the local config. `--all` clears all profiles |
+| `gittensory-mcp whoami [--profile <name>]` | Print the authenticated GitHub login |
+| `gittensory-mcp status [--profile <name>]` | Report package version, npm latest, API health, auth state, and source-upload posture |
+| `gittensory-mcp doctor [--profile <name>] [--cwd path]` | Run the full diagnostic suite (API health, compatibility, auth, PATH, local scorer) |
+| `gittensory-mcp profile <list\|create\|switch\|remove>` | Manage named profiles for multi-account session isolation. Use `list` to show all profiles, `create <name>` to initialize a new profile, `switch <name>` to set the active profile, or `remove <name>` to delete a profile |
| `gittensory-mcp changelog` | Print the local `CHANGELOG.md` |
| `gittensory-mcp init-client --print codex\|claude\|cursor\|mcp` | Print a ready-to-paste MCP client config snippet |
✅ Accepted |
…pport # Conflicts: # packages/gittensory-mcp/README.md # packages/gittensory-mcp/bin/gittensory-mcp.js # test/unit/mcp-cli.test.ts
JSONbored
requested changes
Jun 2, 2026
Owner
JSONbored
left a comment
There was a problem hiding this comment.
@MkDev11 the profile support is useful, but token precedence is still wrong.
Required change:
- Preserve env-token precedence:
GITTENSORY_API_TOKEN/GITTENSORY_TOKEN/GITTENSORY_MCP_TOKENshould win over configured profile tokens. - Add regression coverage for env-token override while an active profile token exists.
Validation expected:
- npm run build:mcp
- npm run test:mcp-pack
- npm run test:ci
Contributor
Author
addressed it |
JSONbored
approved these changes
Jun 2, 2026
Owner
JSONbored
left a comment
There was a problem hiding this comment.
A few notes:
- The profile workflow is useful for #99, especially for users who need to keep JSONbored/oktofeesh1-style identities separated locally.
- The important precedence issue is fixed:
GITTENSORY_API_TOKEN,GITTENSORY_TOKEN, andGITTENSORY_MCP_TOKENnow stay ahead of profile sessions. - The tests cover profile switching, selected-profile logout, missing-profile behavior, JSON output, and token/path redaction.
No code changes requested.
12 tasks
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
Scope
CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
git diff --checknpm run actionlintnpm run typechecknpm run test:coveragelocally; global coverage stays at or above 97% for lines, statements, functions, and branches (aim for 98%+ branch coverage locally so CI variance does not fail near the threshold)npm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderateIf any required check was skipped, explain why:
npm run test:cipassed locally. Coverage summary: statements 99.01%, branches 97.09%, functions 98.07%, lines 99.61%.Safety
Notes