Commit graph

788 commits

Author SHA1 Message Date
Frédéric Barthelet
281cf0bf8d
Save existing refresh_token in store if no new refresh_token is returned (#483)
As described in https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#name-refresh-token-response,
server MAY return a new refresh_token. In case it doesn't, current implementation discard initial refresh
token if it was still valid.
2025-05-21 17:29:56 +01:00
Shubham Lohar
1d860bb217
fixing ProxyOAuthServerProvider: redirect_uri missing in token request (#519) 2025-05-21 17:19:49 +01:00
Itsuki
69dbfac0e4
Feat: Separate authorization server and resource server on client auth flow (#416)
* add type and schema for protected resource metadata

* add private variable to keep track of
authorization server url to avoid fetching Protected Resource Metadata every time

* change auth flow to use authroization server and
add function to discover protected resource metadata

* add/modify tests for new added auth functions

* modify test to use the authorization server

* remove unused variable

* add resource parameter when building auth url

* Change resource to use the protected resource metadata

* resolve typo.

Co-authored-by: Paul Carleton <paulcarletonjr@gmail.com>

* Update src/client/sse.ts import.

Co-authored-by: Paul Carleton <paulcarletonjr@gmail.com>

* remove log.

Co-authored-by: Paul Carleton <paulcarletonjr@gmail.com>

* Update section title.

Co-authored-by: Paul Carleton <paulcarletonjr@gmail.com>

* remove log.

Co-authored-by: Paul Carleton <paulcarletonjr@gmail.com>

* remove resource parameter.

Co-authored-by: Paul Carleton <paulcarletonjr@gmail.com>

* remove resource parameter.

Co-authored-by: Paul Carleton <paulcarletonjr@gmail.com>

* remove resource parameter.

Co-authored-by: Paul Carleton <paulcarletonjr@gmail.com>

* remove resource parameter.

Co-authored-by: Paul Carleton <paulcarletonjr@gmail.com>

* remove resource parameter.

Co-authored-by: Paul Carleton <paulcarletonjr@gmail.com>

* remove resource parameter.

Co-authored-by: Paul Carleton <paulcarletonjr@gmail.com>

* remove resource parameter.

Co-authored-by: Paul Carleton <paulcarletonjr@gmail.com>

* remove resource parameter.

Co-authored-by: Paul Carleton <paulcarletonjr@gmail.com>

* remove resource parameter.

Co-authored-by: Paul Carleton <paulcarletonjr@gmail.com>

* make backwards compatibile

* s/resourceServerUrl/serverUrl/g for backwards compat

* fix test comment

---------

Co-authored-by: itsuki <itsuki.enjyoy@gmail.com>
Co-authored-by: Paul Carleton <paulcarletonjr@gmail.com>
Co-authored-by: Paul Carleton <paulc@anthropic.com>
2025-05-21 14:55:38 +01:00
Paul Carleton
ac1b80a331
feat: Add support for separate Authorization Server / Resource server in server flow (spec: DRAFT-2025-v2) (#503)
* add support for .oauth-protected-resource metadata endpoint and www-authenticate

* test and types

* thread throughs scopes

* have example separate AS and RS

* make inmemory explicitly demo

* fix type

* fix types

* fix client example

* fixup comments

* refactor metadata endpoints to cleanup

* almost working w/ forwarding

* separate AS/RS working

* add to readme

* de-async the auth server setup for happier top level flow

* add test for new router

* fix test

* remove redundant comment

* clarify comment

* remove more unused endpoints

* simplify router

* slim down

* simplify verifier, and fix router test

* fix doc string
2025-05-21 13:13:34 +01:00
bhosmer-ant
3975c1ac79
Merge pull request #517 from modelcontextprotocol/basil/ajv_downgrade
Fix Ajv import compatibility issue by downgrading to v6
2025-05-20 12:38:25 -04:00
bhosmer-ant
69f8ee4818
Merge pull request #502 from modelcontextprotocol/basil/progress_message
Add support for message field in progress notifications
2025-05-19 14:47:05 -04:00
Basil Hosmer
4cc8ed43b4
Fix Ajv import compatibility issue by downgrading to v6
Downgrade Ajv from v8.17.1 to v6.12.6 to resolve ESM/CJS module compatibility issues that were causing "does not provide an export named 'Ajv'" errors in projects using this SDK. This ensures consistent import patterns across different module systems.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-05-19 13:05:21 -04:00
Jerome
3f429895fb
Bumping version 1.11.4 2025-05-16 18:48:07 -04:00
Jerome
3d01e9e450
Merge pull request #506 from modelcontextprotocol/basil/rollback
rollback path preservation fix
2025-05-16 18:44:53 -04:00
Basil Hosmer
82f5f70924
rollback path preservation fix 2025-05-16 17:45:44 -04:00
bhosmer-ant
6be4c60c45
Merge pull request #504 from modelcontextprotocol/basil/fix_path_preservation
fix sse endpoint path preservation
2025-05-16 17:28:49 -04:00
Basil Hosmer
00cb9203cd
fix sse endpoint path preservation 2025-05-16 16:48:31 -04:00
Basil Hosmer
d37de9b110
Add support for message field in progress notifications
Implements the new optional message field for progress notifications as
defined in the MCP specification update. This allows servers to provide
descriptive status updates alongside progress values.

Changes:
- Add optional message field to ProgressSchema in types.ts
- Add tests for progress notifications with message field
- Update protocol tests to verify message field handling

Refs: https://github.com/modelcontextprotocol/modelcontextprotocol/pull/197

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-05-16 15:18:28 -04:00
bhosmer-ant
1fd6265751
Merge pull request #454 from modelcontextprotocol/basil/output_schema
Prototype support for `outputSchema`/`structuredContent`
2025-05-15 10:41:37 -04:00
Basil Hosmer
c964c5cf91
tsc being a diva on testOutputSchemaServers.ts 2025-05-15 10:40:34 -04:00
Basil Hosmer
a19f44ee75
kick build 2025-05-15 10:29:47 -04:00
Basil Hosmer
f470f0996b
fix type error in testOutputSchemaServers.ts 2025-05-15 10:16:49 -04:00
Basil Hosmer
39b2f65434
restore server-side validation for tools returning structuredContent without outputSchema
Co-Authored-By: Claude <noreply@anthropic.com>
2025-05-15 10:03:50 -04:00
Basil Hosmer
6b680ca18a
Move testOutputSchemaServers.ts to client examples directory
This file is a client implementation that tests outputSchema servers,
so it belongs in the client examples directory rather than server examples.
Updated file paths in error messages to reflect the new location.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-05-15 10:03:50 -04:00
Basil Hosmer
712b04e96d
Refactor McpServer tool registration API
- Remove tool() overload that takes a config object with callback
- Add new registerTool() method that separates config from callback
- Extract common tool registration logic into _createRegisteredTool() helper
- Update all tests to use registerTool() for tools with output schemas
- Update examples to use registerTool() and high-level Client API
- Add comment noting that output schema validation only works with high-level API

This change improves API clarity by using a distinct method for tools with
output schemas while maintaining backward compatibility.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-05-15 10:03:50 -04:00
Basil Hosmer
eb0407ea40
split comment for readability 2025-05-15 10:03:50 -04:00
Basil Hosmer
18c7e795a0
address comments: 1. validate schemas w/o codegen, 2. relax no-structured-output restriction 2025-05-15 10:03:50 -04:00
Basil Hosmer
0fa3277550
avoid ({}) => ... in tests 2025-05-15 10:03:50 -04:00
Basil Hosmer
e1abdab7f5
update examples, update package-lock.json 2025-05-15 10:03:48 -04:00
Basil Hosmer
6079cd8307
- add new tool() api and tests
- fix schema validation
- comment headers on tests
2025-05-15 10:03:02 -04:00
Basil Hosmer
9686fc2ead
formatting, more version rollbacks 2025-05-15 10:02:03 -04:00
Basil Hosmer
37dcf753af
remove OUTPUTSCHEMA_CHANGES.md 2025-05-15 10:02:02 -04:00
Basil Hosmer
27d66ef031
back out protocol version change 2025-05-15 10:02:02 -04:00
Basil Hosmer
bb28098d81
feat: add server-side support for tool outputSchema with backward compatibility
- Update McpServer to support registering tools with outputSchema
- Add automatic content generation from structuredContent for backward compatibility
- Add validation to ensure proper usage of structuredContent vs content
- Add comprehensive tests for outputSchema functionality
- Add example servers demonstrating structured output usage
- Update existing test to match new backward compatibility behavior

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-05-15 10:02:02 -04:00
Basil Hosmer
882e0b7d05
feat: update TypeScript SDK to implement draft spec changes for structured tool output
- Add outputSchema support to Tool interface with proper documentation
- Split CallToolResult into structured and unstructured variants
- Change structuredContent from string to object type
- Add validation that tools without outputSchema cannot return structuredContent
- Add validation that tools with outputSchema must return structuredContent
- Update client to validate structured content as object (no JSON parsing)
- Update tests to use object format for structuredContent
- Add tests for new validation constraints
- Update LATEST_PROTOCOL_VERSION to DRAFT-2025-v2

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-05-15 10:02:02 -04:00
Basil Hosmer
cf12fe0d83
Add client-side validation for tool output schemas
- Cache tool output schemas when listing tools
- Validate structuredContent against outputSchema during callTool
- Enforce that tools with outputSchema must return structuredContent
- Add json-schema-to-zod dependency for schema conversion
- Add comprehensive tests for validation scenarios

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-05-15 10:01:58 -04:00
Basil Hosmer
a85fee407a
Add support for outputSchema and optional content fields in tools
- Add outputSchema field to Tool type and RegisteredTool interface
- Make content field optional in CallToolResult
- Update ListToolsRequestSchema handler to include outputSchema in tool list responses
- Add support for structuredContent in tool results
- Update examples to handle optional content field
- Add tests for new outputSchema and structuredContent functionality
- Update ToolCallback documentation to clarify when to use structuredContent vs content

This change enables tools to define structured output schemas and return
structured JSON content, providing better type safety and validation for
tool outputs.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-05-15 09:58:40 -04:00
ihrpr
41c9996019
Merge pull request #449 from petervandenabeele/fix-readme-toc 1.11.3
Fix Table of Contents in README and markdown linter warnings.
2025-05-15 10:23:47 +01:00
ihrpr
2ee962ca7a
Merge pull request #457 from grimmerk/fix-import-path-in-readme
docs: Fix import paths for ProxyOAuthServerProvider in README
2025-05-15 10:12:17 +01:00
ihrpr
1879922e23
Merge pull request #480 from Boyquotes/patch-1
Fix notificaions in README.md
2025-05-15 10:07:10 +01:00
Xiao Yijun
66dec56467
feat(auth): support custom scope in authorization requests (#491)
* feat(auth): support custom scope in authorization requests

* fix(auth): default to provider's scope if not provided
2025-05-14 18:45:18 +01:00
ihrpr
bac916e804
Merge pull request #399 from its-nikhil/FEAT-auth-ctx-streamable-http
[FEAT] added support for AuthInfo in extra for StreamableHTTPServerTransport
2025-05-14 14:30:28 +01:00
ihrpr
17caa5a6ad
Merge pull request #489 from rafaelportomoura/main
chore: fix cross-spawn version to 7.0.5 (issue: #488)
2025-05-14 10:05:37 +01:00
Rafael Moura
f2fc873859 chore: fix cross-spawn version to 7.0.5 (issue: 488) 2025-05-13 15:37:26 -03:00
ihrpr
68a0ca3505
Merge pull request #466 from modelcontextprotocol/fix/sse-custom-endpoint-paths
fix: preserve custom paths in SSE endpoint URLs
2025-05-12 17:24:46 +01:00
olaservo
2f522bf370
Add failing tests 2025-05-12 11:25:41 -04:00
Basil Hosmer
5a25fe3a6c
fix: preserve custom paths in SSE endpoint URLs
When an SSE client connects with a custom path (e.g., /api/v1/custom/sse),
ensure the endpoint URL maintains the same base path structure but with
/messages instead of /sse. This fixes issues where custom endpoints were
getting collapsed to the root path.

Should fix issues reported in modelcontextprotocol/inspector#313 and #296
Tests demonstrating the issue were added in PR #439

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-05-12 11:09:12 -04:00
ihrpr
048bc4f755
Merge pull request #482 from modelcontextprotocol/version-1-11-2 1.11.2
Release 1.11.2 - update version
2025-05-12 10:15:56 +01:00
ihrpr
e5909502c2
bump version 2025-05-12 10:09:49 +01:00
Boyquotes
9fe501b9bf
Fix notificaions in README.md
notificaions -> notifications
2025-05-12 07:34:37 +02:00
bhosmer-ant
bced33d8bc
Merge pull request #468 from geelen/fix-tool-annotation-confusion
Fix Zod object detection logic
2025-05-09 18:01:38 -04:00
Basil Hosmer
4a295a4043
remove vendored library tests 2025-05-09 17:48:33 -04:00
Basil Hosmer
3c9496812e
tweak heuristic type test for isZodRawShape
- simpler test for empty object
- only test public zod properties (parse, safeParse)

Confirmed that vendored-library tests still pass. Note that you need the --testPathIgnorePatterns to avoid the __tests__ directory (this is what was breaking the build):
$ npm test -- --testPathIgnorePatterns="vendor"
2025-05-09 17:43:00 -04:00
Grimmer Kang
1e56091c89
Merge branch 'main' into fix-import-path-in-readme 2025-05-09 20:07:11 +08:00
ihrpr
bf7fd4470e
Merge pull request #464 from pcarleton/pcarleton/oauth-scope
feat: Add scope parameter to startAuthorization function
2025-05-09 11:40:37 +01:00