zendesk_get_organization
Fetch a Zendesk organization's details, including custom fields and tags, by providing its ID. Returns JSON with key fields for integration purposes.
Instructions
Fetch a Zendesk organization including its custom fields and tags. Returns JSON with id, name, organization_fields, tags, created_at, updated_at.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| organization_id | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- The MCP tool handler function 'zendesk_get_organization' that takes an organization_id (int) and returns JSON with id, name, organization_fields, tags, created_at, updated_at.
def zendesk_get_organization(organization_id: int) -> str: """Fetch a Zendesk organization including its custom fields and tags. Returns JSON with id, name, organization_fields, tags, created_at, updated_at.""" return _get_organization_data(organization_id) - Helper function '_get_organization_data' that performs the actual Zendesk API call using httpx to fetch organization data, handling errors and 404 cases.
def _get_organization_data(organization_id: int) -> str: try: subdomain, token = get_oauth_session() except ConfigError as e: return str(e) url = f"https://{subdomain}.zendesk.com/api/v2/organizations/{organization_id}.json" try: response = httpx.get(url, headers={"Authorization": f"Bearer {token}"}, timeout=30) response.raise_for_status() org = response.json().get("organization", {}) return json.dumps({ "id": org.get("id"), "name": org.get("name"), "organization_fields": org.get("organization_fields"), "tags": org.get("tags"), "created_at": org.get("created_at"), "updated_at": org.get("updated_at"), }, indent=2) except Exception as e: if "404" in str(e): return f"Organization #{organization_id} not found or not accessible with current credentials." return f"Zendesk API error: {e}" - src/zendesk_mcp/server.py:49-49 (registration)Registration of the organization tools via 'register_organization_tools(mcp)' call in the server's main() function.
register_organization_tools(mcp) - src/zendesk_mcp/server.py:29-29 (registration)Import of 'register_organization_tools' from the organizations module.
from zendesk_mcp.tools.organizations import register_organization_tools - The tool's input schema is defined by the function signature: organization_id (int). Output is a string (JSON). Type hints serve as implicit schema.
def zendesk_get_organization(organization_id: int) -> str: """Fetch a Zendesk organization including its custom fields and tags. Returns JSON with id, name, organization_fields, tags, created_at, updated_at.""" return _get_organization_data(organization_id)