get_team_members
Retrieve team membership rosters to identify members, administrators, and team composition for project management and user assignment tracking in Azure DevOps.
Instructions
Retrieves the membership roster for a specific team.
Use this tool when you need to:
- See who belongs to a particular team
- Find team administrators
- Check user assignments across teams
- Determine team size and composition
Args:
project_id: The name or ID (GUID) of the team project the team
belongs to
team_id: The name or ID (GUID) of the team
top: Maximum number of members to return
skip: Number of members to skip
Returns:
Formatted string containing team members information including
display names, emails, IDs, and administrator status, formatted
as markdown with each member clearly separated
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | ||
| team_id | Yes | ||
| top | No | ||
| skip | No |
Implementation Reference
- The MCP tool handler function decorated with @mcp.tool(). Handles tool invocation, retrieves Azure DevOps CoreClient, and calls the core implementation.def get_team_members( project_id: str, team_id: str, top: Optional[int] = None, skip: Optional[int] = None ) -> str: """ Retrieves the membership roster for a specific team. Use this tool when you need to: - See who belongs to a particular team - Find team administrators - Check user assignments across teams - Determine team size and composition Args: project_id: The name or ID (GUID) of the team project the team belongs to team_id: The name or ID (GUID) of the team top: Maximum number of members to return skip: Number of members to skip Returns: Formatted string containing team members information including display names, emails, IDs, and administrator status, formatted as markdown with each member clearly separated """ try: core_client = get_core_client() return _get_team_members_impl( core_client, project_id, team_id, top, skip ) except AzureDevOpsClientError as e: return f"Error: {str(e)}"
- Core implementation that calls the Azure DevOps API to get team members with extended properties and formats the results using _format_team_member.def _get_team_members_impl( core_client: CoreClient, project_id: str, team_id: str, top: Optional[int] = None, skip: Optional[int] = None ) -> str: """ Implementation of team members retrieval. Args: core_client: Core client project_id: The name or ID (GUID) of the team project the team belongs to team_id: The name or ID (GUID) of the team top: Maximum number of members to return skip: Number of members to skip Returns: Formatted string containing team members information """ try: team_members = core_client.get_team_members_with_extended_properties( project_id=project_id, team_id=team_id, top=top, skip=skip ) if not team_members: return (f"No members found for team {team_id} in " f"project {project_id}.") formatted_members = [] for member in team_members: formatted_members.append(_format_team_member(member)) return "\n\n".join(formatted_members) except Exception as e: return f"Error retrieving team members: {str(e)}"
- Helper function that formats a single team member's details including identity info and admin status.def _format_team_member(team_member) -> str: """ Format team member information. Args: team_member: Team member object to format Returns: String with team member details """ formatted_info = [] # Get identity information if hasattr(team_member, "identity") and team_member.identity: identity = team_member.identity # Use display name if available, otherwise use ID if hasattr(identity, "display_name") and identity.display_name: formatted_info.append(f"# Member: {identity.display_name}") else: formatted_info.append(f"# Member ID: {identity.id}") # Add ID if hasattr(identity, "id") and identity.id: formatted_info.append(f"ID: {identity.id}") # Add descriptor if hasattr(identity, "descriptor") and identity.descriptor: formatted_info.append(f"Descriptor: {identity.descriptor}") # Add unique name (email/username) if hasattr(identity, "unique_name") and identity.unique_name: formatted_info.append(f"Email/Username: {identity.unique_name}") else: formatted_info.append("# Unknown Member") # Add team admin status if hasattr(team_member, "is_team_admin"): is_admin = "Yes" if team_member.is_team_admin else "No" formatted_info.append(f"Team Administrator: {is_admin}") return "\n".join(formatted_info)
- src/mcp_azure_devops/features/teams/__init__.py:5-13 (registration)Registration entry point for teams feature that invokes tools.register_tools(mcp), which defines and registers the get_team_members tool.def register(mcp): """ Register all teams components with the MCP server. Args: mcp: The FastMCP server instance """ tools.register_tools(mcp)