11// creator-server.ts
22import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" ;
33import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js" ;
4- import { TEMPLATE_MCP_SERVER } from "./template.ts " ;
4+ import { TEMPLATE_MCP_SERVER } from "./template.js " ;
55import { exec } from "child_process" ;
66import { promisify } from "util" ;
77import fs from "fs/promises" ;
@@ -286,7 +286,6 @@ server.tool(
286286 } ;
287287 }
288288
289-
290289 // This is the critical step: We write the file to disk FIRST, before doing anything else.
291290 // This ensures that even if the context window limit is reached during the conversation,
292291 // the file has already been saved and can be accessed in a new conversation.
@@ -310,7 +309,6 @@ server.tool(
310309 error instanceof Error ? error . message : String ( error )
311310 } `;
312311 }
313-
314312 }
315313
316314 // Add line numbers to the code for better reference
@@ -639,23 +637,18 @@ server.tool(
639637 } ;
640638 }
641639
642- // Split the new code into lines
643640 const newLines = code . split ( "\n" ) ;
644641
645- // Replace the specified section with the new code
646642 const updatedLines = [
647643 ...lines . slice ( 0 , startLine - 1 ) ,
648644 ...newLines ,
649645 ...lines . slice ( endLine ) ,
650646 ] ;
651647
652- // Join the lines back together
653648 const updatedCode = updatedLines . join ( "\n" ) ;
654649
655- // Write the updated code back to the file
656650 await fs . writeFile ( filePath , updatedCode ) ;
657-
658- // Add line numbers to the updated content
651+
659652 const numberedLines = updatedLines . map (
660653 ( line , index ) => `${ ( index + 1 ) . toString ( ) . padStart ( 4 , " " ) } | ${ line } `
661654 ) ;
@@ -717,7 +710,7 @@ server.tool(
717710
718711 // Write the updated code back to the file
719712 await fs . writeFile ( filePath , updatedCode ) ;
720-
713+
721714 // Add line numbers to the updated content
722715 const numberedLines = updatedLines . map (
723716 ( line , index ) => `${ ( index + 1 ) . toString ( ) . padStart ( 4 , " " ) } | ${ line } `
@@ -836,7 +829,7 @@ server.tool(
836829 . describe ( "List of npm packages to install" ) ,
837830 } ,
838831 async ( { dependencies } ) => {
839- const log = ( msg : string ) =>
832+ const log = ( msg ) =>
840833 process . stdout . write ( `[installServerDependencies] ${ msg } \n` ) ;
841834
842835 try {
@@ -1100,7 +1093,7 @@ server.tool(
11001093) ;
11011094
11021095// Helper function to recursively copy directories
1103- async function copyRecursive ( src : string , dest : string ) {
1096+ async function copyRecursive ( src , dest ) {
11041097 const stats = await fs . stat ( src ) ;
11051098
11061099 if ( stats . isDirectory ( ) ) {
@@ -1357,10 +1350,7 @@ server.tool(
13571350const transport = new StdioServerTransport ( ) ;
13581351server . connect ( transport ) ;
13591352
1360- async function registerServerWithClaude (
1361- serverName : string ,
1362- serverPath : string
1363- ) : Promise < string > {
1353+ async function registerServerWithClaude ( serverName , serverPath ) {
13641354 const configExists = await fileExists ( CLAUDE_CONFIG_PATH ) ;
13651355
13661356 if ( ! configExists ) {
@@ -1389,7 +1379,7 @@ async function registerServerWithClaude(
13891379 return `Server registered with Claude Desktop as "${ serverName } ".` ;
13901380}
13911381
1392- async function fileExists ( filePath : string ) : Promise < boolean > {
1382+ async function fileExists ( filePath ) {
13931383 try {
13941384 await fs . access ( filePath ) ;
13951385 return true ;
0 commit comments