@tostudy-ai/mcp-setup 1.0.0

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 (75) hide show
  1. package/README.md +149 -0
  2. package/bin/cli.js +6 -0
  3. package/dist/__tests__/e2e-diagnostic-repair-flow.test.d.ts +52 -0
  4. package/dist/__tests__/e2e-diagnostic-repair-flow.test.d.ts.map +1 -0
  5. package/dist/__tests__/e2e-diagnostic-repair-flow.test.js +720 -0
  6. package/dist/__tests__/e2e-diagnostic-repair-flow.test.js.map +1 -0
  7. package/dist/__tests__/e2e-wizard-flow.test.d.ts +43 -0
  8. package/dist/__tests__/e2e-wizard-flow.test.d.ts.map +1 -0
  9. package/dist/__tests__/e2e-wizard-flow.test.js +407 -0
  10. package/dist/__tests__/e2e-wizard-flow.test.js.map +1 -0
  11. package/dist/__tests__/ide-handlers.test.d.ts +10 -0
  12. package/dist/__tests__/ide-handlers.test.d.ts.map +1 -0
  13. package/dist/__tests__/ide-handlers.test.js +336 -0
  14. package/dist/__tests__/ide-handlers.test.js.map +1 -0
  15. package/dist/__tests__/install-command.test.d.ts +10 -0
  16. package/dist/__tests__/install-command.test.d.ts.map +1 -0
  17. package/dist/__tests__/install-command.test.js +237 -0
  18. package/dist/__tests__/install-command.test.js.map +1 -0
  19. package/dist/config.d.ts +51 -0
  20. package/dist/config.d.ts.map +1 -0
  21. package/dist/config.js +117 -0
  22. package/dist/config.js.map +1 -0
  23. package/dist/detect.d.ts +42 -0
  24. package/dist/detect.d.ts.map +1 -0
  25. package/dist/detect.js +277 -0
  26. package/dist/detect.js.map +1 -0
  27. package/dist/diagnose.d.ts +36 -0
  28. package/dist/diagnose.d.ts.map +1 -0
  29. package/dist/diagnose.js +512 -0
  30. package/dist/diagnose.js.map +1 -0
  31. package/dist/ide-handlers/base.d.ts +36 -0
  32. package/dist/ide-handlers/base.d.ts.map +1 -0
  33. package/dist/ide-handlers/base.js +41 -0
  34. package/dist/ide-handlers/base.js.map +1 -0
  35. package/dist/ide-handlers/claude-code.d.ts +15 -0
  36. package/dist/ide-handlers/claude-code.d.ts.map +1 -0
  37. package/dist/ide-handlers/claude-code.js +50 -0
  38. package/dist/ide-handlers/claude-code.js.map +1 -0
  39. package/dist/ide-handlers/cursor.d.ts +15 -0
  40. package/dist/ide-handlers/cursor.d.ts.map +1 -0
  41. package/dist/ide-handlers/cursor.js +61 -0
  42. package/dist/ide-handlers/cursor.js.map +1 -0
  43. package/dist/ide-handlers/desktop.d.ts +16 -0
  44. package/dist/ide-handlers/desktop.d.ts.map +1 -0
  45. package/dist/ide-handlers/desktop.js +26 -0
  46. package/dist/ide-handlers/desktop.js.map +1 -0
  47. package/dist/ide-handlers/index.d.ts +21 -0
  48. package/dist/ide-handlers/index.d.ts.map +1 -0
  49. package/dist/ide-handlers/index.js +49 -0
  50. package/dist/ide-handlers/index.js.map +1 -0
  51. package/dist/ide-handlers/manual.d.ts +16 -0
  52. package/dist/ide-handlers/manual.d.ts.map +1 -0
  53. package/dist/ide-handlers/manual.js +34 -0
  54. package/dist/ide-handlers/manual.js.map +1 -0
  55. package/dist/ide-handlers/opencode.d.ts +15 -0
  56. package/dist/ide-handlers/opencode.d.ts.map +1 -0
  57. package/dist/ide-handlers/opencode.js +57 -0
  58. package/dist/ide-handlers/opencode.js.map +1 -0
  59. package/dist/ide-handlers/vscode.d.ts +16 -0
  60. package/dist/ide-handlers/vscode.d.ts.map +1 -0
  61. package/dist/ide-handlers/vscode.js +62 -0
  62. package/dist/ide-handlers/vscode.js.map +1 -0
  63. package/dist/index.d.ts +14 -0
  64. package/dist/index.d.ts.map +1 -0
  65. package/dist/index.js +501 -0
  66. package/dist/index.js.map +1 -0
  67. package/dist/prompts.d.ts +23 -0
  68. package/dist/prompts.d.ts.map +1 -0
  69. package/dist/prompts.js +68 -0
  70. package/dist/prompts.js.map +1 -0
  71. package/dist/repair.d.ts +50 -0
  72. package/dist/repair.d.ts.map +1 -0
  73. package/dist/repair.js +588 -0
  74. package/dist/repair.js.map +1 -0
  75. package/package.json +54 -0
package/README.md ADDED
@@ -0,0 +1,149 @@
1
+ # @tostudy-ai/mcp-setup
2
+
3
+ CLI to configure Claude Code to connect to the Catalyst MCP server.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npx @tostudy-ai/mcp-setup
9
+ ```
10
+
11
+ ## Commands
12
+
13
+ ### Default Setup
14
+
15
+ ```bash
16
+ npx @tostudy-ai/mcp-setup # Interactive setup
17
+ npx @tostudy-ai/mcp-setup --api-key <key> # Setup with API key
18
+ npx @tostudy-ai/mcp-setup --url <url> # Custom platform URL
19
+ npx @tostudy-ai/mcp-setup --uninstall # Remove configuration
20
+ ```
21
+
22
+ ### Wizard (Step-by-Step)
23
+
24
+ ```bash
25
+ npx @tostudy-ai/mcp-setup wizard # Interactive wizard
26
+ npx @tostudy-ai/mcp-setup wizard --api-key <key> # Wizard with API key
27
+ npx @tostudy-ai/mcp-setup wizard --url <url> # Custom platform URL
28
+ npx @tostudy-ai/mcp-setup wizard --skip-diagnostics # Skip verification step
29
+ npx @tostudy-ai/mcp-setup wizard --auto-repair # Auto-fix detected issues
30
+ ```
31
+
32
+ The wizard guides through 4 steps:
33
+ 1. Environment detection (Claude Code, IDEs)
34
+ 2. API key configuration and validation
35
+ 3. Save configuration
36
+ 4. Diagnostics and verification
37
+
38
+ ### Diagnose
39
+
40
+ ```bash
41
+ npx @tostudy-ai/mcp-setup diagnose # Run diagnostics
42
+ npx @tostudy-ai/mcp-setup diagnose --json # JSON output
43
+ ```
44
+
45
+ Exits with code 1 if issues are found.
46
+
47
+ ### Repair
48
+
49
+ ```bash
50
+ npx @tostudy-ai/mcp-setup repair # Auto-repair issues
51
+ npx @tostudy-ai/mcp-setup repair --api-key <key> # Repair with API key
52
+ npx @tostudy-ai/mcp-setup repair --url <url> # Custom platform URL
53
+ npx @tostudy-ai/mcp-setup repair --json # JSON output
54
+ ```
55
+
56
+ ### Install (Non-Interactive)
57
+
58
+ Used by the web setup wizard to configure a specific IDE in a single command:
59
+
60
+ ```bash
61
+ npx @tostudy-ai/mcp-setup install --ide <ide> --key <key>
62
+ npx @tostudy-ai/mcp-setup install --ide cursor --key <key>
63
+ npx @tostudy-ai/mcp-setup install --ide vscode --key <key> --url http://localhost:3700
64
+ ```
65
+
66
+ Supported IDEs: `claude-code`, `cursor`, `vscode`, `desktop`, `opencode`, `manual`
67
+
68
+ | IDE | Config Location | Config Key |
69
+ |-----|----------------|------------|
70
+ | `claude-code` | Terminal (`claude mcp add`) | N/A |
71
+ | `cursor` | `~/.cursor/mcp.json` | `mcpServers` |
72
+ | `vscode` | `.vscode/mcp.json` | `servers` |
73
+ | `desktop` | Claude Desktop config | `mcpServers` |
74
+ | `opencode` | `~/.opencode/opencode.json` | `mcp` |
75
+ | `manual` | stdout (prints config) | N/A |
76
+
77
+ Each handler reads-then-merges config to preserve other MCP servers.
78
+
79
+ ### Setup via Environment Variable
80
+
81
+ ```bash
82
+ export TOSTUDY_API_KEY="your-api-key"
83
+ export TOSTUDY_PLATFORM_URL="https://tostudy.com" # optional
84
+ npx @tostudy-ai/mcp-setup
85
+ ```
86
+
87
+ ## Environment Variables
88
+
89
+ | Variable | Description | Default |
90
+ |----------|-------------|---------|
91
+ | `TOSTUDY_API_KEY` | Platform API key | - |
92
+ | `TOSTUDY_PLATFORM_URL` | Platform URL | `https://tostudy.com` |
93
+
94
+ ## Getting Your API Key
95
+
96
+ 1. Go to [tostudy.com/student/settings/mcp](https://tostudy.com/student/settings/mcp)
97
+ 2. The setup wizard auto-detects your OS
98
+ 3. Choose your IDE (step 2)
99
+ 4. An API key is generated automatically (step 3)
100
+ 5. Copy the `npx` command and run it in your terminal
101
+
102
+ ## What the CLI Does
103
+
104
+ The CLI modifies the Claude Code configuration file:
105
+
106
+ - **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
107
+ - **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
108
+ - **Linux**: `~/.config/Claude/claude_desktop_config.json`
109
+
110
+ Adds the following configuration:
111
+
112
+ ```json
113
+ {
114
+ "mcpServers": {
115
+ "tostudy": {
116
+ "command": "npx",
117
+ "args": ["-y", "@tostudy-ai/mcp-server"],
118
+ "env": {
119
+ "TOSTUDY_API_KEY": "your-api-key",
120
+ "TOSTUDY_PLATFORM_URL": "https://tostudy.com"
121
+ }
122
+ }
123
+ }
124
+ }
125
+ ```
126
+
127
+ ## After Setup
128
+
129
+ 1. Restart Claude Code
130
+ 2. The MCP server will start automatically
131
+ 3. Use `/courses` to see your enrolled courses
132
+
133
+ ## Scripts
134
+
135
+ | Command | Description |
136
+ |---------|-------------|
137
+ | `pnpm build` | Build CLI |
138
+ | `pnpm type-check` | TypeScript validation |
139
+ | `pnpm test` | Run wizard e2e test |
140
+ | `pnpm test:e2e` | Run shell e2e test |
141
+ | `pnpm test:diagnostic-repair` | Run diagnostic/repair e2e test |
142
+ | `pnpm test:ide-handlers` | Run IDE handler unit tests |
143
+ | `pnpm test:install` | Run install command unit tests |
144
+ | `pnpm test:all` | Run all tests |
145
+
146
+ ## Support
147
+
148
+ - Documentation: [tostudy.com/docs/mcp](https://tostudy.com/docs/mcp)
149
+ - Support: support@tostudy.com
package/bin/cli.js ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+
3
+ import('../dist/index.js').catch((err) => {
4
+ process.stderr.write(`Failed to load CLI: ${err.message}\n`);
5
+ process.exit(1);
6
+ });
@@ -0,0 +1,52 @@
1
+ /**
2
+ * E2E Test: Diagnostic and Repair Flow
3
+ *
4
+ * This test verifies the end-to-end diagnostic and repair flow:
5
+ * 1. Simulate common issues (port conflict, missing config, invalid JSON, etc.)
6
+ * 2. Run mcp-setup diagnose command
7
+ * 3. Verify issue detected with clear description
8
+ * 4. Run mcp-setup repair command
9
+ * 5. Verify issue fixed and MCP configuration is valid
10
+ *
11
+ * NOTE: Port conflict tests require elevated permissions on some systems.
12
+ * Run with: npx tsx src/__tests__/e2e-diagnostic-repair-flow.test.ts
13
+ */
14
+ /**
15
+ * Step 1: Test detection of missing config file
16
+ */
17
+ declare function testMissingConfigDetection(): Promise<void>;
18
+ /**
19
+ * Step 2: Test detection of invalid JSON config
20
+ */
21
+ declare function testInvalidJsonDetection(): Promise<void>;
22
+ /**
23
+ * Step 3: Test detection of missing MCP configuration
24
+ */
25
+ declare function testMissingMcpConfigDetection(): Promise<void>;
26
+ /**
27
+ * Step 4: Test detection of API key issues
28
+ */
29
+ declare function testApiKeyIssuesDetection(): Promise<void>;
30
+ /**
31
+ * Step 5: Test detection of server URL issues
32
+ */
33
+ declare function testServerUrlIssuesDetection(): Promise<void>;
34
+ /**
35
+ * Step 6: Test detection of duplicate servers
36
+ */
37
+ declare function testDuplicateServersDetection(): Promise<void>;
38
+ /**
39
+ * Step 7: Test port conflict detection
40
+ */
41
+ declare function testPortConflictDetection(): Promise<void>;
42
+ /**
43
+ * Step 8: Complete diagnostic and repair flow
44
+ */
45
+ declare function testCompleteFlow(): Promise<void>;
46
+ /**
47
+ * Step 9: Test issue helper functions
48
+ */
49
+ declare function testHelperFunctions(): Promise<void>;
50
+ declare function main(): Promise<void>;
51
+ export { testMissingConfigDetection, testInvalidJsonDetection, testMissingMcpConfigDetection, testApiKeyIssuesDetection, testServerUrlIssuesDetection, testDuplicateServersDetection, testPortConflictDetection, testCompleteFlow, testHelperFunctions, main as runDiagnosticRepairE2ETests, };
52
+ //# sourceMappingURL=e2e-diagnostic-repair-flow.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"e2e-diagnostic-repair-flow.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/e2e-diagnostic-repair-flow.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AA2RH;;GAEG;AACH,iBAAe,0BAA0B,IAAI,OAAO,CAAC,IAAI,CAAC,CAuCzD;AAED;;GAEG;AACH,iBAAe,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC,CA4CvD;AAED;;GAEG;AACH,iBAAe,6BAA6B,IAAI,OAAO,CAAC,IAAI,CAAC,CA0C5D;AAED;;GAEG;AACH,iBAAe,yBAAyB,IAAI,OAAO,CAAC,IAAI,CAAC,CAkDxD;AAED;;GAEG;AACH,iBAAe,4BAA4B,IAAI,OAAO,CAAC,IAAI,CAAC,CAwD3D;AAED;;GAEG;AACH,iBAAe,6BAA6B,IAAI,OAAO,CAAC,IAAI,CAAC,CAoC5D;AAED;;GAEG;AACH,iBAAe,yBAAyB,IAAI,OAAO,CAAC,IAAI,CAAC,CAmCxD;AAED;;GAEG;AACH,iBAAe,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAoF/C;AAED;;GAEG;AACH,iBAAe,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CA4ElD;AAsCD,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAwCnC;AAQD,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,EACxB,6BAA6B,EAC7B,yBAAyB,EACzB,4BAA4B,EAC5B,6BAA6B,EAC7B,yBAAyB,EACzB,gBAAgB,EAChB,mBAAmB,EACnB,IAAI,IAAI,2BAA2B,GACpC,CAAC"}