get_work_item_template
Retrieve detailed work item templates from Azure DevOps to view default field values and understand pre-populated content for consistent project tracking.
Instructions
Gets detailed information about a specific work item template.
Use this tool when you need to:
- View default field values in a template
- Understand what a template pre-populates in a work item
- Get complete details about a template
Args:
team_context: Dictionary containing team information with keys:
project: Project name (Optional if project_id is provided)
project_id: Project ID (Optional if project is provided)
team: Team name (Optional if team_id is provided)
team_id: Team ID (Optional if team is provided)
template_id: The ID of the template
Returns:
Detailed information about the template including default field
values
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| team_context | Yes | ||
| template_id | Yes |
Implementation Reference
- Primary MCP tool handler for get_work_item_template. Registers the tool via @mcp.tool() decorator and implements the core logic by calling the helper implementation.@mcp.tool() def get_work_item_template(team_context: dict, template_id: str) -> str: """ Gets detailed information about a specific work item template. Use this tool when you need to: - View default field values in a template - Understand what a template pre-populates in a work item - Get complete details about a template Args: team_context: Dictionary containing team information with keys: project: Project name (Optional if project_id is provided) project_id: Project ID (Optional if project is provided) team: Team name (Optional if team_id is provided) team_id: Team ID (Optional if team is provided) template_id: The ID of the template Returns: Detailed information about the template including default field values """ try: wit_client = get_work_item_client() return _get_work_item_template_impl( team_context, template_id, wit_client) except AzureDevOpsClientError as e: return f"Error: {str(e)}"
- Core implementation logic that fetches the template using Azure DevOps WorkItemTrackingClient and formats it using _format_work_item_template.def _get_work_item_template_impl(team_context: dict, template_id: str, wit_client: WorkItemTrackingClient) -> str: """Implementation of work item template detail retrieval.""" try: team_ctx = _create_team_context(team_context) template = wit_client.get_template(team_ctx, template_id) if not template: return f"Template with ID '{template_id}' not found." return _format_work_item_template(template) except Exception as e: return f"Error retrieving template '{template_id}': {str(e)}"
- Helper function to format the retrieved template data into a readable markdown string.def _format_work_item_template(template): """Format work item template data for display.""" result = [f"# Template: {template.name}"] for attr in ["description", "work_item_type_name", "id"]: value = getattr(template, attr, None) if value: result.append(f"{attr.replace('_', ' ').capitalize()}: {value}") fields = getattr(template, "fields", None) if fields: result.append("\n## Default Field Values") for field, value in fields.items(): result.append(f"- {field}: {value}") return "\n".join(result)
- Registration call for the templates module, which defines and registers the get_work_item_template tool.templates.register_tools(mcp)
- src/mcp_azure_devops/features/work_items/__init__.py:12-12 (registration)Top-level registration call for all work_items tools, invoking the tools/__init__.py register_tools which includes templates.tools.register_tools(mcp)