@civic/hub-bridge
Version:
Stdio <-> HTTP/SSE MCP bridge with Civic auth handling
72 lines • 2.23 kB
JavaScript
import { logger } from '../utils/logger.js';
import { ConfigManager } from "../lib/ConfigManager.js";
/**
* Tool definition for switch profile tool
*/
export const switchProfileTool = {
name: 'switch_profile',
description: 'Switch to a different profile in your account',
inputSchema: {
type: 'object',
properties: {
alias: {
type: 'string',
description: 'Alias of the profile to switch to'
}
},
required: ['alias']
}
};
/**
* Get the current profile alias
*/
export async function getCurrentProfile() {
return await ConfigManager.getInstance().getCurrentProfileAlias();
}
/**
* Handler for the switch profile tool
*/
export const handleSwitchProfile = async (request) => {
logger.info(`[Tool: ${switchProfileTool.name}] Processing switch profile request`);
try {
const { alias } = request.params.arguments;
if (!alias) {
return {
content: [
{
type: "text",
text: "Error: Profile alias is required"
}
],
isError: true
};
}
// Note: Profile validation will be done by the hub when making requests.
// We just store the alias locally.
// Save the profile alias
await ConfigManager.getInstance().setCurrentProfile(alias);
logger.info(`[Tool: ${switchProfileTool.name}] Switched to profile: ${alias}`);
return {
content: [
{
type: "text",
text: `Successfully switched to profile "${alias}". This profile will be used for all subsequent requests.`
}
],
isError: false
};
}
catch (error) {
logger.error(`[Tool: ${switchProfileTool.name}] Error switching profile:`, error);
return {
content: [
{
type: "text",
text: `Error switching profile: ${error}`
}
],
isError: true
};
}
};
//# sourceMappingURL=switchProfile.js.map