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 registerOrganizationTools(
server: McpServer,
client: RipplingClient
): void {
server.tool(
"list_teams",
"List all teams with subteam relationships",
{},
async () => {
try {
const teams = await client.listTeams();
return {
content: [
{
type: "text",
text: JSON.stringify(teams, null, 2),
},
],
};
} catch (error) {
if (error instanceof RipplingApiError) return error.toToolResult();
throw error;
}
}
);
server.tool(
"list_levels",
"List position levels (e.g. Manager, Executive, Individual Contributor)",
{
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 levels = await client.listLevels({ limit, offset });
return {
content: [
{
type: "text",
text: JSON.stringify(levels, null, 2),
},
],
};
} catch (error) {
if (error instanceof RipplingApiError) return error.toToolResult();
throw error;
}
}
);
server.tool(
"list_custom_fields",
"List custom field definitions configured in Rippling",
{
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 fields = await client.listCustomFields({ limit, offset });
return {
content: [
{
type: "text",
text: JSON.stringify(fields, null, 2),
},
],
};
} catch (error) {
if (error instanceof RipplingApiError) return error.toToolResult();
throw error;
}
}
);
}