Commit graph typescript-sdk/src/client/index.ts
Author SHA1 Message Date
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
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
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
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
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
ihrpr
54d6929149
don't need to re-initialize when we reconnect a session 2025-04-15 11:58:43 +01:00
Justin Spahr-Summers
58adcd4d60
Merge pull request #224 from nanbingxyz/main
✨ (client/index.ts): add optional RequestOptions parameter to connect…
2025-04-07 11:31:28 +01:00
Shinya Fujino
87dc5eb4a2 fix: Ensure the correct capability is checked for completion/complete 2025-04-06 11:42:18 +09:00
Ironben
b6749998f5 ✨ (client/index.ts): add optional RequestOptions parameter to connect method to allow additional configuration options 2025-03-26 11:54:48 +08:00
Kalvin Chau
5087087190 style: fix linting error on String vs string 2025-01-22 09:25:28 -08:00
Kalvin Chau
443c0829ed feat: add mcp client instruction support 2025-01-22 09:17:59 -08:00
Justin Spahr-Summers
1506bd1b51
Allow capabilities to be dynamically registered after initialization 2025-01-07 14:34:00 +00:00
Justin Spahr-Summers
1962943b22
Revert "Remove CompatibilityCallToolResult" 2024-12-04 17:09:31 +00:00
Justin Spahr-Summers
e911ece970
Remove CompatibilityCallToolResult
Resolves #82.
2024-12-03 16:03:26 +00:00
Justin Spahr-Summers
7d50d8ca16
Add missing options to request methods 2024-11-16 15:59:03 +00:00
Justin Spahr-Summers
1451d0ea24
Explicitly allow cancelled notifications without any capability 2024-11-14 14:07:28 +00:00
Justin Spahr-Summers
54d146bbdc
Support passing an AbortSignal to request() 2024-11-14 13:42:18 +00:00
Justin Spahr-Summers
70cfb0f0d4
Unify error text 2024-11-12 12:17:35 +00:00
Justin Spahr-Summers
8b307a5d62
Check capabilities when request handlers are set 2024-11-12 12:16:43 +00:00
Justin Spahr-Summers
64c2862883
Check and add tests for notification capabilities too 2024-11-12 12:02:10 +00:00
Justin Spahr-Summers
dc45f5d148
Handle capabilities checks at the request() level, make non-strict by default 2024-11-12 10:57:59 +00:00
Justin Spahr-Summers
7ab5880569
Use explicit capabilities lists for now 2024-11-11 22:38:43 +00:00
Justin Spahr-Summers
90e91cdd62
Tests and assertions for client/server capabilities
Resolves #45.
2024-11-11 22:30:50 +00:00
Justin Spahr-Summers
c82d633d8d
Disconnect from client side if initialization fails
Resolves #24.
2024-11-11 22:08:46 +00:00
Justin Spahr-Summers
1f3dbef66c
Support old tools/call result structure, if explicitly opted in 2024-11-07 13:09:20 +00:00
Justin Spahr-Summers
b618157c93
Continue allowing 2024-10-07 in version negotiation 2024-11-07 13:00:52 +00:00
Justin Spahr-Summers
099c2e2be3
Update client and server convenience methods 2024-11-06 11:46:55 +00:00
Justin Spahr-Summers
12c92341b4
Support onprogress callbacks 2024-11-04 22:38:10 +00:00
Justin Spahr-Summers
3d32ce69df
Convenience methods for Client 2024-11-04 22:38:10 +00:00
Justin Spahr-Summers
7cc7e81387
Support custom client request, notification, and result types 2024-11-04 21:07:41 +00:00
ashwin-ant
05a3e54751
fix protocol version in client 2024-10-14 20:20:52 -07:00
Justin Spahr-Summers
42fbfe2ff4
Update Protocol type inference 2024-10-02 22:01:49 +01:00
Justin Spahr-Summers
3786c88960
Combine types into one file 2024-10-02 14:17:31 +01:00
David Soria Parra
02e421c1f1
Initial import 2024-09-24 21:53:34 +01:00