We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/peacockery-studio/outlook-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
/**
* Delete event functionality
*/
import { ensureAuthenticated } from "../auth";
import {
canModifyMailbox,
formatAllowedMailboxes,
} from "../config/mailbox-permissions";
import { callGraphAPI } from "../utils/graph-api";
import type { DeleteEventArgs, MCPResponse } from "./types";
/**
* Delete event handler
* @param args - Tool arguments
* @returns MCP response
*/
async function handleDeleteEvent(args: DeleteEventArgs): Promise<MCPResponse> {
const mailbox = args.mailbox;
if (!mailbox) {
return {
content: [{ type: "text", text: "Mailbox address is required." }],
isError: true,
};
}
const { eventId } = args;
if (!eventId) {
return {
content: [
{
type: "text",
text: "Event ID is required to delete an event.",
},
],
isError: true,
};
}
// Check if the mailbox has permission to modify
if (!canModifyMailbox(mailbox)) {
return {
content: [
{
type: "text",
text: `Deleting events is not allowed from this mailbox. Allowed: ${formatAllowedMailboxes()}`,
},
],
isError: true,
};
}
try {
// Get access token
const accessToken = await ensureAuthenticated();
// Build API endpoint
const endpoint = `users/${mailbox}/events/${eventId}`;
// Make API call
await callGraphAPI(accessToken, "DELETE", endpoint);
return {
content: [
{
type: "text",
text: `Event with ID ${eventId} has been successfully deleted.`,
},
],
};
} catch (error) {
const errorMessage =
error instanceof Error ? error.message : "Unknown error";
if (errorMessage === "Authentication required") {
return {
content: [
{
type: "text",
text: "Authentication required. Please use the 'authenticate' tool first.",
},
],
isError: true,
};
}
return {
content: [
{
type: "text",
text: `Error deleting event: ${errorMessage}`,
},
],
isError: true,
};
}
}
export default handleDeleteEvent;