import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";
import { apiRequest, formatResponse, textContent } from "../api-client.js";
interface MobileApp {
id: number;
name: string;
bundle_id: string;
legacy_id?: number | null;
platform?: string;
active?: boolean;
store_url?: string | null;
description?: string | null;
author?: string | null;
sensor_tower_app_id?: string | null;
valid_countries?: string[] | null;
top_countries?: string[] | null;
recent_campaign_created_at?: string | null;
client?: { id: number; name: string; legacy_id?: number | null };
main_category?: { id: number; name: string } | null;
track_party?: { id: number; name: string } | null;
created_at?: string;
updated_at?: string;
}
export function registerMobileAppTools(server: McpServer) {
// List mobile apps
server.tool(
"list_mobile_apps",
"List mobile apps with optional filters.",
{
search: z.string().optional().describe("Filter mobile apps whose name contains this substring"),
client_id: z.number().optional().describe("Filter by client ID"),
track_party_id: z.number().optional().describe("Filter by tracking party ID (e.g., Adjust, Appsflyer)"),
},
async ({ search, client_id, track_party_id }) => {
const response = await apiRequest<MobileApp[]>("/mobile_apps.json", {
search,
client_id,
track_party_id,
});
if (response.error) {
return textContent(`Error: ${response.error}`);
}
return textContent(formatResponse(response));
}
);
// Get mobile app details
server.tool(
"get_mobile_app",
"Get detailed information about a specific mobile app by ID.",
{
id: z.number().describe("The mobile app ID"),
},
async ({ id }) => {
const response = await apiRequest<MobileApp>(`/mobile_apps/${id}.json`);
if (response.error) {
return textContent(`Error: ${response.error}`);
}
return textContent(formatResponse(response));
}
);
}