get_services
List services with account previews, filterable by keyword, with pagination and sorting options.
Instructions
Return a list of services, along with the preview of the accounts. Can be searched by the service name by keyword
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| cursor | No | ||
| keyword | No | ||
| sortBy | No | ||
| sortOrder | No |
Implementation Reference
- src/tools/getServices.ts:1-19 (handler)Main handler function 'getServices' that makes an API call to '/services' with parsed query filters. Also contains the 'ServiceFiltersSchema' Zod schema for input validation.
import { z } from "zod"; import { getClient } from "../admina-api.js"; import { filtersToParams } from "../common/helper.js"; export const ServiceFiltersSchema = z.object({ limit: z.number().optional(), cursor: z.string().optional(), keyword: z.string().optional(), sortBy: z.string().optional(), sortOrder: z.string().optional(), }); export type ServiceFilters = z.infer<typeof ServiceFiltersSchema>; export async function getServices(filters: ServiceFilters) { const client = getClient(); const queryParams = filtersToParams(filters); return client.makeApiCall("/services", queryParams); } - src/tools/getServices.ts:5-11 (schema)Input schema 'ServiceFiltersSchema' defining optional fields: limit, cursor, keyword, sortBy, sortOrder.
export const ServiceFiltersSchema = z.object({ limit: z.number().optional(), cursor: z.string().optional(), keyword: z.string().optional(), sortBy: z.string().optional(), sortOrder: z.string().optional(), }); - src/index.ts:189-193 (registration)Tool registration in the ListToolsRequestSchema handler where 'get_services' is defined with name, description, and inputSchema.
name: "get_services", description: "Return a list of services, along with the preview of the accounts. Can be searched by the service name by keyword", inputSchema: zodToJsonSchema(ServiceFiltersSchema), }, - src/index.ts:312-312 (registration)Tool handler mapping in the toolHandlers record, routing 'get_services' to the getServices function with schema parsing.
get_services: async (input) => getServices(ServiceFiltersSchema.parse(input)), - src/common/helper.ts:1-19 (helper)Helper function 'filtersToParams' used by getServices to convert filter objects to URLSearchParams for the API call.
export function filtersToParams(filters: Record<string, any>): URLSearchParams { const queryParams = new URLSearchParams(); Object.entries(filters).forEach(([key, value]) => { if (value !== undefined && value !== null && !(Array.isArray(value) && value.length === 0)) { if (Array.isArray(value) && value.length > 0) { // Append each array value separately to generate format: key=value1&key=value2 value.forEach((item) => { queryParams.append(key, String(item)); }); } else if (typeof value === "boolean") { queryParams.append(key, value.toString()); } else { queryParams.append(key, String(value)); } } }); return queryParams; }