#!/usr/bin/env node
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import { performLogin } from "./oauth.js";
import { MCP } from "./mcp.js";
import { saveConfig, loadConfig } from "./auth.js";
yargs(hideBin(process.argv))
.command(
"configure <clientId> <clientSecret>",
"Configure OAuth credentials",
(yargs) => {
return yargs
.positional("clientId", {
describe: "ClickUp Client ID",
type: "string",
})
.positional("clientSecret", {
describe: "ClickUp Client Secret",
type: "string",
});
},
(argv: any) => {
saveConfig({
clientId: argv.clientId,
clientSecret: argv.clientSecret,
});
console.log("Configuration saved.");
},
)
.command(
"logout",
"Remove stored credentials",
() => { },
() => {
saveConfig({});
console.log("Logged out.");
},
)
.command(
"login",
"Authenticate with ClickUp via OAuth",
() => { },
async () => {
await performLogin();
process.exit(0);
},
)
.command(
"tasks list <listId>",
"Get a list of tasks in a list",
(yargs: any) => {
return yargs.positional("listId", {
describe: "The ID of the list to get tasks from",
type: "string",
});
},
async (argv: any) => {
const mcp = new MCP();
const tasks = await mcp.getTasks(argv.listId);
console.log(JSON.stringify(tasks, null, 2));
},
)
.command(
"workspaces",
"List available ClickUp workspaces",
() => { },
async () => {
try {
const mcp = new MCP();
const teams = await mcp.getWorkspaces();
console.log("Found Workspaces:");
teams.forEach((team: any) => {
console.log(`- ${team.name} (ID: ${team.id})`);
});
} catch (error: any) {
console.error("Error fetching workspaces:", error.message);
}
},
)
.command(
"spaces <workspaceId>",
"List spaces in a workspace",
(yargs: any) => {
return yargs.positional("workspaceId", {
describe: "The ID of the workspace",
type: "string",
});
},
async (argv: any) => {
try {
const mcp = new MCP();
const spaces = await mcp.getSpaces(argv.workspaceId);
console.log("Found Spaces:");
spaces.forEach((space: any) => {
console.log(`- ${space.name} (ID: ${space.id})`);
});
} catch (error: any) {
console.error("Error fetching spaces:", error.message);
}
},
)
.command(
"folders <spaceId>",
"List folders in a space",
(yargs: any) => {
return yargs.positional("spaceId", {
describe: "The ID of the space",
type: "string",
});
},
async (argv: any) => {
try {
const mcp = new MCP();
const folders = await mcp.getFolders(argv.spaceId);
console.log("Found Folders:");
folders.forEach((folder: any) => {
console.log(`- ${folder.name} (ID: ${folder.id})`);
});
} catch (error: any) {
console.error("Error fetching folders:", error.message);
}
},
)
.command(
"lists <folderId>",
"List lists in a folder",
(yargs: any) => {
return yargs.positional("folderId", {
describe: "The ID of the folder",
type: "string",
});
},
async (argv: any) => {
try {
const mcp = new MCP();
const lists = await mcp.getLists(argv.folderId);
console.log("Found Lists:");
lists.forEach((list: any) => {
console.log(`- ${list.name} (ID: ${list.id})`);
});
} catch (error: any) {
console.error("Error fetching lists:", error.message);
}
},
)
.demandCommand(1)
.parse();