Commit graph typescript-sdk/src/examples
Author SHA1 Message Date
ihrpr
4d03b243e3
add title 2025-06-15 20:42:25 +01:00
ihrpr
c69168cf93
Merge pull request #534 from modelcontextprotocol/ihrpr/fix-example-shttp
Fix StreamableHttp example for tool calls - have a separate option for testing notifications resumption
2025-05-22 16:43:03 +01:00
ihrpr
3d76bbe6c6
Merge pull request #526 from modelcontextprotocol/ihrpr/auth-example-client3
Example Auth client
2025-05-22 11:14:51 +01:00
ihrpr
cbe9279206
add new tool for testing resumability - leave the rest normal 2025-05-22 10:38:43 +01:00
ihrpr
9bb5ed6dc9
lint 2025-05-21 21:32:01 +01:00
ihrpr
70f03ee648
remove non mac open browser commands 2025-05-21 21:27:42 +01:00
Basil Hosmer
7636c63f39
update to track spec changes 2025-05-21 12:42:20 -04:00
ihrpr
265ad071f7
make content required 2025-05-21 12:19:31 -04:00
ihrpr
8fd635cf72
exaple 2025-05-21 16:29:41 +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
Basil Hosmer
c964c5cf91
tsc being a diva on testOutputSchemaServers.ts 2025-05-15 10:40:34 -04:00
Basil Hosmer
f470f0996b
fix type error in testOutputSchemaServers.ts 2025-05-15 10:16:49 -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
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
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
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
9db5b8363c
fix sse examples 2025-04-23 22:32:56 +01:00
Basil Hosmer
e53608ea19
rebase and address comments 2025-04-22 16:37:16 -04:00
Basil Hosmer
c5e81adcd8
Fix example to properly position tool annotations 2025-04-22 15:24:38 -04:00
Basil Hosmer
0096be432f
Add ToolAnnotations support to McpServer.tool() method 2025-04-22 15:24:32 -04: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
eeda5d630a
readme update 2025-04-21 15:13:25 +01:00
ihrpr
39f7fdf050
fix stateless example 2025-04-21 14:41:12 +01:00
ihrpr
70608b5876
Add more test clients 2025-04-21 11:54:10 +01:00
Marcelo Paternostro
112eed999c
example and more documentation 2025-04-18 10:08:36 -04:00
ihrpr
ea04be4cf8
fix build 2025-04-18 11:52:51 +01:00
ihrpr
0bf8b376df
examples for stateless servers 2025-04-18 11:46:17 +01:00
ihrpr
64653f54bd
Merge pull request #351 from modelcontextprotocol/ihrpr/clean-up-examples
StreamableHttp - Update examples and README
2025-04-17 18:32:20 +01:00
ihrpr
f10d1ff93f
change sessionIdGenerator to be either undefined or generate a string 2025-04-17 18:22:11 +01:00
ihrpr
29ae6b8e49
appying suggested changes 2025-04-17 17:43:14 +01:00
ihrpr
8806c0ecb4
examples readme improvements 2025-04-16 17:49:22 +01:00
ihrpr
16df308d4f
remove logs how to ititialize with curl - not needed anymore as we have client 2025-04-16 14:51:09 +01:00
ihrpr
c3f08567a2
share implementation of in memory store between examples and integration tests 2025-04-16 14:48:47 +01:00
ihrpr
7341c9a288
fix lint 2025-04-16 14:44:45 +01:00
ihrpr
80b0bab08b
backwards compatible client 2025-04-16 14:20:55 +01:00
ihrpr
8328cfe327
example of sse server 2025-04-16 13:36:37 +01:00
ihrpr
4d2968cec3
backward compatible server example 2025-04-16 13:30:00 +01:00
ihrpr
c053c2e97d
handle session termination 2025-04-16 11:56:28 +01:00
ihrpr
585dc06708
introduce onsessioninitialized to avoid race conditions 2025-04-16 11:09:47 +01:00
ihrpr
31f44e0b68
add isInitializeRequest and isInitializedNotification utility 2025-04-16 10:19:46 +01:00
ihrpr
f1e6acb17d
resumed tool to return value 2025-04-15 16:37:31 +01:00
ihrpr
1359e9fe6a
pull transport send options into own named type 2025-04-15 11:42:16 +01:00
ihrpr
621e65c42b
Merge branch 'resumability' into ihrpr/resume-long-running-requests 2025-04-15 11:14:39 +01:00
ihrpr
67a4595ae7
improve event store interface 2025-04-15 11:03:44 +01:00
ihrpr
43cb015844
resume long running requst from new client 2025-04-13 21:40:15 +01:00
ihrpr
663b68a733
exc to disconnect in example client 2025-04-13 16:16:14 +01:00