UNPKG

lattice-hq-mcp-server

Version:

MCP Server for Lattice HQ API - Access goals, users, reviews, and feedback

99 lines (98 loc) 3.37 kB
const LATTICE_API_URL = process.env.LATTICE_API_URL; export class LatticeClient { constructor(apiToken) { this.apiToken = apiToken || process.env.LATTICE_API_TOKEN || ''; if (!this.apiToken) { throw new Error("LATTICE_API_TOKEN is required"); } } async makeRequest(endpoint, options = {}) { if (!LATTICE_API_URL) { throw new Error("LATTICE_API_URL environment variable is required"); } const url = `${LATTICE_API_URL}${endpoint}`; const response = await fetch(url, { ...options, headers: { "Authorization": `Bearer ${this.apiToken}`, "Content-Type": "application/json", ...options.headers, }, }); if (!response.ok) { throw new Error(`Lattice API error: ${response.status} ${response.statusText}`); } return response.json(); } // User operations async getUsers() { const response = await this.makeRequest("/v1/users"); return response.data; } async getUser(userId) { const response = await this.makeRequest(`/v1/user/${userId}`); return response.data; } async getUserDirectReports(userId) { const response = await this.makeRequest(`/v1/user/${userId}/directReports`); return response.data; } // Goal operations async getGoals() { const response = await this.makeRequest("/v1/goals"); return response.data; } async getGoal(goalId) { const response = await this.makeRequest(`/v1/goal/${goalId}`); return response.data; } async getUserGoals(userId) { const response = await this.makeRequest(`/v1/user/${userId}/goals`); return response.data; } // Review Cycle operations async getReviewCycles() { const response = await this.makeRequest("/v1/reviewCycles"); return response.data; } async getReviewCycle(cycleId) { const response = await this.makeRequest(`/v1/reviewCycle/${cycleId}`); return response.data; } async getReviewCycleReviewees(cycleId) { const response = await this.makeRequest(`/v1/reviewCycle/${cycleId}/reviewees`); return response.data; } // Feedback operations async getFeedbacks() { const response = await this.makeRequest("/v1/feedbacks"); return response.data; } async getFeedback(feedbackId) { const response = await this.makeRequest(`/v1/feedback/${feedbackId}`); return response.data; } // Department operations async getDepartments() { const response = await this.makeRequest("/v1/departments"); return response.data; } async getDepartment(departmentId) { const response = await this.makeRequest(`/v1/department/${departmentId}`); return response.data; } // Updates operations async getUpdates() { const response = await this.makeRequest("/v1/updates"); return response.data; } async getUpdate(updateId) { const response = await this.makeRequest(`/v1/update/${updateId}`); return response.data; } // Get current user async getMe() { const response = await this.makeRequest("/v1/me"); return response.data; } }