274569bd79
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
35 lines
1.5 KiB
C#
35 lines
1.5 KiB
C#
using System.ComponentModel;
|
|
using ModelContextProtocol.Server;
|
|
|
|
namespace MoneyMap.Mcp.Tools;
|
|
|
|
[McpServerToolType]
|
|
public static class CategoryTools
|
|
{
|
|
[McpServerTool(Name = "list_categories"), Description("List all categories with transaction counts.")]
|
|
public static async Task<string> ListCategories(
|
|
MoneyMapApiClient api = default!)
|
|
{
|
|
return await api.ListCategoriesAsync();
|
|
}
|
|
|
|
[McpServerTool(Name = "get_category_mappings"), Description("Get auto-categorization pattern rules (CategoryMappings).")]
|
|
public static async Task<string> GetCategoryMappings(
|
|
[Description("Filter mappings to a specific category")] string? category = null,
|
|
MoneyMapApiClient api = default!)
|
|
{
|
|
return await api.GetCategoryMappingsAsync(category);
|
|
}
|
|
|
|
[McpServerTool(Name = "add_category_mapping"), Description("Add a new auto-categorization rule that maps transaction name patterns to categories.")]
|
|
public static async Task<string> AddCategoryMapping(
|
|
[Description("Pattern to match in transaction name (case-insensitive)")] string pattern,
|
|
[Description("Category to assign when pattern matches")] string category,
|
|
[Description("Merchant name to assign (creates if new)")] string? merchantName = null,
|
|
[Description("Priority (higher = checked first, default 0)")] int priority = 0,
|
|
MoneyMapApiClient api = default!)
|
|
{
|
|
return await api.AddCategoryMappingAsync(pattern, category, merchantName, priority);
|
|
}
|
|
}
|