1+ // do same for listTanStackReactAddOns and listTanStackSolidAddOns
2+ // remove the react and solid variants
3+
14import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
25import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js'
36import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
@@ -9,6 +12,8 @@ import {
912 createDefaultEnvironment ,
1013 finalizeAddOns ,
1114 getFrameworkById ,
15+ getFrameworkByName ,
16+ getFrameworks ,
1217} from '@tanstack/cta-engine'
1318
1419function createServer ( {
@@ -24,101 +29,17 @@ function createServer({
2429 version : '1.0.0' ,
2530 } )
2631
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 ) ;
5134
5235 server . tool (
53- 'createTanStackReactApplication ' ,
54- 'Create a new TanStack React application ' ,
36+ 'listTanStackAddOns ' ,
37+ 'List the available add-ons for creating TanStack applications ' ,
5538 {
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 ( ', ' ) } ` ) ,
6840 } ,
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 ) !
12243 return {
12344 content : [
12445 {
@@ -139,9 +60,10 @@ function createServer({
13960 )
14061
14162 server . tool (
142- 'createTanStackSolidApplication ' ,
143- 'Create a new TanStack Solid application' ,
63+ 'createTanStackApplication ' ,
64+ 'Create a new TanStack application' ,
14465 {
66+ framework : z . string ( ) . describe ( `The framework to use. Available frameworks: ${ frameworkNames . join ( ', ' ) } ` ) ,
14567 projectName : z
14668 . string ( )
14769 . describe (
@@ -155,8 +77,8 @@ function createServer({
15577 'The directory to create the application in. Use the absolute path of the directory you want the application to be created in' ,
15678 ) ,
15779 } ,
158- async ( { projectName, addOns, cwd, targetDir } ) => {
159- const framework = getFrameworkById ( 'solid' ) !
80+ async ( { framework : frameworkName , projectName, addOns, cwd, targetDir } ) => {
81+ const framework = getFrameworkByName ( frameworkName ) !
16082 try {
16183 process . chdir ( cwd )
16284 try {
@@ -182,6 +104,7 @@ function createServer({
182104 git : true ,
183105 } )
184106 } catch ( error ) {
107+ console . error ( error )
185108 return {
186109 content : [
187110 { type : 'text' , text : `Error creating application: ${ error } ` } ,
0 commit comments