/**
* Google Calendar Integration Tools
*
* Imports and adapts tools from @jezweb/mcp-integrations package.
*
* @see /home/jez/Documents/mcp/mcp-integrations/CLAUDE.md
*/
import { z, type ZodTypeAny } from 'zod';
import type { ToolDefinition, ToolContext } from './types';
import { tools as calendarTools } from '@jezweb/mcp-integrations/google/calendar';
// ============================================================================
// Adapter: Convert @jezweb/mcp-integrations tools to template ToolDefinition
// ============================================================================
interface IntegrationTool {
name: string;
description: string;
parameters: z.ZodType;
handler: (
params: unknown,
ctx: { authorizedFetch: (url: string, init?: RequestInit) => Promise<Response> }
) => Promise<{ content: Array<{ type: string; text: string }>; isError?: boolean }>;
category?: string;
tags?: string[];
alwaysVisible?: boolean;
}
function adaptIntegrationTool(tool: IntegrationTool): ToolDefinition {
return {
name: tool.name,
description: tool.description,
schema: (tool.parameters as z.ZodObject<Record<string, ZodTypeAny>>).shape,
handler: async (args, context: ToolContext | undefined) => {
if (!context?.authorizedFetch) {
return {
content: [
{
type: 'text',
text: 'Error: This tool requires authentication. Please connect your Google account.',
},
],
isError: true,
};
}
return tool.handler(args, { authorizedFetch: context.authorizedFetch });
},
metadata: {
category: (tool.category as 'utility' | 'query' | 'mutation' | 'integration') || 'integration',
tags: tool.tags,
alwaysVisible: tool.alwaysVisible,
requiresAuth: 'google',
authScopes: ['https://www.googleapis.com/auth/calendar'],
},
};
}
// ============================================================================
// Export adapted calendar tools
// ============================================================================
/**
* All Google Calendar tools from @jezweb/mcp-integrations
*
* Includes: listEvents, createEvent, updateEvent, deleteEvent, quickAddEvent
*/
export const integrationTools: ToolDefinition[] = calendarTools.all.map(adaptIntegrationTool);
// Alternative presets (uncomment to use):
// export const integrationTools = calendarTools.readOnly.map(adaptIntegrationTool); // Just listEvents
// export const integrationTools = calendarTools.fullAccess.map(adaptIntegrationTool); // All CRUD