dual_count_objects
Count objects matching specific filter criteria in the DUAL Web3 Operating System without retrieving full object data.
Instructions
Count objects matching filter criteria without returning the full objects.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filter | Yes | Filter criteria (same as search) |
Implementation Reference
- src/tools/objects.ts:112-124 (handler)The 'dual_count_objects' tool registration and handler. Makes a POST request to 'objects/count' API endpoint with filter criteria, returns the count of matching objects.
server.registerTool("dual_count_objects", { title: "Count Objects", description: "Count objects matching filter criteria without returning the full objects.", inputSchema: { filter: z.record(z.unknown()).describe("Filter criteria (same as search)"), }, annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true }, }, async (params) => { try { const res = await makeApiRequest<{ count: number }>("objects/count", "POST", params); return textResult(`Count: ${res.count}`); } catch (e) { return errorResult(handleApiError(e)); } }); - src/tools/objects.ts:115-117 (schema)Input schema for dual_count_objects tool - accepts a 'filter' parameter as a record of key-value pairs for filtering criteria.
inputSchema: { filter: z.record(z.unknown()).describe("Filter criteria (same as search)"), }, - src/services/api-client.ts:40-62 (helper)makeApiRequest helper function that performs the actual HTTP request to the DUAL API. Handles authentication headers, timeout, and returns typed response data.
export async function makeApiRequest<T>( endpoint: string, method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" = "GET", data?: unknown, params?: Record<string, unknown>, options?: { timeout?: number; multipart?: boolean } ): Promise<T> { const config: AxiosRequestConfig = { method, url: `${API_BASE_URL}/${endpoint}`, headers: getAuthHeaders(), timeout: options?.timeout ?? 30000, }; if (data !== undefined) config.data = data; if (params) config.params = params; if (options?.multipart) { config.headers = { ...config.headers, "Content-Type": "multipart/form-data" }; } const response = await axios(config); return response.data as T; } - src/services/formatters.ts:39-46 (helper)textResult and errorResult helper functions that format the MCP tool response content in the standard format.
export function textResult(text: string) { return { content: [{ type: "text" as const, text }] }; } /** Standard error content response */ export function errorResult(text: string) { return { content: [{ type: "text" as const, text }], isError: true as const }; }