UNPKG

makereels-mcp

Version:

MakeReels MCP Server

68 lines (67 loc) 2 kB
import z from "zod"; import { createTool } from "./utils.js"; import { api, getToken, setToken } from "../lib/api.js"; export const is_authenticated_tool = createTool({ id: "is_authenticated", name: "Is Authenticated", description: "Check if the user is authenticated", outputSchema: z.object({ isAuthenticated: z.boolean(), }), execute: async () => { let token = null; try { token = getToken(); } catch (error) { token = null; } return { isAuthenticated: !!token, }; }, }); export const initiate_authentication_tool = createTool({ id: "initiate_authentication", name: "Initiate Authentication", description: "Initiate the authentication process for the user", inputSchema: z.object({ email: z.string().email().describe("The email of the user"), }), outputSchema: z.object({ otpId: z .string() .describe("The OTP ID for the user, this need to be sent to verify_authentication tool"), }), execute: async ({ email }) => { const send = await api.post("/auth/send-otp", { email, }); return { otpId: send.data.id, }; }, }); export const verify_authentication_tool = createTool({ id: "verify_authentication", name: "Verify Authentication", description: "Verify the authentication for the user", inputSchema: z.object({ otpId: z.string().describe("The OTP ID for the user"), otp: z.string().describe("The OTP for the user"), }), outputSchema: z.object({ message: z.string(), }), execute: async ({ otpId, otp }) => { const verify = await api.post("/auth/verify-otp", { id: otpId, otp: otp, }); const token = verify.data.token; setToken(token); return { message: `Client authenticated successfully`, }; }, });