Skip to main content
Glama
SLdragon

MCP User Profile Management Server

by SLdragon

create_user_profile

Create new user profiles with interactive prompts to collect missing required information, ensuring complete and validated data entry.

Instructions

Create a new user profile with elicitation support for missing fields

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function that executes the create_user_profile tool: elicits missing user fields, validates, creates the user profile using UserService, and returns success/error response.
    async (inputs, context) => { try { let userData = { ...inputs }; const missingFields = UserService.getMissingFields(userData); if (missingFields.length > 0) { const { properties, required } = SchemaBuilder.buildUserSchema(missingFields); const elicitationResult = await elicitationHelper.elicitWithProgress( "Please provide your user profile information", { type: "object", properties, required }, inputs, ); if (elicitationResult.action === "accept" && elicitationResult.content) { Object.assign(userData, elicitationResult.content); } else if (elicitationResult.action === "decline") { return utils.createErrorResponse("User declined to provide profile information. No profile was created."); } else { return utils.createErrorResponse("User cancelled the profile creation process."); } } UserService.validateUser(userData); const newUser = UserService.createUser(userData); return utils.createSuccessResponse( `Successfully created user profile:\n${JSON.stringify(newUser, null, 2)}` ); } catch (error) { return utils.createErrorResponse(`Error creating user profile: ${error.message}`); } }
  • Defines the input schema/parameters for the create_user_profile tool based on USER_FIELD_SCHEMAS (name, email, age, role). Passed to server.tool.
    static getUserToolParams() { const toolParams = {}; for (const [key, schema] of Object.entries(this.USER_FIELD_SCHEMAS)) { toolParams[key] = { type: schema.type, description: schema.description, optional: true }; } return toolParams; }
  • index.js:16-16 (registration)
    Registers the create_user_profile tool on the MCP server by invoking createUserTool.
    createUserTool(server, elicitationHelper);
  • The createUserTool function that performs the server.tool registration for "create_user_profile".
    export function createUserTool(server, elicitationHelper) { return server.tool( "create_user_profile", "Create a new user profile with elicitation support for missing fields", SchemaBuilder.getUserToolParams(), async (inputs, context) => { try { let userData = { ...inputs }; const missingFields = UserService.getMissingFields(userData); if (missingFields.length > 0) { const { properties, required } = SchemaBuilder.buildUserSchema(missingFields); const elicitationResult = await elicitationHelper.elicitWithProgress( "Please provide your user profile information", { type: "object", properties, required }, inputs, ); if (elicitationResult.action === "accept" && elicitationResult.content) { Object.assign(userData, elicitationResult.content); } else if (elicitationResult.action === "decline") { return utils.createErrorResponse("User declined to provide profile information. No profile was created."); } else { return utils.createErrorResponse("User cancelled the profile creation process."); } } UserService.validateUser(userData); const newUser = UserService.createUser(userData); return utils.createSuccessResponse( `Successfully created user profile:\n${JSON.stringify(newUser, null, 2)}` ); } catch (error) { return utils.createErrorResponse(`Error creating user profile: ${error.message}`); } } ); }
  • UserService static methods: getMissingFields (used for elicitation), validateUser, and createUser (stores new user in storage). Called by the handler.
    export class UserService { static getMissingFields(inputs) { const { name, email, age, role } = inputs; const missing = []; if (!name) missing.push("name"); if (!email) missing.push("email"); if (age === undefined) missing.push("age"); if (!role) missing.push("role"); return missing; } static validateUser(user) { if (user.email && !utils.validateEmail(user.email)) { throw new Error("Invalid email format. Please provide a valid email address."); } } static createUser(userData) { const newUser = { id: utils.getNextId(storage.users), name: userData.name, email: userData.email, age: userData.age, role: userData.role }; storage.users.push(newUser); return newUser; } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/SLdragon/mcp-elicitation-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server