capture-mvp-token.tsβ’5.73 kB
#!/usr/bin/env tsx
/**
* Manual MVP Token Capture Tool
*
* This script helps you update your Claude Desktop config with a fresh MVP token
* that you capture manually from your browser's DevTools.
*/
import { writeFileSync, readFileSync, existsSync } from "node:fs";
import { homedir } from "node:os";
import { join } from "node:path";
import { exec } from "node:child_process";
import { promisify } from "node:util";
import * as readline from "node:readline";
const execAsync = promisify(exec);
interface ClaudeConfig {
mcpServers?: {
"activity-reporting"?: {
command?: string;
args?: string[];
env?: {
MVP_ACCESS_TOKEN?: string;
MVP_USER_PROFILE_ID?: string;
ADVOCU_ACCESS_TOKEN?: string;
};
};
};
}
function updateClaudeDesktopConfig(newToken: string): boolean {
try {
const configPath = join(homedir(), "Library", "Application Support", "Claude", "claude_desktop_config.json");
let config: ClaudeConfig = {};
// Read existing config if it exists
if (existsSync(configPath)) {
const configContent = readFileSync(configPath, "utf-8");
config = JSON.parse(configContent);
}
// Ensure mcpServers exists
if (!config.mcpServers) {
config.mcpServers = {};
}
// Ensure activity-reporting server exists
if (!config.mcpServers["activity-reporting"]) {
config.mcpServers["activity-reporting"] = {
command: "node",
args: [join(process.cwd(), "dist", "index.js")],
env: {},
};
}
// Ensure env object exists
if (!config.mcpServers["activity-reporting"].env) {
config.mcpServers["activity-reporting"].env = {};
}
// Update the MVP token
config.mcpServers["activity-reporting"].env.MVP_ACCESS_TOKEN = newToken;
// Write back to file
writeFileSync(configPath, JSON.stringify(config, null, 2));
return true;
} catch (error) {
console.error("β Error updating config:", error);
return false;
}
}
async function main() {
console.log("\nπ MVP Token Manual Capture Tool\n");
console.log("=" .repeat(60));
console.log("\nβ οΈ IMPORTANTE: Debes estar logueado en el portal MVP ANTES de continuar\n");
console.log("=" .repeat(60));
console.log("\nπ INSTRUCCIONES:\n");
console.log("1. π Abriendo tu navegador por defecto en el portal MVP...");
console.log("2. β
Si ya estΓ‘s logueado, verΓ‘s tu cuenta directamente");
console.log("3. π Si no estΓ‘s logueado, inicia sesiΓ³n con tu cuenta Microsoft");
console.log("\n4. π οΈ Abre DevTools:");
console.log(" - Chrome/Edge/Firefox: Presiona F12 o Cmd+Option+I (Mac)");
console.log(" - Safari: Habilita en Preferencias primero, luego Cmd+Option+I");
console.log("\n5. π Click en la pestaΓ±a 'Network' (Red) en DevTools");
console.log("6. π Navega a 'Add activity' o edita una actividad existente");
console.log("7. βοΈ Llena cualquier campo del formulario (esto genera llamadas API)");
console.log("\n8. π En la pestaΓ±a Network, busca una peticiΓ³n a:");
console.log(" β
'mavenapi-prod.azurewebsites.net'");
console.log(" β
MΓ©todo: POST o GET");
console.log("\n9. π±οΈ Haz click en esa peticiΓ³n");
console.log("10. π Ve a la pestaΓ±a 'Headers' (Encabezados)");
console.log("11. π Scroll hasta 'Request Headers' (Encabezados de solicitud)");
console.log("12. π Encuentra el header 'Authorization'");
console.log("13. π Copia SOLO la parte del token (despuΓ©s de 'Bearer ')");
console.log("\n" + "=".repeat(60));
console.log("\nπ‘ El token se ve asΓ:");
console.log(" eyJhbGciOiJSU0EtT0FFUCIsImVuYy...(cadena muy larga)");
console.log("\nβ οΈ IMPORTANTE: Copia SOLO el token, NO la palabra 'Bearer'\n");
console.log("=".repeat(60) + "\n");
console.log("β³ Abriendo navegador en 3 segundos...\n");
await new Promise((resolve) => setTimeout(resolve, 3000));
// Open the default browser
try {
await execAsync("open https://mvp.microsoft.com/en-US/account/");
console.log("β
Navegador abierto!\n");
} catch (error) {
console.log("β οΈ No se pudo abrir el navegador automΓ‘ticamente");
console.log("π‘ Abre manualmente: https://mvp.microsoft.com/en-US/account/\n");
}
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
rl.question("π Paste your MVP access token here and press Enter:\n\n", (token) => {
rl.close();
const cleanToken = token.trim().replace(/^Bearer\s+/i, "");
if (!cleanToken || cleanToken.length < 50) {
console.log("\nβ Invalid token. Token should be very long (hundreds of characters)");
console.log("π‘ Make sure you copied the entire token");
process.exit(1);
}
console.log("\nβ
Token received!");
console.log(`π Length: ${cleanToken.length} characters`);
console.log(`π Preview: ${cleanToken.substring(0, 50)}...${cleanToken.substring(cleanToken.length - 20)}\n`);
console.log("π§ Updating Claude Desktop config...");
const updated = updateClaudeDesktopConfig(cleanToken);
if (updated) {
console.log("\nβ
SUCCESS! Claude Desktop config updated!");
console.log("π Updated: MVP_ACCESS_TOKEN\n");
console.log("π Next steps:");
console.log(" 1. Restart Claude Desktop (Cmd+Q then reopen)");
console.log(" 2. Your MVP token is now refreshed and ready to use!\n");
} else {
console.log("\nβ οΈ Could not auto-update config. Manual update needed:");
console.log(` "MVP_ACCESS_TOKEN": "${cleanToken}"\n`);
}
});
}
main().catch((error) => {
console.error("β Error:", error);
process.exit(1);
});