updateDomains
Modify allowlisted domains for user access control in the Pollinations Multimodal MCP Server to manage permitted content generation sources.
Instructions
Update domains allowlisted for a user
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| userId | Yes | The GitHub user ID | |
| domains | Yes | The domains to allowlist | |
| sessionId | Yes | The session ID for authentication |
Implementation Reference
- src/services/authService.js:181-223 (handler)The main handler function for the 'updateDomains' tool. Validates inputs, makes a PUT request to the auth API to update the user's allowlisted domains using the provided JWT access token, and returns the response in MCP format.async function updateDomains(params) { const { userId, domains, accessToken } = params; if (!userId || typeof userId !== "string") { throw new Error("User ID is required and must be a string"); } if (!Array.isArray(domains)) { throw new Error("Domains must be an array of strings"); } if (!accessToken || typeof accessToken !== "string") { throw new Error("Access token is required and must be a string"); } try { // Call the auth.pollinations.ai domains endpoint with JWT const response = await fetch( `${AUTH_API_BASE_URL}/api/user/${userId}/domains`, { method: "PUT", headers: { "Content-Type": "application/json", Authorization: `Bearer ${accessToken}`, }, body: JSON.stringify({ domains }), }, ); if (!response.ok) { throw new Error(`Failed to update domains: ${response.statusText}`); } // Get the updated domains data const updatedData = await response.json(); // Return the response in MCP format return createMCPResponse([createTextContent(updatedData, true)]); } catch (error) { console.error("Error updating domains:", error); throw error; } }
- src/services/authService.js:340-351 (registration)Registration of the 'updateDomains' tool in the authTools export array, including the tool name, description, Zod input schema for validation, and reference to the handler function.[ "updateDomains", "Update domains allowlisted for a user using JWT authentication", { userId: z.string().describe("The GitHub user ID"), domains: z.array(z.string()).describe("The domains to allowlist"), accessToken: z .string() .describe("The JWT access token from exchangeToken"), }, updateDomains, ],