@@ -11,38 +11,26 @@ export async function buildFramework() {
1111 const startDir = process . cwd ( ) ;
1212 process . stderr . write ( `Starting search from: ${ startDir } \n` ) ;
1313
14- let projectRoot : string | null = null ;
14+ if ( process . argv . includes ( 'create' ) ) {
15+ process . stderr . write ( `Skipping build for create command\n` ) ;
16+ return ;
17+ }
18+
1519 try {
1620 const pkgPath = join ( startDir , 'package.json' ) ;
17- const tsConfigPath = join ( startDir , 'tsconfig.json' ) ;
18-
19- process . stderr . write ( `Checking for package.json at: ${ pkgPath } \n` ) ;
20- const [ pkgContent , _tsConfigContent ] = await Promise . all ( [
21- readFile ( pkgPath , 'utf8' ) ,
22- readFile ( tsConfigPath , 'utf8' )
23- ] ) ;
24-
21+ const pkgContent = await readFile ( pkgPath , 'utf8' ) ;
2522 const pkg = JSON . parse ( pkgContent ) ;
26- if ( pkg . dependencies ?. [ "mcp-framework" ] ) {
27- projectRoot = startDir ;
28- process . stderr . write ( `Found MCP project at current directory: ${ projectRoot } \n` ) ;
23+
24+ if ( ! pkg . dependencies ?. [ "mcp-framework" ] ) {
25+ throw new Error ( "This directory is not an MCP project (mcp-framework not found in dependencies)" ) ;
2926 }
30- } catch ( error ) {
31- process . stderr . write ( `Error checking current directory: ${ error instanceof Error ? error . message : String ( error ) } \n` ) ;
32- }
33-
34- if ( ! projectRoot ) {
35- process . stderr . write ( "Error: Current directory is not an MCP project\n" ) ;
36- throw new Error ( 'Current directory must be an MCP project with mcp-framework as a dependency' ) ;
37- }
38-
39- try {
40- process . stderr . write ( `Running tsc in ${ projectRoot } \n` ) ;
27+
28+ process . stderr . write ( `Running tsc in ${ startDir } \n` ) ;
4129
4230 const tscCommand = process . platform === 'win32' ? [ 'npx.cmd' , 'tsc' ] : [ 'npx' , 'tsc' ] ;
4331
4432 await execa ( tscCommand [ 0 ] , [ tscCommand [ 1 ] ] , {
45- cwd : projectRoot ,
33+ cwd : startDir ,
4634 stdio : "inherit" ,
4735 env : {
4836 ...process . env ,
@@ -51,7 +39,7 @@ export async function buildFramework() {
5139 }
5240 } ) ;
5341
54- const distPath = join ( projectRoot , "dist" ) ;
42+ const distPath = join ( startDir , "dist" ) ;
5543 const projectIndexPath = join ( distPath , "index.js" ) ;
5644 const shebang = "#!/usr/bin/env node\n" ;
5745
@@ -68,7 +56,7 @@ export async function buildFramework() {
6856
6957 process . stderr . write ( "Build completed successfully!\n" ) ;
7058 } catch ( error ) {
71- process . stderr . write ( `Build error : ${ error instanceof Error ? error . message : String ( error ) } \n` ) ;
59+ process . stderr . write ( `Error : ${ error instanceof Error ? error . message : String ( error ) } \n` ) ;
7260 process . exit ( 1 ) ;
7361 }
7462}
@@ -80,3 +68,5 @@ if (import.meta.url.startsWith('file:')) {
8068 process . exit ( 1 ) ;
8169 } ) ;
8270}
71+
72+ export default buildFramework ;
0 commit comments