Skip to main content
Glama
SLdragon

MCP User Profile Management Server

by SLdragon

search_users

Find user profiles by entering search terms to locate specific individuals in the user management system.

Instructions

Search through user profiles using a simple text query

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function for the 'search_users' tool. It handles input query (with elicitation fallback), searches users in storage by name/email/role, and returns matching users or error messages.
      async (inputs, context) => {
        try {
          let searchQuery = inputs.query;
    
          if (!searchQuery) {
            const elicitationResult = await elicitationHelper.elicitWithProgress(
              "Please enter your search query to find users",
              {
                type: "object",
                properties: {
                  query: {
                    type: "string",
                    title: "Search Query",
                    description: "Enter keywords to search for users by name, email, or role"
                  }
                },
                required: ["query"]
              },
              inputs
            );
    
            if (elicitationResult.action === "accept" && elicitationResult.content?.query) {
              searchQuery = elicitationResult.content.query;
            } else if (elicitationResult.action === "decline") {
              return utils.createErrorResponse("User declined to provide search query. Search cancelled.");
            } else {
              return utils.createErrorResponse("User cancelled the search process.");
            }
          }
    
          const { storage } = await import('../storage.js');
          const query = searchQuery.toLowerCase();
          
          const matchingUsers = storage.users.filter(user => {
            return (
              user.name?.toLowerCase().includes(query) ||
              user.email?.toLowerCase().includes(query) ||
              user.role?.toLowerCase().includes(query)
            );
          });
    
          if (matchingUsers.length === 0) {
            return utils.createSuccessResponse(`No users found matching query: "${searchQuery}"`);
          }
    
          return utils.createSuccessResponse(
            `Found ${matchingUsers.length} user(s) matching "${searchQuery}":\n${JSON.stringify(matchingUsers, null, 2)}`
          );
        } catch (error) {
          return utils.createErrorResponse(`Error searching users: ${error.message}`);
        }
      }
    );
  • The primary input schema for the 'search_users' tool, defining a required 'query' string parameter.
    {
      type: "object",
      properties: {
        query: {
          type: "string",
          description: "Search query to find users by name, email, or role"
        }
      }
    },
  • The searchUsersTool function that registers the 'search_users' MCP tool on the server, including name, description, schema, and handler.
    export function searchUsersTool(server, elicitationHelper) {
      return server.tool(
        "search_users",
        "Search through user profiles using a simple text query",
        {
          type: "object",
          properties: {
            query: {
              type: "string",
              description: "Search query to find users by name, email, or role"
            }
          }
        },
        async (inputs, context) => {
          try {
            let searchQuery = inputs.query;
    
            if (!searchQuery) {
              const elicitationResult = await elicitationHelper.elicitWithProgress(
                "Please enter your search query to find users",
                {
                  type: "object",
                  properties: {
                    query: {
                      type: "string",
                      title: "Search Query",
                      description: "Enter keywords to search for users by name, email, or role"
                    }
                  },
                  required: ["query"]
                },
                inputs
              );
    
              if (elicitationResult.action === "accept" && elicitationResult.content?.query) {
                searchQuery = elicitationResult.content.query;
              } else if (elicitationResult.action === "decline") {
                return utils.createErrorResponse("User declined to provide search query. Search cancelled.");
              } else {
                return utils.createErrorResponse("User cancelled the search process.");
              }
            }
    
            const { storage } = await import('../storage.js');
            const query = searchQuery.toLowerCase();
            
            const matchingUsers = storage.users.filter(user => {
              return (
                user.name?.toLowerCase().includes(query) ||
                user.email?.toLowerCase().includes(query) ||
                user.role?.toLowerCase().includes(query)
              );
            });
    
            if (matchingUsers.length === 0) {
              return utils.createSuccessResponse(`No users found matching query: "${searchQuery}"`);
            }
    
            return utils.createSuccessResponse(
              `Found ${matchingUsers.length} user(s) matching "${searchQuery}":\n${JSON.stringify(matchingUsers, null, 2)}`
            );
          } catch (error) {
            return utils.createErrorResponse(`Error searching users: ${error.message}`);
          }
        }
      );
    }
  • index.js:18-18 (registration)
    Invocation of searchUsersTool to register the 'search_users' tool during server setup.
    searchUsersTool(server, elicitationHelper);
  • index.js:5-5 (helper)
    Import of the searchUsersTool registration helper from userTools.js.
    import { createUserTool, listUsersTool, searchUsersTool } from './tools/userTools.js';
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool searches user profiles, implying a read-only operation, but doesn't cover aspects like search scope, result format, pagination, or error handling, leaving significant gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence with no wasted words, making it efficient and easy to understand. It front-loads the key action and resource without unnecessary details.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete. It doesn't explain what the search returns, how results are structured, or any limitations, which is inadequate for a tool that likely returns data.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0 parameters with 100% coverage, so no parameter information is needed. The description adds value by mentioning a 'simple text query', which implies a search functionality beyond what the empty schema indicates, justifying a baseline score above 3.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('search') and resource ('user profiles'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'list_users', which might also retrieve user information but potentially with different mechanisms or scope.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives such as 'list_users'. It mentions a 'simple text query' but doesn't specify contexts where this is preferred over other tools or any exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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