@niondigital/moco-mcp
Version:
Model Context Protocol (MCP) server for MOCO: time tracking, project management, holidays, and presence monitoring
94 lines (93 loc) • 3.7 kB
TypeScript
/**
* MOCO API service client
* Handles all HTTP communication with the MOCO API including authentication,
* pagination, and error handling
*/
import type { Activity, Project, Task, UserHoliday, UserPresence } from '../types/mocoTypes.js';
/**
* HTTP client for MOCO API with automatic pagination and error handling
*/
export declare class MocoApiService {
private readonly config;
/**
* Default request headers for MOCO API
*/
private get defaultHeaders();
/**
* Makes an HTTP request to the MOCO API with error handling
* @param endpoint - API endpoint path (without base URL)
* @param params - Query parameters
* @returns Promise with parsed JSON response
*/
private makeRequest;
/**
* Makes an HTTP request to the MOCO API with headers for pagination
* @param endpoint - API endpoint path (without base URL)
* @param params - Query parameters
* @returns Promise with parsed JSON response and headers
*/
private makeRequestWithHeaders;
/**
* Fetches all pages of a paginated endpoint automatically using header-based pagination
* @param endpoint - API endpoint path
* @param params - Query parameters
* @returns Promise with all items from all pages
*/
private fetchAllPages;
/**
* Retrieves activities for the current user within a date range
* @param startDate - Start date in ISO 8601 format (YYYY-MM-DD)
* @param endDate - End date in ISO 8601 format (YYYY-MM-DD)
* @param projectId - Optional project ID to filter activities
* @returns Promise with array of activities
*/
getActivities(startDate: string, endDate: string, projectId?: number): Promise<Activity[]>;
/**
* Retrieves all projects assigned to the current user
* @returns Promise with array of assigned projects
*/
getProjects(): Promise<Project[]>;
/**
* Searches for projects by name or description
* @param query - Search query string
* @returns Promise with array of matching projects
*/
searchProjects(query: string): Promise<Project[]>;
/**
* Retrieves all tasks for a specific assigned project
* @param projectId - Project ID (must be assigned to current user)
* @returns Promise with array of tasks
*/
getProjectTasks(projectId: number): Promise<Task[]>;
/**
* Retrieves user holidays for a specific year
* @param year - Year (e.g., 2024)
* @returns Promise with array of user holidays
*/
getUserHolidays(year: number): Promise<UserHoliday[]>;
/**
* Retrieves actual taken holidays (absences) for a specific year using schedules endpoint
* @param year - Year (e.g., 2024)
* @returns Promise with array of taken holiday schedules
*/
getTakenHolidays(year: number): Promise<any[]>;
/**
* Retrieves actual taken sick days for a specific year using schedules endpoint
* @param year - Year (e.g., 2024)
* @returns Promise with array of taken sick day schedules
*/
getTakenSickDays(year: number): Promise<any[]>;
/**
* Retrieves public holidays for a specific year using schedules endpoint
* @param year - Year (e.g., 2024)
* @returns Promise with array of public holiday schedules
*/
getPublicHolidays(year: number): Promise<any[]>;
/**
* Retrieves user presences within a date range
* @param startDate - Start date in ISO 8601 format (YYYY-MM-DD)
* @param endDate - End date in ISO 8601 format (YYYY-MM-DD)
* @returns Promise with array of user presences
*/
getUserPresences(startDate: string, endDate: string): Promise<UserPresence[]>;
}