Commit graph typescript-sdk/src
Author SHA1 Message Date
Glen Maddern
6f5e53b44b
Returning undefined from discoverOAuthMetadata for CORS errors (#717)
* Returning undefined from `discoverOAuthMetadata` for CORS errors

This behaviour was already happening for the root URL, but the new `fetchWithCorsRetry` logic differed.

The issue was if the server returns a 404 for `/.well-known/oauth-authorization-server/xyz` that didn't have the `access-control-allow-origin`, a TypeError was being thrown. There was logic there already to handle a TypeError for a _preflight_ request (cause by custom headers), but not the fallback. I refactored so all combinations return `undefined`.

* Add test for CORS error handling that should return undefined

This test covers the scenario where both the initial request with headers
and the retry without headers fail with CORS TypeErrors. The desired
behavior is to return undefined instead of throwing.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix test comment

---------

Co-authored-by: Glen Maddern <glen@glenmaddern.com>
Co-authored-by: Paul Carleton <paulc@anthropic.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Paul Carleton <paulcarletonjr@gmail.com>
2025-07-01 16:24:27 +01:00
Inna Harper
fb4d07f0ee
Merge pull request #698 from RishiNandha/main
Added Sampling Example to README
2025-06-30 16:31:42 +01:00
ihrpr
a8fa0b342a
build 2025-06-30 16:25:26 +01:00
ihrpr
3d6acd3d9a
add an example and update readme 2025-06-30 16:23:19 +01:00
bhosmer-ant
a40b353fb6
Merge branch 'main' into feat/structured-content-with-type-safety 2025-06-30 10:08:09 -04:00
ihrpr
0db4407d43
Merge branch 'main' into xiaofhua/pid-StdioClientTransport 2025-06-30 14:44:36 +01:00
Inna Harper
7682c4cf4f
Merge pull request #598 from sinedied/fix-empty-schema
fix: missing "properties" property in empty schema
2025-06-30 13:20:42 +01:00
sushichan044
fb303d748f
tidying up 2025-06-28 14:56:02 +09:00
Inna Harper
64a60c4ecd
Merge pull request #571 from garciasdos/main
fix: extra headers when they are a Headers object
2025-06-27 17:29:06 +01:00
Inna Harper
99c75281bd
Merge pull request #661 from kentcdodds/resource-types
add overloads for registerResource method in McpServer class
2025-06-27 17:05:01 +01:00
Felix Weinberger
d54ebee8fe
Merge branch 'main' into hotfix/windows-default-env 2025-06-27 15:50:27 +01:00
ihrpr
53ad0a01d5
fix lint 2025-06-27 14:14:21 +01:00
David Dworken
8bc7374f5e
Fix merge conflict 2025-06-26 16:12:26 -07:00
David Dworken
185fb23f34
Merge branch 'main' into main 2025-06-26 16:10:00 -07:00
Christian Bromann
f76652bb10
Update src/server/sse.test.ts 2025-06-26 10:22:27 -07:00
Christian Bromann
08c767f8e1
Merge branch 'main' into cb/sse-tests 2025-06-26 09:50:41 -07:00
Inna Harper
71d309d0d8
Merge pull request #477 from nichtsam/pr/protocol-overwriting-transport-hooks
Pr/protocol overwriting transport hooks
2025-06-26 14:04:16 +01:00
Konstantin Konstantinov
a94a63a2d0
Merge branch 'main' into request-propagation-in-tools 2025-06-25 16:25:24 +03:00
Konstantin Konstantinov
924c1ce56b
Merge branch 'request-propagation-in-tools' of github.com:KKonstantinov/typescript-sdk into request-propagation-in-tools 2025-06-25 16:25:09 +03:00
Konstantin Konstantinov
606c278668
clean up tests - remove mockRequestInfo 2025-06-25 16:24:30 +03:00
Inna Harper
f733207dae
Merge pull request #640 from cliffhall/report-session-id-per-request
Show session id per request in simpleStreamableHttp example server
2025-06-25 14:18:49 +01:00
Konstantin Konstantinov
384095c30b
Merge branch 'main' into request-propagation-in-tools 2025-06-25 14:16:18 +03:00
Chris Dickinson
05d98bb3a4
feat(shared/auth): support software_statement in OAuthClientMetadata (#696)
Per [Section 3.1.1][ref], `software_statement` is an OPTIONAL member
of the client creation request, which may contain a JWT encoding claims
about client software.

[ref]: https://datatracker.ietf.org/doc/html/rfc7591#section-3.1.1
2025-06-25 11:20:26 +01:00
Konstantin Konstantinov
166da76b00
extra parameter - remain optional for backwards compatibility 2025-06-24 19:39:37 +03:00
Konstantin Konstantinov
33895f4520
Merge branch 'main' into request-propagation-in-tools 2025-06-24 19:32:49 +03:00
ihrpr
33e03f499e
Merge branch 'main' into fix/skip_validate_if_error 2025-06-24 17:12:34 +01:00
ihrpr
c20a47a79f
small fixes 2025-06-24 17:09:29 +01:00
Konstantin Konstantinov
dff036ecb8
Merge branch 'main' into request-propagation-in-tools 2025-06-24 18:28:04 +03:00
Konstantin Konstantinov
96ff8573cf
Merge branch 'main' into request-propagation-in-tools 2025-06-24 17:21:09 +03:00
Paul Carleton
15a2277c89
refactor resource selection to not include resource if PRM is not present 2025-06-24 14:47:54 +01:00
ihrpr
03da7cfc66
fallback 2025-06-24 11:38:55 +01:00
Henry Mao
1ff08e41d7
Add path test 2025-06-23 17:32:08 -04:00
Henry Mao
6220701352
Fix trailing slash 2025-06-23 17:13:13 -04:00
Henry Mao
da6ac79c1e
Fix missing issuer 2025-06-24 04:41:26 +08:00
Henry Mao
4f24b8bc6f
Fix /.well-known/oauth-authorization-server dropping path 2025-06-24 04:36:54 +08:00
Chris Dickinson
d89e854133
fix(client/sse): extract protected resource from eventsource 401
Previously the SSE connection would always default to the
`/.well-known/oauth-protected-resource` URI, ignoring the `resource_metadata`
portion of the `www-authenticate` returned in a 401.

Extract the metadata from the initial 401, so RS servers with
custom protected resource URIs (as in RFC9728, [section 3.1][1]))
continue to work as expected.

[1]: https://datatracker.ietf.org/doc/html/rfc9728#section-3.1
2025-06-20 12:54:29 -07:00
Samuel Jensen
9edb619600 make protocol class not overwrite existing hooks when connecting transports 2025-06-20 19:59:30 +02:00
sushichan044
08808a45e0
test: add type assertion to bypass type check 2025-06-20 17:24:17 +09:00
Inna Harper
66b7cd2642
Merge pull request #664 from modelcontextprotocol/pcarleton/auth-resource-validation2
[auth] adjust default validation for resource parameter in client flow, and server example
2025-06-20 08:54:12 +01:00
sushichan044
fc9ca5ff2e
fix: update ToolCallback type to include output arguments for better type safety 2025-06-20 16:47:53 +09:00
Ashwin Bhat
f4b8a48ded
feat: remove console statements from SDK code
- Remove all console.log, console.warn, and console.error from src/client and src/server
- Add ESLint no-console rule for client and server directories (excluding tests)
- Keep console statements in test files, examples, and CLI tools as intended

Addresses feedback in PR #665

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-19 22:36:33 -07:00
Paul Carleton
eff548c06f
adjust to provided resource 2025-06-19 18:02:00 +01:00
Paul Carleton
87da0e0c3a
adjust default validation for resource parameter in client flow, and server example 2025-06-19 17:52:24 +01:00
Olivier Chafik
2a238905df
simpleStreamableHttp: fix example code (#660) 2025-06-19 11:44:43 +01:00
Kent C. Dodds
b293911df7 add overloads for registerResource method in McpServer class
Otherwise, TypeScript can't properly distinguish the type of callback
2025-06-18 21:56:22 -06:00
ihrpr
2f9530bdf9
fix typo 2025-06-18 20:33:35 +01:00
ihrpr
e7a5e331f1
rename decline to reject 2025-06-18 20:11:18 +01:00
Inna Harper
90569d885f
Merge pull request #638 from modelcontextprotocol/ochafik/auth-resource
RFC 8707 Resource Indicators Implementation
2025-06-18 17:34:37 +01:00
Paul Carleton
86bed6aaac
adjust comment 2025-06-18 16:05:14 +01:00
Paul Carleton
4c51230fc2
fix tests 2025-06-18 16:00:12 +01:00