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
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get_services"
}
}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/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; }