@mcp-ts/sdk 1.3.7 → 1.3.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +397 -404
  3. package/dist/adapters/agui-middleware.js.map +1 -1
  4. package/dist/adapters/agui-middleware.mjs.map +1 -1
  5. package/dist/bin/mcp-ts.js +0 -0
  6. package/dist/bin/mcp-ts.js.map +1 -1
  7. package/dist/bin/mcp-ts.mjs +0 -0
  8. package/dist/bin/mcp-ts.mjs.map +1 -1
  9. package/dist/client/index.js.map +1 -1
  10. package/dist/client/index.mjs.map +1 -1
  11. package/dist/client/react.d.mts +10 -28
  12. package/dist/client/react.d.ts +10 -28
  13. package/dist/client/react.js +101 -52
  14. package/dist/client/react.js.map +1 -1
  15. package/dist/client/react.mjs +102 -53
  16. package/dist/client/react.mjs.map +1 -1
  17. package/dist/client/vue.js.map +1 -1
  18. package/dist/client/vue.mjs.map +1 -1
  19. package/dist/index.js +78 -6
  20. package/dist/index.js.map +1 -1
  21. package/dist/index.mjs +73 -6
  22. package/dist/index.mjs.map +1 -1
  23. package/dist/server/index.js +78 -6
  24. package/dist/server/index.js.map +1 -1
  25. package/dist/server/index.mjs +73 -6
  26. package/dist/server/index.mjs.map +1 -1
  27. package/dist/shared/index.js.map +1 -1
  28. package/dist/shared/index.mjs.map +1 -1
  29. package/package.json +185 -185
  30. package/src/adapters/agui-middleware.ts +382 -382
  31. package/src/bin/mcp-ts.ts +102 -102
  32. package/src/client/core/app-host.ts +417 -417
  33. package/src/client/core/sse-client.ts +371 -371
  34. package/src/client/core/types.ts +31 -31
  35. package/src/client/index.ts +27 -27
  36. package/src/client/react/index.ts +20 -16
  37. package/src/client/react/use-app-host.ts +74 -73
  38. package/src/client/react/use-mcp-apps.tsx +224 -214
  39. package/src/client/react/use-mcp.ts +669 -641
  40. package/src/client/vue/index.ts +10 -10
  41. package/src/client/vue/use-mcp.ts +617 -617
  42. package/src/index.ts +11 -11
  43. package/src/server/handlers/nextjs-handler.ts +204 -204
  44. package/src/server/handlers/sse-handler.ts +631 -631
  45. package/src/server/index.ts +57 -57
  46. package/src/server/mcp/multi-session-client.ts +228 -228
  47. package/src/server/mcp/oauth-client.ts +1188 -1188
  48. package/src/server/mcp/storage-oauth-provider.ts +272 -272
  49. package/src/server/storage/crypto.ts +92 -0
  50. package/src/server/storage/file-backend.ts +157 -157
  51. package/src/server/storage/index.ts +176 -176
  52. package/src/server/storage/memory-backend.ts +123 -123
  53. package/src/server/storage/redis-backend.ts +276 -276
  54. package/src/server/storage/redis.ts +160 -160
  55. package/src/server/storage/sqlite-backend.ts +182 -182
  56. package/src/server/storage/supabase-backend.ts +229 -228
  57. package/src/server/storage/types.ts +116 -116
  58. package/src/shared/constants.ts +29 -29
  59. package/src/shared/errors.ts +133 -133
  60. package/src/shared/event-routing.ts +28 -28
  61. package/src/shared/events.ts +180 -180
  62. package/src/shared/index.ts +75 -75
  63. package/src/shared/tool-utils.ts +61 -61
  64. package/src/shared/types.ts +282 -282
  65. package/src/shared/utils.ts +38 -38
  66. package/supabase/migrations/20260330195700_install_mcp_sessions.sql +84 -84
package/src/bin/mcp-ts.ts CHANGED
@@ -1,102 +1,102 @@
1
- #!/usr/bin/env node
2
- import * as fs from 'fs';
3
- import * as path from 'path';
4
-
5
- /**
6
- * MCP-TS CLI Utility
7
- *
8
- * Provides helper commands for users of the @mcp-ts/sdk library.
9
- */
10
- async function run() {
11
- const args = process.argv.slice(2);
12
- const command = args[0];
13
-
14
- if (command === 'supabase-init') {
15
- await initSupabase();
16
- } else {
17
- showHelp();
18
- }
19
- }
20
-
21
- function showHelp() {
22
- console.log(`
23
- šŸš€ MCP-TS CLI Utility
24
- Usage: npx mcp-ts <command>
25
-
26
- Commands:
27
- supabase-init Initialize Supabase migrations in your project
28
- `);
29
- }
30
-
31
- async function initSupabase() {
32
- console.log('šŸš€ Initializing Supabase storage for MCP-TS...');
33
-
34
- // When running from dist/bin/mcp-ts.js (compiled), __dirname is dist/bin.
35
- // The supabase/ migrations are at the root of the package.
36
- // We need to look up two levels to find 'supabase' folder in the package.
37
- const pkgRoot = path.resolve(__dirname, '../..');
38
- const sourceDir = path.join(pkgRoot, 'supabase', 'migrations');
39
-
40
- if (!fs.existsSync(sourceDir)) {
41
- console.error(`āŒ Error: Could not find migration files in package at: ${sourceDir}`);
42
- console.log('Please ensure you are running this from a project where @mcp-ts/sdk is installed.');
43
- process.exit(1);
44
- }
45
-
46
- const targetDir = path.join(process.cwd(), 'supabase', 'migrations');
47
-
48
- try {
49
- if (!fs.existsSync(targetDir)) {
50
- fs.mkdirSync(targetDir, { recursive: true });
51
- console.log(`šŸ“ Created directory: ${targetDir}`);
52
- }
53
-
54
- const files = fs.readdirSync(sourceDir);
55
- let copiedCount = 0;
56
-
57
- for (const file of files) {
58
- if (file.endsWith('.sql')) {
59
- const srcPath = path.join(sourceDir, file);
60
- const destPath = path.join(targetDir, file);
61
-
62
- if (fs.existsSync(destPath)) {
63
- console.log(`ā­ļø Skipping existing migration: ${file}`);
64
- continue;
65
- }
66
-
67
- fs.copyFileSync(srcPath, destPath);
68
- console.log(`āœ… Copied: ${file}`);
69
- copiedCount++;
70
- }
71
- }
72
-
73
- if (copiedCount > 0) {
74
- console.log('\n✨ Database migrations successfully initialized!');
75
- console.log('\nNext steps:');
76
- console.log('1. Link your Supabase project:');
77
- console.log(' npx supabase link --project-ref <your-project-id>');
78
- console.log('\n2. Push the migrations to your remote database:');
79
- console.log(' npx supabase db push');
80
- console.log('\n3. Add your Supabase credentials to .env:');
81
- console.log(' SUPABASE_URL=https://<your-project-id>.supabase.co');
82
- console.log(' SUPABASE_SERVICE_ROLE_KEY=<your-service-role-key>');
83
- console.log('\nāš ļø Important: Use the service_role key (not the anon key) for server-side storage.');
84
- console.log(' The service_role key bypasses RLS policies and is required for mcp-ts to work correctly.');
85
- console.log(' Find it in: Supabase Dashboard -> Project Settings -> API -> service_role');
86
- } else if (files.length > 0) {
87
- console.log('\nšŸ‘ All migration files are already present in your project.');
88
- console.log(' Ensure SUPABASE_SERVICE_ROLE_KEY (not SUPABASE_ANON_KEY) is set in your .env');
89
- } else {
90
- console.log('āš ļø No migration files found to copy.');
91
- }
92
-
93
- } catch (error: any) {
94
- console.error(`āŒ Error initializing Supabase: ${error.message}`);
95
- process.exit(1);
96
- }
97
- }
98
-
99
- run().catch(err => {
100
- console.error(err);
101
- process.exit(1);
102
- });
1
+ #!/usr/bin/env node
2
+ import * as fs from 'fs';
3
+ import * as path from 'path';
4
+
5
+ /**
6
+ * MCP-TS CLI Utility
7
+ *
8
+ * Provides helper commands for users of the @mcp-ts/sdk library.
9
+ */
10
+ async function run() {
11
+ const args = process.argv.slice(2);
12
+ const command = args[0];
13
+
14
+ if (command === 'supabase-init') {
15
+ await initSupabase();
16
+ } else {
17
+ showHelp();
18
+ }
19
+ }
20
+
21
+ function showHelp() {
22
+ console.log(`
23
+ šŸš€ MCP-TS CLI Utility
24
+ Usage: npx mcp-ts <command>
25
+
26
+ Commands:
27
+ supabase-init Initialize Supabase migrations in your project
28
+ `);
29
+ }
30
+
31
+ async function initSupabase() {
32
+ console.log('šŸš€ Initializing Supabase storage for MCP-TS...');
33
+
34
+ // When running from dist/bin/mcp-ts.js (compiled), __dirname is dist/bin.
35
+ // The supabase/ migrations are at the root of the package.
36
+ // We need to look up two levels to find 'supabase' folder in the package.
37
+ const pkgRoot = path.resolve(__dirname, '../..');
38
+ const sourceDir = path.join(pkgRoot, 'supabase', 'migrations');
39
+
40
+ if (!fs.existsSync(sourceDir)) {
41
+ console.error(`āŒ Error: Could not find migration files in package at: ${sourceDir}`);
42
+ console.log('Please ensure you are running this from a project where @mcp-ts/sdk is installed.');
43
+ process.exit(1);
44
+ }
45
+
46
+ const targetDir = path.join(process.cwd(), 'supabase', 'migrations');
47
+
48
+ try {
49
+ if (!fs.existsSync(targetDir)) {
50
+ fs.mkdirSync(targetDir, { recursive: true });
51
+ console.log(`šŸ“ Created directory: ${targetDir}`);
52
+ }
53
+
54
+ const files = fs.readdirSync(sourceDir);
55
+ let copiedCount = 0;
56
+
57
+ for (const file of files) {
58
+ if (file.endsWith('.sql')) {
59
+ const srcPath = path.join(sourceDir, file);
60
+ const destPath = path.join(targetDir, file);
61
+
62
+ if (fs.existsSync(destPath)) {
63
+ console.log(`ā­ļø Skipping existing migration: ${file}`);
64
+ continue;
65
+ }
66
+
67
+ fs.copyFileSync(srcPath, destPath);
68
+ console.log(`āœ… Copied: ${file}`);
69
+ copiedCount++;
70
+ }
71
+ }
72
+
73
+ if (copiedCount > 0) {
74
+ console.log('\n✨ Database migrations successfully initialized!');
75
+ console.log('\nNext steps:');
76
+ console.log('1. Link your Supabase project:');
77
+ console.log(' npx supabase link --project-ref <your-project-id>');
78
+ console.log('\n2. Push the migrations to your remote database:');
79
+ console.log(' npx supabase db push');
80
+ console.log('\n3. Add your Supabase credentials to .env:');
81
+ console.log(' SUPABASE_URL=https://<your-project-id>.supabase.co');
82
+ console.log(' SUPABASE_SERVICE_ROLE_KEY=<your-service-role-key>');
83
+ console.log('\nāš ļø Important: Use the service_role key (not the anon key) for server-side storage.');
84
+ console.log(' The service_role key bypasses RLS policies and is required for mcp-ts to work correctly.');
85
+ console.log(' Find it in: Supabase Dashboard -> Project Settings -> API -> service_role');
86
+ } else if (files.length > 0) {
87
+ console.log('\nšŸ‘ All migration files are already present in your project.');
88
+ console.log(' Ensure SUPABASE_SERVICE_ROLE_KEY (not SUPABASE_ANON_KEY) is set in your .env');
89
+ } else {
90
+ console.log('āš ļø No migration files found to copy.');
91
+ }
92
+
93
+ } catch (error: any) {
94
+ console.error(`āŒ Error initializing Supabase: ${error.message}`);
95
+ process.exit(1);
96
+ }
97
+ }
98
+
99
+ run().catch(err => {
100
+ console.error(err);
101
+ process.exit(1);
102
+ });