Skip to main content
Glama

search_users

Search and filter users by keyword or role on the MCP Test Server to manage user data efficiently for testing and analysis purposes.

Instructions

搜索用户

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes搜索关键词
roleNo按角色筛选

Implementation Reference

  • The asynchronous handler function for the 'search_users' tool. It filters the testData.users array based on the query string matching name or email, optionally filters by role, logs the search, and returns a formatted text response with results.
    }, async (args) => { const { query, role } = args; let results = testData.users.filter(user => user.name.includes(query) || user.email.includes(query) ); if (role) { results = results.filter(user => user.role === role); } testData.logs.push(`搜索用户: "${query}" ${role ? `(角色: ${role})` : ""}`); return { content: [{ type: "text", text: `🔍 搜索结果 (${results.length}个):\n${JSON.stringify(results, null, 2)}` }] }; });
  • Zod input schema for 'search_users' tool: required 'query' (string), optional 'role' (enum: 'admin' or 'user').
    query: z.string().describe("搜索关键词"), role: z.enum(["admin", "user"]).optional().describe("按角色筛选")
  • src/index.ts:121-142 (registration)
    Registration of the 'search_users' tool using McpServer.tool(), specifying name, description (Chinese: '搜索用户'), input schema, and inline handler function.
    server.tool("search_users", "搜索用户", { query: z.string().describe("搜索关键词"), role: z.enum(["admin", "user"]).optional().describe("按角色筛选") }, async (args) => { const { query, role } = args; let results = testData.users.filter(user => user.name.includes(query) || user.email.includes(query) ); if (role) { results = results.filter(user => user.role === role); } testData.logs.push(`搜索用户: "${query}" ${role ? `(角色: ${role})` : ""}`); return { content: [{ type: "text", text: `🔍 搜索结果 (${results.length}个):\n${JSON.stringify(results, null, 2)}` }] }; });

Other Tools

Related 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/small-tou/mcp-test'

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