import { Injectable } from '@nestjs/common';
import { Resource } from '@rekog/mcp-nest';
import { GammaApiService, Theme } from './gamma-api.service';
@Injectable()
export class ThemesResource {
constructor(private readonly gammaApi: GammaApiService) {}
@Resource({
uri: 'gamma://themes',
name: 'Gamma Themes',
description: 'List all themes available for Gamma generation',
mimeType: 'application/json',
})
async listThemes() {
try {
const allThemes: Theme[] = [];
let cursor: string | null = null;
let hasMore = true;
// Fetch all pages
while (hasMore) {
const response = await this.gammaApi.listThemes({
limit: 50, // API max limit is 50
after: cursor || undefined,
});
allThemes.push(...response.data);
hasMore = response.hasMore;
cursor = response.nextCursor;
}
return {
themes: allThemes,
total: allThemes.length,
};
} catch (error: any) {
throw new Error(
error.response?.data?.message || error.message || 'Failed to fetch themes'
);
}
}
}