Skip to main content
Glama
iMark21

AEAT MCP Server

by iMark21

get_irpf_brackets

Retrieve Spanish income tax brackets for work income or capital gains. Specify fiscal year and bracket type to get state-level IRPF rates for tax calculations.

Instructions

Returns Spanish IRPF (income tax) brackets for a given fiscal year. type='general' returns the base general (work/business income) brackets. type='savings' returns the base del ahorro (capital gains/dividends) brackets. These are STATE-level rates only (roughly half of the total rate). The other half comes from the CCAA regional scale. Source: Ley 35/2006, arts. 63 and 66.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
yearYesFiscal year (2024-2026)
typeNoBracket type: 'general' (work income) or 'savings' (capital gains)general

Implementation Reference

  • The async handler function that executes the logic for the get_irpf_brackets tool, including data loading, error handling, and result formatting.
    async ({ year, type }) => {
      const data = loadData(year);
      if (!data) {
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify({
                error: "no_data",
                message: `No IRPF data available for year ${year}. Available years: 2025.`,
              }),
            },
          ],
        };
      }
    
      const brackets =
        type === "savings"
          ? data.savings_brackets
          : data.general_brackets;
    
      return {
        content: [
          {
            type: "text" as const,
            text: JSON.stringify(
              {
                year,
                type,
                level: "state",
                note: "These are state-level rates only (approximately half of total IRPF). Regional (CCAA) rates are added on top.",
                brackets: brackets.state,
                source: brackets.source,
                verified_date: data.verified_date,
                disclaimer:
                  "Informational only. Does not constitute tax advice.",
              },
              null,
              2
            ),
          },
        ],
      };
    }
  • The Zod schema defining the input parameters (year and type) for the tool.
    {
      year: z
        .number()
        .int()
        .min(2024)
        .max(2026)
        .describe("Fiscal year (2024-2026)"),
      type: z
        .enum(["general", "savings"])
        .optional()
        .default("general")
        .describe("Bracket type: 'general' (work income) or 'savings' (capital gains)"),
    },
  • The registration function that defines the MCP tool using the McpServer instance.
    export function registerIrpfBracketsTool(server: McpServer) {
      server.tool(
        "get_irpf_brackets",
        "Returns Spanish IRPF (income tax) brackets for a given fiscal year. " +
          "type='general' returns the base general (work/business income) brackets. " +
          "type='savings' returns the base del ahorro (capital gains/dividends) brackets. " +
          "These are STATE-level rates only (roughly half of the total rate). " +
          "The other half comes from the CCAA regional scale. " +
          "Source: Ley 35/2006, arts. 63 and 66.",
        {
          year: z
            .number()
            .int()
            .min(2024)
            .max(2026)
            .describe("Fiscal year (2024-2026)"),
          type: z
            .enum(["general", "savings"])
            .optional()
            .default("general")
            .describe("Bracket type: 'general' (work income) or 'savings' (capital gains)"),
        },
        async ({ year, type }) => {
          const data = loadData(year);
          if (!data) {
            return {
              content: [
                {
                  type: "text" as const,
                  text: JSON.stringify({
                    error: "no_data",
                    message: `No IRPF data available for year ${year}. Available years: 2025.`,
                  }),
                },
              ],
            };
          }
    
          const brackets =
            type === "savings"
              ? data.savings_brackets
              : data.general_brackets;
    
          return {
            content: [
              {
                type: "text" as const,
                text: JSON.stringify(
                  {
                    year,
                    type,
                    level: "state",
                    note: "These are state-level rates only (approximately half of total IRPF). Regional (CCAA) rates are added on top.",
                    brackets: brackets.state,
                    source: brackets.source,
                    verified_date: data.verified_date,
                    disclaimer:
                      "Informational only. Does not constitute tax advice.",
                  },
                  null,
                  2
                ),
              },
            ],
          };
        }
      );
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/iMark21/aeat-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server