Commit dbfda40
feat: add mcpOAuthTokenStorage support across all SDKs (#1326)
* feat: add mcpOAuthTokenStorage support across all SDKs
Add the mcpOAuthTokenStorage protocol property to session creation and
resume flows in all five language SDKs (Node.js, Python, Go, .NET, Rust).
When set to "in-memory", the runtime uses an in-memory MCP OAuth token
store instead of the OS keychain. The SDK defaults to "in-memory" for
safe multitenant behavior.
- Node.js: Add to SessionConfig interface and ResumeSessionConfig Pick type
- Python: Add to both TypedDicts and client methods with docstrings
- Go: Add to config structs, wire request structs, and client wiring
- .NET: Add McpOAuthTokenStorageMode enum with JsonStringEnumConverter,
update config classes, copy constructors, wire records, and serialization
context
- Rust: Add field, builder methods, Default/new impls, and Debug impls
Tests:
- Rust: Assert defaults and builder composition in existing type tests
- .NET: Add property to SessionConfig_Clone_CopiesAllProperties test
- Go: Add wire serialization tests for both request types
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix(go): rename McpOAuthTokenStorage to MCPOAuthTokenStorage
Follow Go naming convention for initialisms (consistent with MCPServers).
Also fixes JSON tags that were accidentally changed from camelCase wire
format during the rename.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix(go): add error handling in MCPOAuthTokenStorage omit subtests
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* test(nodejs): add mcpOAuthTokenStorage default and forwarding tests
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* test(python): add mcp_oauth_token_storage default and forwarding tests
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix(python): use current CopilotClient constructor in mcpOAuthTokenStorage tests
Replace SubprocessConfig positional arg (removed in main) with
keyword-only connection=RuntimeConnection.for_stdio(path=CLI_PATH),
matching the pattern used by all other tests in the file.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* feat(java): add mcpOAuthTokenStorage support
Add mcpOAuthTokenStorage field to SessionConfig, ResumeSessionConfig,
CreateSessionRequest, and ResumeSessionRequest. The SessionRequestBuilder
defaults to "in-memory" for safe multitenant behavior, consistent with
all other SDK implementations.
Includes 6 unit tests covering default and explicit value forwarding for
both create and resume paths, plus null config handling.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix MCP OAuth test regressions
Update the Python MCP OAuth request interception tests to forward keyword arguments introduced by the merged create_session path, and add focused .NET clone tests so McpOAuth coverage can be validated directly.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Move mcpOAuthTokenStorage default to empty (multitenant) mode only
Previously, all SDKs unconditionally defaulted mcpOAuthTokenStorage to
"in-memory". With the client mode system from PR #1428, the safe
multitenant default now only applies in "empty" mode. In "copilot-cli"
mode, the property is not sent, letting the runtime default to
"persistent" (backward compatible).
Changes across all 6 SDKs:
- Node.js: configDefaultsForMode() sets default for empty mode only
- Python: _mcp_oauth_token_storage_default() helper checks mode
- Go: applyConfigDefaultsForMode/applyResumeDefaultsForMode set default
- .NET: ApplyConfigDefaultsForMode() uses ??= for empty mode
- Rust: Default impls return None; session.rs applies for empty mode
- Java: CopilotClient applies default in empty mode blocks
Tests updated to verify mode-specific behavior in all SDKs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix stale doc comments for mcp_oauth_token_storage in Rust
The doc comments incorrectly stated the default came from
SessionConfig::default(). Updated to reflect that the in-memory default
is applied at the client level when ClientMode::Empty is active.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix formatting in Node.js and Python test files
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix Python type annotation for _mcp_oauth_token_storage_default
Use Literal type instead of str to match the parameter type in client.py,
fixing the red-knot invalid-assignment diagnostic.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Add base_directory to Python empty mode tests
Empty mode requires base_directory to avoid falling back to ~/.copilot.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 6ffb9e1 commit dbfda40
24 files changed
Lines changed: 654 additions & 3 deletions
File tree
- dotnet
- src
- test/Unit
- go
- java/src
- main/java/com/github/copilot
- rpc
- test/java/com/github/copilot
- nodejs
- src
- test
- python
- copilot
- rust/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
637 | 637 | | |
638 | 638 | | |
639 | 639 | | |
| 640 | + | |
640 | 641 | | |
641 | 642 | | |
642 | 643 | | |
| |||
868 | 869 | | |
869 | 870 | | |
870 | 871 | | |
| 872 | + | |
871 | 873 | | |
872 | 874 | | |
873 | 875 | | |
| |||
1055 | 1057 | | |
1056 | 1058 | | |
1057 | 1059 | | |
| 1060 | + | |
1058 | 1061 | | |
1059 | 1062 | | |
1060 | 1063 | | |
| |||
2169 | 2172 | | |
2170 | 2173 | | |
2171 | 2174 | | |
| 2175 | + | |
2172 | 2176 | | |
2173 | 2177 | | |
2174 | 2178 | | |
| |||
2247 | 2251 | | |
2248 | 2252 | | |
2249 | 2253 | | |
| 2254 | + | |
2250 | 2255 | | |
2251 | 2256 | | |
2252 | 2257 | | |
| |||
2343 | 2348 | | |
2344 | 2349 | | |
2345 | 2350 | | |
| 2351 | + | |
2346 | 2352 | | |
2347 | 2353 | | |
2348 | 2354 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2081 | 2081 | | |
2082 | 2082 | | |
2083 | 2083 | | |
| 2084 | + | |
| 2085 | + | |
| 2086 | + | |
| 2087 | + | |
| 2088 | + | |
| 2089 | + | |
| 2090 | + | |
| 2091 | + | |
| 2092 | + | |
| 2093 | + | |
| 2094 | + | |
| 2095 | + | |
| 2096 | + | |
| 2097 | + | |
| 2098 | + | |
2084 | 2099 | | |
2085 | 2100 | | |
2086 | 2101 | | |
| |||
2397 | 2412 | | |
2398 | 2413 | | |
2399 | 2414 | | |
| 2415 | + | |
2400 | 2416 | | |
2401 | 2417 | | |
2402 | 2418 | | |
| |||
2616 | 2632 | | |
2617 | 2633 | | |
2618 | 2634 | | |
| 2635 | + | |
| 2636 | + | |
| 2637 | + | |
| 2638 | + | |
| 2639 | + | |
| 2640 | + | |
2619 | 2641 | | |
2620 | 2642 | | |
2621 | 2643 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
| |||
113 | 114 | | |
114 | 115 | | |
115 | 116 | | |
| 117 | + | |
116 | 118 | | |
117 | 119 | | |
118 | 120 | | |
| |||
420 | 422 | | |
421 | 423 | | |
422 | 424 | | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
423 | 451 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
629 | 629 | | |
630 | 630 | | |
631 | 631 | | |
| 632 | + | |
632 | 633 | | |
633 | 634 | | |
634 | 635 | | |
| |||
958 | 959 | | |
959 | 960 | | |
960 | 961 | | |
| 962 | + | |
961 | 963 | | |
962 | 964 | | |
963 | 965 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
619 | 619 | | |
620 | 620 | | |
621 | 621 | | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
622 | 686 | | |
623 | 687 | | |
624 | 688 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
129 | 132 | | |
130 | 133 | | |
131 | 134 | | |
| |||
136 | 139 | | |
137 | 140 | | |
138 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
139 | 145 | | |
140 | 146 | | |
141 | 147 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
965 | 965 | | |
966 | 966 | | |
967 | 967 | | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
968 | 973 | | |
969 | 974 | | |
970 | 975 | | |
| |||
1287 | 1292 | | |
1288 | 1293 | | |
1289 | 1294 | | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
1290 | 1300 | | |
1291 | 1301 | | |
1292 | 1302 | | |
| |||
1602 | 1612 | | |
1603 | 1613 | | |
1604 | 1614 | | |
| 1615 | + | |
1605 | 1616 | | |
1606 | 1617 | | |
1607 | 1618 | | |
| |||
1673 | 1684 | | |
1674 | 1685 | | |
1675 | 1686 | | |
| 1687 | + | |
1676 | 1688 | | |
1677 | 1689 | | |
1678 | 1690 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
512 | 512 | | |
513 | 513 | | |
514 | 514 | | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
515 | 518 | | |
516 | 519 | | |
517 | 520 | | |
| |||
626 | 629 | | |
627 | 630 | | |
628 | 631 | | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
629 | 635 | | |
630 | 636 | | |
631 | 637 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| 128 | + | |
128 | 129 | | |
129 | 130 | | |
130 | 131 | | |
| |||
227 | 228 | | |
228 | 229 | | |
229 | 230 | | |
| 231 | + | |
230 | 232 | | |
231 | 233 | | |
232 | 234 | | |
| |||
0 commit comments