1
+ // do same for listTanStackReactAddOns and listTanStackSolidAddOns
2
+ // remove the react and solid variants
3
+
1
4
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
2
5
import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js'
3
6
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
@@ -9,6 +12,8 @@ import {
9
12
createDefaultEnvironment ,
10
13
finalizeAddOns ,
11
14
getFrameworkById ,
15
+ getFrameworkByName ,
16
+ getFrameworks ,
12
17
} from '@tanstack/cta-engine'
13
18
14
19
function createServer ( {
@@ -24,101 +29,17 @@ function createServer({
24
29
version : '1.0.0' ,
25
30
} )
26
31
27
- server . tool (
28
- 'listTanStackReactAddOns' ,
29
- 'List the available add-ons for creating TanStack React applications' ,
30
- { } ,
31
- ( ) => {
32
- const framework = getFrameworkById ( 'react-cra' ) !
33
- return {
34
- content : [
35
- {
36
- type : 'text' ,
37
- text : JSON . stringify (
38
- framework
39
- . getAddOns ( )
40
- . filter ( ( addOn ) => addOn . modes . includes ( 'file-router' ) )
41
- . map ( ( addOn ) => ( {
42
- id : addOn . id ,
43
- description : addOn . description ,
44
- } ) ) ,
45
- ) ,
46
- } ,
47
- ] ,
48
- }
49
- } ,
50
- )
32
+ const frameworks = getFrameworks ( ) ;
33
+ const frameworkNames = frameworks . map ( ( framework ) => framework . name ) ;
51
34
52
35
server . tool (
53
- 'createTanStackReactApplication ' ,
54
- 'Create a new TanStack React application ' ,
36
+ 'listTanStackAddOns ' ,
37
+ 'List the available add-ons for creating TanStack applications ' ,
55
38
{
56
- projectName : z
57
- . string ( )
58
- . describe (
59
- 'The package.json module name of the application (will also be the directory name)' ,
60
- ) ,
61
- cwd : z . string ( ) . describe ( 'The directory to create the application in' ) ,
62
- addOns : z . array ( z . string ( ) ) . describe ( 'The IDs of the add-ons to install' ) ,
63
- targetDir : z
64
- . string ( )
65
- . describe (
66
- 'The directory to create the application in. Use the absolute path of the directory you want the application to be created in' ,
67
- ) ,
39
+ framework : z . string ( ) . describe ( `The framework to use. Available frameworks: ${ frameworkNames . join ( ', ' ) } ` ) ,
68
40
} ,
69
- async ( { projectName, addOns, cwd, targetDir } ) => {
70
- const framework = getFrameworkById ( 'react-cra' ) !
71
- try {
72
- process . chdir ( cwd )
73
- try {
74
- const chosenAddOns = await finalizeAddOns (
75
- framework ,
76
- 'file-router' ,
77
- Array . from (
78
- new Set ( [
79
- ...( addOns as unknown as Array < string > ) ,
80
- ...forcedAddOns ,
81
- ] ) ,
82
- ) ,
83
- )
84
- await createApp ( createDefaultEnvironment ( ) , {
85
- projectName : projectName . replace ( / ^ \/ / , './' ) ,
86
- targetDir,
87
- framework,
88
- typescript : true ,
89
- tailwind : true ,
90
- packageManager : 'pnpm' ,
91
- mode : 'file-router' ,
92
- chosenAddOns,
93
- git : true ,
94
- } )
95
- } catch ( error ) {
96
- console . error ( error )
97
- return {
98
- content : [
99
- { type : 'text' , text : `Error creating application: ${ error } ` } ,
100
- ] ,
101
- }
102
- }
103
- return {
104
- content : [ { type : 'text' , text : 'Application created successfully' } ] ,
105
- }
106
- } catch ( error ) {
107
- return {
108
- content : [
109
- { type : 'text' , text : `Error creating application: ${ error } ` } ,
110
- ] ,
111
- }
112
- }
113
- } ,
114
- )
115
-
116
- server . tool (
117
- 'listTanStackSolidAddOns' ,
118
- 'List the available add-ons for creating TanStack Solid applications' ,
119
- { } ,
120
- ( ) => {
121
- const framework = getFrameworkById ( 'solid' ) !
41
+ ( { framework : frameworkName } ) => {
42
+ const framework = getFrameworkByName ( frameworkName ) !
122
43
return {
123
44
content : [
124
45
{
@@ -139,9 +60,10 @@ function createServer({
139
60
)
140
61
141
62
server . tool (
142
- 'createTanStackSolidApplication ' ,
143
- 'Create a new TanStack Solid application' ,
63
+ 'createTanStackApplication ' ,
64
+ 'Create a new TanStack application' ,
144
65
{
66
+ framework : z . string ( ) . describe ( `The framework to use. Available frameworks: ${ frameworkNames . join ( ', ' ) } ` ) ,
145
67
projectName : z
146
68
. string ( )
147
69
. describe (
@@ -155,8 +77,8 @@ function createServer({
155
77
'The directory to create the application in. Use the absolute path of the directory you want the application to be created in' ,
156
78
) ,
157
79
} ,
158
- async ( { projectName, addOns, cwd, targetDir } ) => {
159
- const framework = getFrameworkById ( 'solid' ) !
80
+ async ( { framework : frameworkName , projectName, addOns, cwd, targetDir } ) => {
81
+ const framework = getFrameworkByName ( frameworkName ) !
160
82
try {
161
83
process . chdir ( cwd )
162
84
try {
@@ -182,6 +104,7 @@ function createServer({
182
104
git : true ,
183
105
} )
184
106
} catch ( error ) {
107
+ console . error ( error )
185
108
return {
186
109
content : [
187
110
{ type : 'text' , text : `Error creating application: ${ error } ` } ,
0 commit comments