adding the --clean flag
This commit is contained in:
parent
a32681e154
commit
027007030e
6 changed files with 125 additions and 25 deletions
|
@ -4,7 +4,10 @@
|
|||
* MCP Client with OAuth support
|
||||
* A command-line client that connects to an MCP server using SSE with OAuth authentication.
|
||||
*
|
||||
* Run with: npx tsx client.ts https://example.remote/server [callback-port]
|
||||
* Run with: npx tsx client.ts [--clean] https://example.remote/server [callback-port]
|
||||
*
|
||||
* Options:
|
||||
* --clean: Deletes stored configuration before reading, ensuring a fresh session
|
||||
*
|
||||
* If callback-port is not specified, an available port will be automatically selected.
|
||||
*/
|
||||
|
@ -20,7 +23,7 @@ import { parseCommandLineArgs, setupOAuthCallbackServer, setupSignalHandlers } f
|
|||
/**
|
||||
* Main function to run the client
|
||||
*/
|
||||
async function runClient(serverUrl: string, callbackPort: number) {
|
||||
async function runClient(serverUrl: string, callbackPort: number, clean: boolean = false) {
|
||||
// Set up event emitter for auth flow
|
||||
const events = new EventEmitter()
|
||||
|
||||
|
@ -29,6 +32,7 @@ async function runClient(serverUrl: string, callbackPort: number) {
|
|||
serverUrl,
|
||||
callbackPort,
|
||||
clientName: 'MCP CLI Client',
|
||||
clean,
|
||||
})
|
||||
|
||||
// Create the client
|
||||
|
@ -147,9 +151,9 @@ async function runClient(serverUrl: string, callbackPort: number) {
|
|||
}
|
||||
|
||||
// Parse command-line arguments and run the client
|
||||
parseCommandLineArgs(process.argv.slice(2), 3333, 'Usage: npx tsx client.ts <https://server-url> [callback-port]')
|
||||
.then(({ serverUrl, callbackPort }) => {
|
||||
return runClient(serverUrl, callbackPort)
|
||||
parseCommandLineArgs(process.argv.slice(2), 3333, 'Usage: npx tsx client.ts [--clean] <https://server-url> [callback-port]')
|
||||
.then(({ serverUrl, callbackPort, clean }) => {
|
||||
return runClient(serverUrl, callbackPort, clean)
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Fatal error:', error)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue