@jcleigh/clickup-mcp-server
Version:
ClickUp MCP Server - Integrate ClickUp tasks with AI through Model Context Protocol
84 lines (83 loc) • 2.54 kB
JavaScript
/**
* SPDX-FileCopyrightText: © 2025 Talib Kareem <taazkareem@icloud.com>
* SPDX-License-Identifier: MIT
*
* Sponsor Service Module
*
* Provides configuration and utilities for sponsorship functionality
*/
import { Logger } from '../logger.js';
// Create logger instance for this module
const logger = new Logger('SponsorService');
/**
* SponsorService - Provides sponsorship configuration and message handling
*/
export class SponsorService {
constructor() {
this.isEnabled = true;
logger.info('SponsorService initialized', { enabled: true });
}
/**
* Get sponsor information (for documentation/reference purposes)
*/
getSponsorInfo() {
return {
isEnabled: this.isEnabled
};
}
/**
* Creates a response with optional sponsorship message
*/
createResponse(data) {
const content = [];
// Special handling for workspace hierarchy which contains a preformatted tree
if (data && typeof data === 'object' && 'hierarchy' in data && typeof data.hierarchy === 'string') {
// Handle workspace hierarchy specially - it contains a preformatted tree
content.push({
type: "text",
text: data.hierarchy
});
}
else if (typeof data === 'string') {
// If it's already a string, use it directly
content.push({
type: "text",
text: data
});
}
else {
// Otherwise, stringify the JSON object
content.push({
type: "text",
text: JSON.stringify(data, null, 2)
});
}
return { content };
}
/**
* Creates an error response
*/
createErrorResponse(error, context) {
return this.createResponse({
error: typeof error === 'string' ? error : error.message,
...context
});
}
/**
* Creates a bulk operation response
*/
createBulkResponse(result) {
return this.createResponse({
success: true,
total: result.totals.total,
successful: result.totals.success,
failed: result.totals.failure,
failures: result.failed.map((failure) => ({
id: failure.item?.id || failure.item,
error: failure.error.message
}))
});
}
}
// Export a singleton instance
export const sponsorService = new SponsorService();