wecom_mcpis an MCP tool, and all operations are completed by calling this tool.
⚠️ Prerequisite: Before the first call to
wecom_mcp, you must perform the prerequisite check according to thewecom-preflightskill to ensure the tool has been added to the whitelist.
Through the MCP tool protocol-encapsulated get_userlist interface, retrieve contact members within the current user's visible scope, and filter and match locally by name/alias.
Operations
1. Retrieve all contact members
Retrieve information for all enterprise members within the current user's visible scope:
Call example:
Use the wecom_mcp tool to call wecom_mcp call contact get_userlist '{}'
Return format:
{
"errcode": 0,
"errmsg": "ok",
"userlist": [
{
"userid": "zhangsan",
"name": "张三",
"alias": "Sam"
},
{
"userid": "lisi",
"name": "李四",
"alias": ""
}
]
}
Returned field descriptions:
| Field | Type | Description |
|---|---|---|
errcode |
integer | Return code,0 indicates success |
errmsg |
string | Error message |
userlist |
array | User list |
userlist[].userid |
string | User unique ID |
userlist[].name |
string | User name |
userlist[].alias |
string | User alias, may be empty |
2. Search for personnel by name/alias
get_userlist After returning all members, filter and match the results locally:
- Exact match:
nameoraliasexactly matches the keyword, use it directly - Fuzzy match:
nameoraliascontains the keyword, return all matching results - No results: Inform the user that no corresponding personnel was found
Search example:
User asks: "Help me find out who Zhang San is?"
- Call
get_userlistto retrieve all members - In
userlist, filter fornameoraliasmembers containing "Zhang San" - Return matching results
Notes
-
get_userlistWhat is returned is the current user'svisible scopemembers, which must be filtered by visibility rules and are not necessarily all personnel in the entire company; the returned fields only includeuserid、name(name) andalias(alias) -
⚠️ The interface will report an error when there are more than 10 people: If
userlistreturns more than 10 members, it is considered abnormal, and processing should be stopped immediately and the user should be informed:The number of currently visible members in the contacts exceeds the upper limit supported by this skill (10 people). This skill is only suitable for scenarios with a small visible scope and cannot be used with a large-scope contacts list. It is recommended to narrow the visible scope and retry, or query the target personnel through other means.
-
useridis the user's unique identifier; use this field when the user ID needs to be passed to other interfaces -
aliasThe field may be an empty string, so null value checks are required when searching -
If the search results contain multiple people with the same name, all candidates must be shown to the user for selection, and you must not decide on your own
-
If
errcodeis not0, it indicates that the interface call failed, and the user must be informed of the error message (errmsg)
Typical Workflow
Workflow 1: Querying Personnel Information
User asks: "Help me find out who Sam is?"
-
Use
wecom_mcptool to callwecom_mcp call contact get_userlist '{}'to get the full member list -
Filter in the results the members whose
aliasisSamornamecontainsSammembers of -
If a unique match is found, display the result directly:
📇 找到成员:
- 姓名:张三
- 别名:Sam
- 用户ID:zhangsan
- If multiple matches are found, display the candidate list and ask the user to confirm:
🔍 找到多个匹配成员,请确认您要查询的是哪位:
1. 张三(别名:Sam,ID:zhangsan)
2. 张三丰(别名:Sam2,ID:zhangsan2)
请问您要查询的是哪一位?
Workflow 2: Providing userid conversion for other features
User asks: "Help me send a message to Zhang San"
-
Use
wecom_mcptool to callwecom_mcp call contact get_userlist '{}'to get all members -
Filter the members whose
nameis "Zhang San", confirm theuserid -
Pass the
useridto the message sending API
Workflow 3: Batch query multiple people
User asks: "Help me find out who Zhang San and Li Si are respectively?"
-
Use
wecom_mcptool to callwecom_mcp call contact get_userlist '{}'to get the full member list -
Filter the matching results for "Zhang San" and "Li Si" respectively
-
Summarize and display them together
Note: Only call
get_userlistonce, perform multiple local filters on the results, and avoid repeated API calls.
Quick Reference
API Description
| API | Purpose | Input | Return |
|---|---|---|---|
get_userlist |
Get all contacts members within the visible scope | None | User list (userid, name, alias) |
Local Filtering Strategy
| Scenario | Strategy |
|---|---|
| Exact match (name or alias exactly the same) | Use directly, no user confirmation needed |
| Fuzzy match (name or alias contains the keyword), unique result | Use directly, display the result to the user |
| Fuzzy match, multiple results | Display the candidate list and ask the user to choose |
| No matching result | Inform the user that no corresponding person was found |