it-tools-mcp
Version:
Full MCP 2025-06-18 compliant server with 121+ IT tools, logging, ping, progress tracking, cancellation, and sampling utilities
64 lines (60 loc) • 2.15 kB
JavaScript
import { z } from "zod";
export function registerDecodeSafelink(server) {
server.registerTool("decode_safelink", {
description: "Decode Microsoft Outlook SafeLink URLs",
inputSchema: {
safelink: z.string().describe("SafeLink URL to decode")
},
// VS Code compliance annotations
annotations: {
title: "Decode Safelink",
description: "Decode Microsoft Outlook SafeLink URLs",
readOnlyHint: false
}
}, async ({ safelink }) => {
try {
const url = new URL(safelink);
// Check if it's a SafeLink URL
if (!url.hostname.includes('safelinks.protection.outlook.com')) {
return {
content: [{
type: "text",
text: "This doesn't appear to be a SafeLink URL."
}]
};
}
// Extract the actual URL from the 'url' parameter
const actualUrl = url.searchParams.get('url');
if (!actualUrl) {
return {
content: [{
type: "text",
text: "Could not find the original URL in the SafeLink."
}]
};
}
// Decode the URL
const decodedUrl = decodeURIComponent(actualUrl);
return {
content: [{
type: "text",
text: `SafeLink Decoder Results:
Original SafeLink: ${safelink}
Decoded URL: ${decodedUrl}
Additional Parameters:
- Data: ${url.searchParams.get('data') || 'N/A'}
- Reserved: ${url.searchParams.get('reserved') || 'N/A'}
- Source: ${url.searchParams.get('source') || 'N/A'}`
}]
};
}
catch (error) {
return {
content: [{
type: "text",
text: `Error decoding SafeLink: ${error instanceof Error ? error.message : 'Unknown error'}`
}]
};
}
});
}