Commit graph typescript-sdk/src/server
Author SHA1 Message Date
Olivier Chafik
4aaa26d900
remove protocol version mismatch warning 2025-06-13 13:35:38 +01:00
Olivier Chafik
4e9d6a707d
Merge branch 'ochafik/protocol-version' of https://github.com/modelcontextprotocol/typescript-sdk into ochafik/protocol-version 2025-06-12 18:45:10 +01:00
Olivier Chafik
bb0592bd50
add supported versions to error message 2025-06-12 18:42:51 +01:00
Olivier Chafik
18f8b40d00
Merge branch 'main' into ochafik/protocol-version 2025-06-11 18:53:04 +01:00
Olivier Chafik
84971c83ea
Set Mcp-Protocol-Version in client requests after init, and warn when it doesn't match negotiated version (it SHOULD match) 2025-06-11 17:29:09 +01:00
Frédéric Barthelet
7e0521550b Add tests for completions capability registration on template resource with completion or prompt completable argument registration 2025-05-25 19:07:26 -07:00
Frédéric Barthelet
269c8caf8e Remove server-specific capabilities definition from Client constructor in mcp tests 2025-05-25 18:00:28 -07:00
Frédéric Barthelet
5f5180c4d3 Register completions capabilities 2025-05-25 17:20:02 -07:00
Basil Hosmer
aeb7b8d741
server error if tool declares outputSchema but no structuredContent in result 2025-05-21 15:45:52 -04:00
bhosmer-ant
a41b174330
Merge pull request #524 from modelcontextprotocol/ihrpr/output-types
Make content in Tool Result required
2025-05-21 12:54:19 -04:00
Basil Hosmer
7636c63f39
update to track spec changes 2025-05-21 12:42:20 -04:00
Shubham Lohar
1d860bb217
fixing ProxyOAuthServerProvider: redirect_uri missing in token request (#519) 2025-05-21 17:19:49 +01:00
ihrpr
265ad071f7
make content required 2025-05-21 12:19:31 -04: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
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
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
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
0fa3277550
avoid ({}) => ... in tests 2025-05-15 10:03:50 -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
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
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
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
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
Glen Maddern
b6617dc44c Fix Zod object detection logic
Previously, this check was `value instanceof ZodType`, which breaks if
the user is using a different version of Zod than the library. Instead,
do the check using the structure of the input object rather than its
prototype chain.

Additionally, this adds a vendored version of Zod to use for tests, which
ensures that regressions like this would be caught next time.
2025-05-09 15:26:33 +10:00
yuna0x0
52dc7f1160
Fix isZodRawShape return false on empty object and add test 2025-05-06 01:49:33 +08:00
ihrpr
7e18c70169
Merge pull request #403 from botengyao/fix-comments-stateless
comment: fix stateless comments that no session-id is included in any responses
2025-04-28 18:39:31 +01:00
ihrpr
dbd439ec57
Merge pull request #406 from botengyao/format-issue
nit: fix the comment format in the streamableHTTP.ts
2025-04-28 18:31:14 +01:00
Michael Hart
67ad0bd773
Ensure JSONRPCError messages are sent for streamable http
Prior to this, any JSONRPCError message sent when `enableJsonResponse` is true would be ignored (and response.end() never called)
2025-04-25 22:18:18 +10:00
Boteng Yao
868fc7b432 fix format 2025-04-25 03:43:05 +00:00
Boteng Yao
414cb11898 fix stateless comments 2025-04-25 01:42:36 +00:00
Nikhil Taneja
4b5c16fae0 [FEAT] added unit test for StreamableHTTPServerTransport with AuthInfo 2025-04-24 23:26:21 +05:30
Nikhil Taneja
37ca02d36d [FEAT] added support for AuthInfo in extra for StreamableHTTPServerTransport 2025-04-24 19:22:55 +05:30
ihrpr
3f95b76dcf
Merge pull request #338 from TomasRup/fix-example-in-stateless
stateless had a wrong example
2025-04-23 22:30:36 +01:00
Basil Hosmer
e53608ea19
rebase and address comments 2025-04-22 16:37:16 -04:00
Basil Hosmer
0096be432f
Add ToolAnnotations support to McpServer.tool() method 2025-04-22 15:24:32 -04:00
ihrpr
f41769184d
Merge pull request #358 from lforst/lforst-pass-request-id-to-extra
Pass `requestId` to handlers via metadata
2025-04-22 18:17:26 +01:00
Tomas Petras Rupšys
d61e59defe
Update src/server/streamableHttp.ts
Co-authored-by: ihrpr <inna.hrpr@gmail.com>
2025-04-22 14:20:08 +03:00
Justin Spahr-Summers
21f492f531
Revert "Merge pull request #334 from m-paternostro/mp/notifier"
This reverts commit 3ef902328a, reversing
changes made to 5b6d35eb12.
2025-04-22 11:35:49 +01:00
ihrpr
6050aa9f05
lint 2025-04-21 15:31:38 +01:00
ihrpr
37fc7d2ca8
fix check to skip session validation for stateless mode 2025-04-21 14:56:12 +01:00
ihrpr
a51fea33b1
Merge remote-tracking branch 'qikaigao/patch-1' into ihrpr/example-clients 2025-04-21 14:47:36 +01:00
Cliff Hall
88f962d463
Merge branch 'main' into patch-1 2025-04-18 15:13:12 -04:00
Marcelo Paternostro
112eed999c
example and more documentation 2025-04-18 10:08:36 -04:00
Marcelo Paternostro
b2fea383dd
capability event 2025-04-18 10:05:10 -04:00
Marcelo Paternostro
b5e6d7bc32
add server.getVersion() 2025-04-18 10:05:09 -04:00
ihrpr
0bf8b376df
examples for stateless servers 2025-04-18 11:46:17 +01:00
qikaigao
1df348710b
Update streamableHttp.ts 2025-04-17 15:38:12 -07:00