list_workspace_users
Search and list users in your Google Workspace directory by name or email. Retrieve email addresses and other user details with optional filters and result limits for better organization management.
Instructions
List Google Workspace users in your organization's directory.
This tool allows you to search and list users in your Google Workspace directory,
including their email addresses and other information.
Args:
query: Optional search term to find specific users (name, email, etc.)
max_results: Maximum number of results to return (default: 50)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| max_results | No | ||
| query | No |
Input Schema (JSON Schema)
{
"properties": {
"max_results": {
"default": 50,
"title": "Max Results",
"type": "integer"
},
"query": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Query"
}
},
"title": "list_workspace_usersArguments",
"type": "object"
}
Implementation Reference
- The handler function for the 'list_workspace_users' tool. It initializes the Google Contacts service, calls list_directory_people on it with the provided query and max_results, formats the results using format_directory_people, and returns the formatted string or an error message. The @mcp.tool() decorator registers it as an MCP tool.@mcp.tool() async def list_workspace_users(query: Optional[str] = None, max_results: int = 50) -> str: """List Google Workspace users in your organization's directory. This tool allows you to search and list users in your Google Workspace directory, including their email addresses and other information. Args: query: Optional search term to find specific users (name, email, etc.) max_results: Maximum number of results to return (default: 50) """ service = init_service() if not service: return "Error: Google Contacts service is not available. Please check your credentials." try: workspace_users = service.list_directory_people(query=query, max_results=max_results) return format_directory_people(workspace_users, query) except Exception as e: return f"Error: Failed to list Google Workspace users - {str(e)}"
- mcp_google_contacts_server/main.py:84-84 (registration)Call to register_tools(mcp) in the main server initialization, which registers all tools including list_workspace_users.register_tools(mcp)