zendesk_get_view
Retrieve a Zendesk view's filter conditions, execution settings, and metadata, returned as structured JSON.
Instructions
Get a Zendesk view's definition including filter conditions and execution settings. Returns JSON with id, title, active, conditions, execution.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| view_id | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/zendesk_mcp/tools/views.py:71-74 (handler)The handler function `zendesk_get_view` (decorated with @mcp.tool()) that serves as the MCP tool entry point. It takes a view_id (int) and returns a JSON string by calling _get_view_data.
@mcp.tool() def zendesk_get_view(view_id: int) -> str: """Get a Zendesk view's definition including filter conditions and execution settings. Returns JSON with id, title, active, conditions, execution.""" return _get_view_data(view_id) - src/zendesk_mcp/tools/views.py:17-37 (helper)The helper function `_get_view_data` that performs the actual Zendesk API call via httpx GET to fetch view definition (id, title, active, conditions, execution).
def _get_view_data(view_id: int) -> str: try: subdomain, token = get_oauth_session() except ConfigError as e: return str(e) url = f"https://{subdomain}.zendesk.com/api/v2/views/{view_id}.json" try: response = httpx.get(url, headers={"Authorization": f"Bearer {token}"}, timeout=30) response.raise_for_status() view = response.json().get("view", {}) return json.dumps({ "id": view.get("id"), "title": view.get("title"), "active": view.get("active"), "conditions": view.get("conditions"), "execution": view.get("execution"), }, indent=2) except Exception as e: if "404" in str(e): return f"View #{view_id} not found or not accessible with current credentials." return f"Zendesk API error: {e}" - src/zendesk_mcp/tools/views.py:65-79 (registration)The `register_view_tools` function that registers all three view tools (list, get, get_tickets) with the MCP server via @mcp.tool() decorators.
def register_view_tools(mcp) -> None: @mcp.tool() def zendesk_list_views() -> str: """List all active Zendesk views. Returns JSON array of {id, title}.""" return _list_views_data() @mcp.tool() def zendesk_get_view(view_id: int) -> str: """Get a Zendesk view's definition including filter conditions and execution settings. Returns JSON with id, title, active, conditions, execution.""" return _get_view_data(view_id) @mcp.tool() def zendesk_get_view_tickets(view_id: int) -> str: """Get the tickets currently matching a Zendesk view. Returns JSON array of tickets with essential fields.""" return _get_view_tickets_data(view_id) - src/zendesk_mcp/server.py:25-25 (registration)Import of register_view_tools from views.py into the main server.
from zendesk_mcp.tools.views import register_view_tools - src/zendesk_mcp/server.py:45-45 (registration)Registration call `register_view_tools(mcp)` in the main server's main() function.
register_view_tools(mcp)