crafty_login
Authenticate to Crafty Controller using username and password credentials to obtain a bearer token for API access.
Instructions
Login with username and password to get a bearer token. Use this if you prefer username/password authentication over a pre-generated API token.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| username | Yes | Crafty Controller username | |
| password | Yes | Crafty Controller password | |
| totp | No | TOTP/2FA code (required if MFA is enabled on the account) |
Implementation Reference
- src/tools/auth.ts:17-25 (handler)The handler function for the crafty_login tool.
async ({ username, password, totp }) => { try { const data = await client.login(username, password, totp); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } catch (error) { const msg = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Error: ${msg}` }], isError: true }; } } - src/tools/auth.ts:9-16 (schema)Zod schema definition for crafty_login input arguments.
{ username: z.string().describe("Crafty Controller username"), password: z.string().describe("Crafty Controller password"), totp: z .string() .optional() .describe("TOTP/2FA code (required if MFA is enabled on the account)"), }, - src/tools/auth.ts:6-26 (registration)Registration of the crafty_login tool within the MCP server.
server.tool( "crafty_login", "Login with username and password to get a bearer token. Use this if you prefer username/password authentication over a pre-generated API token.", { username: z.string().describe("Crafty Controller username"), password: z.string().describe("Crafty Controller password"), totp: z .string() .optional() .describe("TOTP/2FA code (required if MFA is enabled on the account)"), }, async ({ username, password, totp }) => { try { const data = await client.login(username, password, totp); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } catch (error) { const msg = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Error: ${msg}` }], isError: true }; } } );