import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";
import { RipplingClient } from "../clients/rippling-client.js";
import { RipplingApiError } from "../utils/errors.js";
export function registerCompanyTools(
server: McpServer,
client: RipplingClient
): void {
server.tool(
"get_company",
"Get current company details including name, address, and locations",
{},
async () => {
try {
const company = await client.getCompany();
return {
content: [
{
type: "text",
text: JSON.stringify(company, null, 2),
},
],
};
} catch (error) {
if (error instanceof RipplingApiError) return error.toToolResult();
throw error;
}
}
);
server.tool(
"list_departments",
"List all departments in the organization with hierarchical structure",
{
limit: z
.number()
.min(1)
.max(100)
.optional()
.describe("Max results per page (1-100, default 50)"),
offset: z
.number()
.min(0)
.optional()
.describe("Pagination offset (default 0)"),
},
async ({ limit, offset }) => {
try {
const departments = await client.listDepartments({ limit, offset });
return {
content: [
{
type: "text",
text: JSON.stringify(departments, null, 2),
},
],
};
} catch (error) {
if (error instanceof RipplingApiError) return error.toToolResult();
throw error;
}
}
);
server.tool(
"list_work_locations",
"List all work locations with addresses",
{},
async () => {
try {
const locations = await client.listWorkLocations();
return {
content: [
{
type: "text",
text: JSON.stringify(locations, null, 2),
},
],
};
} catch (error) {
if (error instanceof RipplingApiError) return error.toToolResult();
throw error;
}
}
);
}