Skip to main content
Glama
effytech

Freshdesk MCP server

by effytech

list_companies

Retrieve and paginate through all companies stored in Freshdesk to streamline company data management and support operations.

Instructions

List all companies in Freshdesk with pagination support.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageNo
per_pageNo

Implementation Reference

  • The primary handler function for the 'list_companies' MCP tool. It is decorated with @mcp.tool(), which both defines and registers the tool. Fetches companies from the Freshdesk API endpoint /api/v2/companies with pagination, validation, error handling, and pagination parsing.
    async def list_companies(page: Optional[int] = 1, per_page: Optional[int] = 30) -> Dict[str, Any]:
        """List all companies in Freshdesk with pagination support."""
        # Validate input parameters
        if page < 1:
            return {"error": "Page number must be greater than 0"}
    
        if per_page < 1 or per_page > 100:
            return {"error": "Page size must be between 1 and 100"}
    
        url = f"https://{FRESHDESK_DOMAIN}/api/v2/companies"
    
        params = {
            "page": page,
            "per_page": per_page
        }
    
        headers = {
            "Authorization": f"Basic {base64.b64encode(f'{FRESHDESK_API_KEY}:X'.encode()).decode()}",
            "Content-Type": "application/json"
        }
    
        async with httpx.AsyncClient() as client:
            try:
                response = await client.get(url, headers=headers, params=params)
                response.raise_for_status()
    
                # Parse pagination from Link header
                link_header = response.headers.get('Link', '')
                pagination_info = parse_link_header(link_header)
    
                companies = response.json()
    
                return {
                    "companies": companies,
                    "pagination": {
                        "current_page": page,
                        "next_page": pagination_info.get("next"),
                        "prev_page": pagination_info.get("prev"),
                        "per_page": per_page
                    }
                }
    
            except httpx.HTTPStatusError as e:
                return {"error": f"Failed to fetch companies: {str(e)}"}
            except Exception as e:
                return {"error": f"An unexpected error occurred: {str(e)}"}
  • Utility helper function used by list_companies (and others) to parse the HTTP Link header for pagination information (next/prev pages). Called within the handler to enrich the response with pagination metadata.
    def parse_link_header(link_header: str) -> Dict[str, Optional[int]]:
        """Parse the Link header to extract pagination information.
    
        Args:
            link_header: The Link header string from the response
    
        Returns:
            Dictionary containing next and prev page numbers
        """
        pagination = {
            "next": None,
            "prev": None
        }
    
        if not link_header:
            return pagination
    
        # Split multiple links if present
        links = link_header.split(',')
    
        for link in links:
            # Extract URL and rel
            match = re.search(r'<(.+?)>;\s*rel="(.+?)"', link)
            if match:
                url, rel = match.groups()
                # Extract page number from URL
                page_match = re.search(r'page=(\d+)', url)
                if page_match:
                    page_num = int(page_match.group(1))
                    pagination[rel] = page_num
    
        return pagination
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'pagination support' which is valuable context beyond basic functionality, but doesn't describe authentication requirements, rate limits, error conditions, or what the return format looks like. For a list operation with zero annotation coverage, this leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core functionality ('List all companies in Freshdesk') and adds the key behavioral detail ('with pagination support'). Every word earns its place with zero waste or redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (list operation with pagination), no annotations, no output schema, and 0% schema description coverage, the description is minimally adequate. It covers the basic purpose and pagination behavior but lacks details about authentication, rate limits, error handling, and return format that would be helpful for an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate for undocumented parameters. The description mentions 'pagination support' which hints at the purpose of the two parameters (page and per_page), but doesn't explain their specific semantics, defaults, or constraints. It adds some value but doesn't fully compensate for the coverage gap.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('List') and resource ('all companies in Freshdesk'), making the purpose unambiguous. It distinguishes from sibling 'find_company_by_name' and 'search_companies' by specifying 'all companies' without filtering. However, it doesn't explicitly differentiate from 'view_company' which appears to be a single-item view tool.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for retrieving all companies with pagination, suggesting it's for bulk retrieval rather than filtered searches. However, it doesn't explicitly state when to use this versus 'search_companies' or 'find_company_by_name', nor does it mention any prerequisites or exclusions. The guidance is implied rather than explicit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/effytech/freshdesk_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server