Commit d0636ea
Add multi-account support with automatic account routing
Implements multi-account support allowing users to configure multiple
GitHub accounts with automatic switching based on repository context.
Key features:
- Account configuration via JSON file with --accounts-config flag
- Automatic account selection based on organization or repository patterns
- Environment variable expansion for tokens (e.g., ${GITHUB_WORK_TOKEN})
- Three matcher types: org (organization), repo_pattern (wildcards), all
- Backward compatible: single GITHUB_PERSONAL_ACCESS_TOKEN still works
- Default account fallback when no match found
Implementation:
- pkg/accounts: Core account routing logic with Config, Router, and matcher system
- Comprehensive test coverage with multiple matching scenarios
- CLI flag: --accounts-config <path-to-json>
- Example configuration in accounts.example.json
Use cases:
- Work + personal GitHub accounts (EMU-friendly)
- Multiple organization access
- Repository-specific authentication
Fixes #1940
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 1820a0f commit d0636ea
File tree
5 files changed
+731
-14
lines changed- cmd/github-mcp-server
- internal/ghmcp
- pkg/accounts
5 files changed
+731
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| 12 | + | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
| |||
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
35 | 49 | | |
36 | | - | |
37 | | - | |
| 50 | + | |
| 51 | + | |
38 | 52 | | |
39 | 53 | | |
40 | 54 | | |
| |||
73 | 87 | | |
74 | 88 | | |
75 | 89 | | |
| 90 | + | |
76 | 91 | | |
77 | 92 | | |
78 | 93 | | |
| |||
111 | 126 | | |
112 | 127 | | |
113 | 128 | | |
| 129 | + | |
114 | 130 | | |
115 | 131 | | |
116 | 132 | | |
| |||
126 | 142 | | |
127 | 143 | | |
128 | 144 | | |
| 145 | + | |
129 | 146 | | |
130 | 147 | | |
131 | 148 | | |
| |||
153 | 170 | | |
154 | 171 | | |
155 | 172 | | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
36 | | - | |
| 37 | + | |
| 38 | + | |
37 | 39 | | |
38 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
39 | 45 | | |
40 | 46 | | |
41 | 47 | | |
| |||
87 | 93 | | |
88 | 94 | | |
89 | 95 | | |
90 | | - | |
91 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
92 | 127 | | |
93 | | - | |
94 | | - | |
| 128 | + | |
| 129 | + | |
95 | 130 | | |
96 | 131 | | |
97 | 132 | | |
| |||
102 | 137 | | |
103 | 138 | | |
104 | 139 | | |
105 | | - | |
| 140 | + | |
106 | 141 | | |
107 | 142 | | |
108 | 143 | | |
| |||
112 | 147 | | |
113 | 148 | | |
114 | 149 | | |
115 | | - | |
| 150 | + | |
116 | 151 | | |
117 | | - | |
| 152 | + | |
118 | 153 | | |
119 | | - | |
120 | | - | |
| 154 | + | |
| 155 | + | |
121 | 156 | | |
122 | 157 | | |
123 | 158 | | |
| |||
159 | 194 | | |
160 | 195 | | |
161 | 196 | | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
162 | 202 | | |
163 | 203 | | |
164 | 204 | | |
165 | 205 | | |
166 | 206 | | |
167 | | - | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
168 | 214 | | |
169 | 215 | | |
170 | 216 | | |
| |||
293 | 339 | | |
294 | 340 | | |
295 | 341 | | |
296 | | - | |
| 342 | + | |
| 343 | + | |
297 | 344 | | |
298 | 345 | | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
299 | 349 | | |
300 | 350 | | |
301 | 351 | | |
| |||
382 | 432 | | |
383 | 433 | | |
384 | 434 | | |
| 435 | + | |
385 | 436 | | |
386 | 437 | | |
387 | 438 | | |
| |||
0 commit comments