import { Tool } from '@modelcontextprotocol/sdk/types.js';
import { RemoveFeedSchema } from '../utils/validation.js';
import { ConfigManager } from '../config/manager.js';
import { RemoveFeedResponse } from '../types/index.js';
export function createRemoveFeedTool(): Tool {
return {
name: 'remove_feed',
description: '登録されているRSSフィードを削除します',
inputSchema: {
type: 'object',
properties: {
feedId: {
type: 'string',
description: '削除するフィードのID',
minLength: 1
}
},
required: ['feedId']
}
};
}
export async function handleRemoveFeed(
args: any,
configManager: ConfigManager
): Promise<RemoveFeedResponse> {
try {
const params = RemoveFeedSchema.parse(args);
const success = await configManager.removeFeed(params.feedId);
if (success) {
return {
success: true,
message: 'フィードが正常に削除されました'
};
} else {
return {
success: false,
message: '指定されたIDのフィードが見つかりません'
};
}
} catch (error) {
if (error instanceof Error && 'issues' in error) {
return {
success: false,
message: '入力パラメータが無効です'
};
}
return {
success: false,
message: `フィード削除エラー: ${error instanceof Error ? error.message : 'Unknown error'}`
};
}
}