@@ -40,6 +40,7 @@ interface CliArgs {
4040 userId ?: string ;
4141 isNew : boolean ;
4242 verbose : boolean ;
43+ local : boolean ;
4344}
4445
4546interface SessionData {
@@ -51,18 +52,20 @@ function parseArgs(): CliArgs {
5152 const args = process . argv . slice ( 2 ) ;
5253
5354 if ( args . length === 0 || args . includes ( '--help' ) || args . includes ( '-h' ) ) {
54- console . log ( 'Usage: agent-cli <question> [--userId <userId>] [--new] [--verbose]' ) ;
55+ console . log ( 'Usage: agent-cli <question> [--userId <userId>] [--new] [--verbose] [--local] ' ) ;
5556 console . log ( ' question: Your question about burger orders' ) ;
5657 console . log ( ' --userId: Optional user ID (needed for some tasks)' ) ;
5758 console . log ( ' --new: Start a new session' ) ;
5859 console . log ( ' --verbose: Enable verbose mode to show intermediate steps' ) ;
60+ console . log ( ' --local: Force connection to localhost MCP server' ) ;
5961 process . exit ( 0 ) ;
6062 }
6163
6264 const questionParts : string [ ] = [ ] ;
6365 let userId : string | undefined ;
6466 let isNew = false ;
6567 let verbose = false ;
68+ let local = false ;
6669
6770 for ( let i = 0 ; i < args . length ; i ++ ) {
6871 const arg = args [ i ] ;
@@ -74,6 +77,8 @@ function parseArgs(): CliArgs {
7477 isNew = true ;
7578 } else if ( arg === '--verbose' ) {
7679 verbose = true ;
80+ } else if ( arg === '--local' ) {
81+ local = true ;
7782 } else {
7883 questionParts . push ( arg ) ;
7984 }
@@ -86,7 +91,7 @@ function parseArgs(): CliArgs {
8691 process . exit ( 1 ) ;
8792 }
8893
89- return { question, userId, isNew, verbose } ;
94+ return { question, userId, isNew, verbose, local } ;
9095}
9196
9297async function getSessionPath ( ) : Promise < string > {
@@ -123,9 +128,10 @@ function convertHistoryToMessages(history: SessionData['history']): BaseMessage[
123128}
124129
125130export async function run ( ) {
126- const { question, userId, isNew, verbose } = parseArgs ( ) ;
131+ const { question, userId, isNew, verbose, local } = parseArgs ( ) ;
127132 const azureOpenAiEndpoint = process . env . AZURE_OPENAI_API_ENDPOINT ;
128- const burgerMcpEndpoint = process . env . BURGER_MCP_URL ?? 'http://localhost:3000/mcp' ;
133+ const localMcpEndpoint = 'http://localhost:3000/mcp' ;
134+ const burgerMcpEndpoint = local ? localMcpEndpoint : ( process . env . BURGER_MCP_URL ?? localMcpEndpoint ) ;
129135
130136 let client : Client | undefined ;
131137
0 commit comments