@@ -10,62 +10,60 @@ export function registerContributorRecommenderTool(server: McpServer) {
1010 title : "Code Contributor Recommender" ,
1111 description : "Recommends contributors who have contributed most to specific files/branches/PR areas by aggregating recent contribution data." ,
1212 inputSchema : {
13- repoPath : z . string ( ) . describe ( "GitHub repository path (e.g: owner/repo or https://github.com/owner/repo)" ) ,
14- pr : z . union ( [ z . string ( ) , z . number ( ) ] ) . optional ( ) . describe ( "PR-based recommendation (PR number)" ) ,
15- paths : z . array ( z . string ( ) ) . optional ( ) . describe ( "File/directory path array (supports glob patterns)" ) ,
16- branch : z . string ( ) . optional ( ) . describe ( "Branch-based recommendation (default: main)" ) ,
17- since : z . string ( ) . optional ( ) . describe ( "Analysis period start (default 90 days, 30d/ISO date etc.)" ) ,
18- until : z . string ( ) . optional ( ) . describe ( "Analysis period end (current if unspecified)" ) ,
19- githubToken : z . string ( ) . describe ( "GitHub authentication token" ) ,
20- locale : z . enum ( [ "en" , "ko" ] ) . default ( "en" ) . describe ( "Response language (en: English, ko: Korean)" ) ,
21- chart : z . boolean ( ) . default ( false ) . describe ( "Generate interactive chart visualization (true: HTML chart display, false: JSON data)" ) ,
13+ repoPath : z . string ( ) . describe ( "GitHub repository path (e.g: owner/repo or https://github.com/owner/repo)" ) ,
14+ pr : z . union ( [ z . string ( ) , z . number ( ) ] ) . optional ( ) . describe ( "PR-based recommendation (PR number)" ) ,
15+ paths : z . array ( z . string ( ) ) . optional ( ) . describe ( "File/directory path array (supports glob patterns)" ) ,
16+ branch : z . string ( ) . optional ( ) . describe ( "Branch-based recommendation (default: main)" ) ,
17+ since : z . string ( ) . optional ( ) . describe ( "Analysis period start (default 90 days, 30d/ISO date etc.)" ) ,
18+ until : z . string ( ) . optional ( ) . describe ( "Analysis period end (current if unspecified)" ) ,
19+ locale : z . enum ( [ "en" , "ko" ] ) . default ( "en" ) . describe ( "Response language (en: English, ko: Korean)" ) ,
20+ isChart : z . boolean ( ) . default ( false ) . describe ( "Generate interactive chart visualization (true: HTML chart display, false: JSON data)" ) ,
2221 } ,
2322 } ,
2423
25- async ( { repoPath, pr, paths, branch, since, until, githubToken , locale, chart } : ContributorRecommenderInputs & { locale ?: string ; chart ?: boolean } ) => {
24+ async ( { repoPath, pr, paths, branch, since, until, locale, isChart } : ContributorRecommenderInputs & { locale ?: string ; chart ?: boolean } ) => {
2625 try {
27- I18n . setLocale ( locale || 'en' ) ;
28-
29- const { ContributorRecommender } = await import ( '../../tool/contributorRecommender.js' ) ;
30- const recommender = new ContributorRecommender ( {
31- repoPath,
32- pr,
33- paths,
34- branch,
35- since,
36- until,
37- githubToken,
38- locale,
39- } ) ;
26+ I18n . setLocale ( locale || 'en' ) ;
27+
28+ const { ContributorRecommender } = await import ( '../../tool/contributorRecommender.js' ) ;
29+ const recommender = new ContributorRecommender ( {
30+ repoPath,
31+ pr,
32+ paths,
33+ branch,
34+ since,
35+ until,
36+ locale,
37+ } ) ;
4038
41- const recommendation = await recommender . analyze ( ) ;
39+ const recommendation = await recommender . analyze ( ) ;
4240
43- if ( chart ) {
44- const chartHtml = recommender . generateChart ( recommendation ) ;
45- return {
46- content : [
47- {
48- type : "text" ,
49- text : chartHtml ,
50- } ,
51- ] ,
52- } ;
53- } else {
54- return {
55- content : [
56- {
57- type : "text" ,
58- text : JSON . stringify ( recommendation , null , 2 ) ,
59- } ,
60- ] ,
61- } ;
62- }
41+ if ( isChart ) {
42+ const chartHtml = recommender . generateChart ( recommendation ) ;
43+ return {
44+ content : [
45+ {
46+ type : "text" ,
47+ text : chartHtml ,
48+ } ,
49+ ] ,
50+ } ;
51+ } else {
52+ return {
53+ content : [
54+ {
55+ type : "text" ,
56+ text : JSON . stringify ( recommendation , null , 2 ) ,
57+ } ,
58+ ] ,
59+ } ;
60+ }
6361 } catch ( err : any ) {
64- return {
65- content : [
66- { type : "text" , text : `Contributor recommendation error occurred: ${ err ?. message ?? String ( err ) } ` } ,
67- ] ,
68- } ;
62+ return {
63+ content : [
64+ { type : "text" , text : `Contributor recommendation error occurred: ${ err ?. message ?? String ( err ) } ` } ,
65+ ] ,
66+ } ;
6967 }
7068 }
7169 ) ;
0 commit comments