check_username
Verify username availability on MonkeyType by checking if a desired username is already taken, enabling users to find available options.
Instructions
Check if a username is available on MonkeyType
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Username to check for availability |
Implementation Reference
- server.js:293-299 (handler)The switch case handler for the 'check_username' tool. It constructs parameters from the input args, calls the shared 'callMonkeyTypeApi' helper with the specific MonkeyType endpoint '/users/checkname' using GET method, and returns the JSON-stringified result as tool output.case "check_username": { const params = { name: args.name }; const result = await callMonkeyTypeApi(`/users/checkname`, 'GET', apiKey, params); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }
- server.js:20-22 (schema)Zod schema defining the input parameters for the 'check_username' tool: a required 'name' string representing the username to check.const CheckNameSchema = BaseApiSchema.extend({ name: z.string().describe("Username to check for availability") });
- server.js:163-167 (registration)Registration of the 'check_username' tool in the MCP server's listTools response, including name, description, and input schema derived from CheckNameSchema.{ name: "check_username", description: "Check if a username is available on MonkeyType", inputSchema: zodToJsonSchema(CheckNameSchema), },
- server.js:118-156 (helper)Shared helper function used by all tools, including 'check_username', to make authenticated HTTP requests to the MonkeyType API using axios, handling GET/POST, errors, and returning data or error objects.async function callMonkeyTypeApi(endpoint, method, apiKey, params = {}, data = null) { try { const headers = { 'Authorization': `ApeKey ${apiKey}`, 'Content-Type': 'application/json', 'User-Agent': 'MonkeyType-MCP-Server/1.0.0' }; const config = { headers, timeout: 30000, validateStatus: status => status < 500 }; if (method === 'GET' && Object.keys(params).length > 0) { config.params = params; } let response; if (method === 'GET') { response = await axios.get(`${MONKEYTYPE_API_BASE_URL}${endpoint}`, config); } else if (method === 'POST') { response = await axios.post(`${MONKEYTYPE_API_BASE_URL}${endpoint}`, data, config); } return response.data; } catch (error) { console.error(`Error calling MonkeyType API: ${error.message}`); if (error.response) { return { error: error.response.data, statusCode: error.response.status }; } return { error: error.message }; } }