@@ -43,6 +43,8 @@ async function createMcpServer(
4343 {
4444 capabilities : {
4545 tools : { } ,
46+ resources : { } ,
47+ prompts : { } ,
4648 } ,
4749 instructions : `
4850<General Purpose>
@@ -336,6 +338,237 @@ You MUST prefer the tools provided by this server over using shell commands for
336338 }
337339 ) ;
338340
341+ // Enhanced tool with table formatting for component listing
342+ server . tool (
343+ "ig_list_components_with_commands" ,
344+ "List all available Ignite UI components with their corresponding CLI and schematic commands in table format" ,
345+ {
346+ framework : {
347+ type : "string" ,
348+ description : "Framework to list components for (angular, react, webcomponents)" ,
349+ } ,
350+ format : {
351+ type : "string" ,
352+ description : "Output format: 'table' (default) or 'json'" ,
353+ } ,
354+ } ,
355+ async ( args : any ) => {
356+ try {
357+ const framework = args . framework || "angular" ;
358+ const format = args . format || "table" ;
359+ const frameworks = templateManager . getFrameworkIds ( ) ;
360+
361+ if ( ! frameworks . includes ( framework ) ) {
362+ return {
363+ content : [
364+ {
365+ type : "text" ,
366+ text : `Framework "${ framework } " not supported. Available: ${ frameworks . join ( ", " ) } ` ,
367+ } ,
368+ ] ,
369+ isError : true ,
370+ } ;
371+ }
372+
373+ const frameworkObj = templateManager . getFrameworkById ( framework ) ;
374+ const projectLibraries = frameworkObj ?. projectLibraries || [ ] ;
375+ const components : any [ ] = [ ] ;
376+
377+ for ( const projectLib of projectLibraries ) {
378+ for ( const component of projectLib . components ) {
379+ // Get first template for the component to extract ID
380+ const firstTemplate = component . templates [ 0 ] ;
381+ if ( firstTemplate ) {
382+ const componentId = firstTemplate . id ;
383+ const cliCommand = `ig add ${ componentId } new${ component . name . replace ( / \s / g, "" ) } ` ;
384+ const schematicCommand = framework === "angular"
385+ ? `ng g @igniteui/angular-schematics:component ${ componentId } new${ component . name . replace ( / \s / g, "" ) } `
386+ : cliCommand ;
387+
388+ components . push ( {
389+ id : componentId ,
390+ name : component . name ,
391+ description : component . description || "" ,
392+ cliCommand,
393+ schematicCommand,
394+ } ) ;
395+ }
396+ }
397+ }
398+
399+ if ( format === "table" ) {
400+ // Create formatted table
401+ let table = `
402+ Available Ignite UI Components for ${ framework } :
403+
404+ | Component | Description | CLI Command | Schematic Command (Angular) |
405+ |-----------------|--------------------------------|--------------------------------|------------------------------------------------------------------|
406+ ` ;
407+ for ( const comp of components ) {
408+ const id = comp . id . padEnd ( 15 ) ;
409+ const desc = ( comp . description . substring ( 0 , 30 ) ) . padEnd ( 30 ) ;
410+ const cli = comp . cliCommand . padEnd ( 30 ) ;
411+ const schematic = comp . schematicCommand . padEnd ( 64 ) ;
412+ table += `| ${ id } | ${ desc } | ${ cli } | ${ schematic } |\n` ;
413+ }
414+
415+ table += `
416+ \nTo add a component, use either command from the table above.
417+ After adding a component, start your application with:
418+ - For Angular: ng serve (or ig start)
419+ - For React: npm start (or ig start)
420+ - For WebComponents: npm start (or ig start)
421+ ` ;
422+
423+ return {
424+ content : [
425+ {
426+ type : "text" ,
427+ text : table ,
428+ } ,
429+ ] ,
430+ } ;
431+ } else {
432+ // Return JSON format
433+ return {
434+ content : [
435+ {
436+ type : "text" ,
437+ text : JSON . stringify ( { framework, components } , null , 2 ) ,
438+ } ,
439+ ] ,
440+ } ;
441+ }
442+ } catch ( error : any ) {
443+ return {
444+ content : [
445+ {
446+ type : "text" ,
447+ text : `Error listing components: ${ error . message } ` ,
448+ } ,
449+ ] ,
450+ isError : true ,
451+ } ;
452+ }
453+ }
454+ ) ;
455+
456+ // Register resources (simplified for SDK compatibility)
457+ // Note: MCP SDK v1.21.0 has different resource API than prompts/tools
458+ // We'll provide resources through tools for now until SDK is updated
459+
460+ server . tool (
461+ "ig_get_project_config" ,
462+ "Get the current project's ignite-ui-cli.json configuration" ,
463+ { } ,
464+ async ( ) => {
465+ try {
466+ const { ProjectConfig } = await import ( "@igniteui/cli-core" ) ;
467+ if ( ! ProjectConfig . hasLocalConfig ( ) ) {
468+ return {
469+ content : [
470+ {
471+ type : "text" ,
472+ text : JSON . stringify ( { error : "No Ignite UI project found in current directory" } , null , 2 ) ,
473+ } ,
474+ ] ,
475+ } ;
476+ }
477+ const config = ProjectConfig . getConfig ( ) ;
478+ return {
479+ content : [
480+ {
481+ type : "text" ,
482+ text : JSON . stringify ( config , null , 2 ) ,
483+ } ,
484+ ] ,
485+ } ;
486+ } catch ( error : any ) {
487+ return {
488+ content : [
489+ {
490+ type : "text" ,
491+ text : JSON . stringify ( { error : error . message } , null , 2 ) ,
492+ } ,
493+ ] ,
494+ isError : true ,
495+ } ;
496+ }
497+ }
498+ ) ;
499+
500+ server . tool (
501+ "ig_get_components_catalog" ,
502+ "Get full component catalog with metadata for a framework" ,
503+ {
504+ framework : {
505+ type : "string" ,
506+ description : "Framework to get catalog for (angular, react, webcomponents)" ,
507+ } ,
508+ } ,
509+ async ( args : any ) => {
510+ try {
511+ const framework = args . framework || "angular" ;
512+
513+ const frameworkObj = templateManager . getFrameworkById ( framework ) ;
514+ if ( ! frameworkObj ) {
515+ return {
516+ content : [
517+ {
518+ type : "text" ,
519+ text : JSON . stringify ( { error : `Framework "${ framework } " not found` } , null , 2 ) ,
520+ } ,
521+ ] ,
522+ isError : true ,
523+ } ;
524+ }
525+
526+ const catalog : any = {
527+ framework,
528+ name : frameworkObj . name ,
529+ projectTypes : [ ] ,
530+ } ;
531+
532+ for ( const projectLib of frameworkObj . projectLibraries || [ ] ) {
533+ const projectType : any = {
534+ id : projectLib . projectType ,
535+ name : projectLib . name ,
536+ components : projectLib . components . map ( ( c : any ) => ( {
537+ name : c . name ,
538+ description : c . description ,
539+ group : c . group ,
540+ templates : c . templates . map ( ( t : any ) => ( {
541+ id : t . id ,
542+ name : t . name ,
543+ description : t . description ,
544+ } ) ) ,
545+ } ) ) ,
546+ } ;
547+ catalog . projectTypes . push ( projectType ) ;
548+ }
549+
550+ return {
551+ content : [
552+ {
553+ type : "text" ,
554+ text : JSON . stringify ( catalog , null , 2 ) ,
555+ } ,
556+ ] ,
557+ } ;
558+ } catch ( error : any ) {
559+ return {
560+ content : [
561+ {
562+ type : "text" ,
563+ text : JSON . stringify ( { error : error . message } , null , 2 ) ,
564+ } ,
565+ ] ,
566+ isError : true ,
567+ } ;
568+ }
569+ }
570+ ) ;
571+
339572 return server ;
340573}
341574
0 commit comments