Skip to main content
Glama

IT Tools MCP Server

index.ts•2.65 kB
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { z } from "zod"; export function registerGenerateToken(server: McpServer) { server.registerTool("generate_token", { description: "Generate secure random tokens", inputSchema: { length: z.number().describe("Token length").optional(), charset: z.enum(["alphanumeric", "hex", "base64", "custom"]).describe("Character set to use").optional(), customChars: z.string().optional().describe("Custom characters (required if charset is 'custom')"), }, // VS Code compliance annotations annotations: { title: "Generate Token", description: "Generate secure random tokens", readOnlyHint: false } }, async ({ length = 32, charset = "alphanumeric", customChars }) => { try { if (length < 8 || length > 256) { return { content: [ { type: "text", text: "Length must be between 8 and 256.", }, ], }; } let chars = ''; switch (charset) { case 'alphanumeric': chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; break; case 'hex': chars = '0123456789abcdef'; break; case 'base64': chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; break; case 'custom': if (!customChars) { return { content: [ { type: "text", text: "Error: Custom characters required when charset is 'custom'", }, ], }; } chars = customChars; break; } let token = ''; const { randomBytes } = await import('crypto'); const randomValues = randomBytes(length); for (let i = 0; i < length; i++) { token += chars.charAt(randomValues[i] % chars.length); } return { content: [ { type: "text", text: `Generated Token: ${token} Length: ${length} characters Character set: ${charset} ${charset === 'custom' ? `Custom chars: ${customChars}` : ''}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error generating token: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], }; } } ); }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/wrenchpilot/it-tools-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server