updateDomains
Manage allowlisted domains for a user by updating the list of approved domains for secure API access within the Pollinations Multimodal MCP Server.
Instructions
Update domains allowlisted for a user
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| domains | Yes | The domains to allowlist | |
| sessionId | Yes | The session ID for authentication | |
| userId | Yes | The GitHub user ID |
Implementation Reference
- src/services/authService.js:181-223 (handler)The primary handler function for the 'updateDomains' MCP tool. It performs input validation, sends a PUT request to the authentication API to update the user's allowlisted domains using JWT, handles errors, and returns an MCP-formatted response with the updated data.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:343-349 (schema)Zod schema defining the input parameters for the 'updateDomains' tool: userId (string), domains (array of strings), and accessToken (string). Used for validation during tool invocation.{ 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"), },
- src/services/authService.js:340-351 (registration)The registration entry for the 'updateDomains' tool within the authTools array. Includes the tool name, description (with Gen-Z instructions), input schema, and reference to the handler function. This array is later spread into the main toolDefinitions and registered with the MCP server.[ "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, ],