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
                ),
              },
            ],
          };
        }
      );
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses that the tool returns brackets (read-only behavior) and specifies the source (Ley 35/2006), adding useful context. However, it doesn't mention potential limitations like rate changes, data freshness, or error handling, leaving some behavioral aspects unclear.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the core purpose, followed by specific details on types and scope, and ends with the source. Every sentence adds value without redundancy, making it appropriately sized and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (2 parameters, no output schema, no annotations), the description is fairly complete. It covers purpose, parameter semantics, and scope, but lacks details on output format (e.g., structure of returned brackets) and potential errors, which could be helpful for an agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters thoroughly. The description adds marginal value by explaining the semantics of 'general' and 'savings' types and noting the state-level scope, but doesn't provide additional syntax or format details beyond what the schema offers.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Returns' and the resource 'Spanish IRPF brackets', specifying it's for a given fiscal year. It distinguishes between 'general' and 'savings' types, making the purpose specific and differentiated from siblings like get_ccaa_deductions or get_vat_rates.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context on when to use each type ('general' for work/business income, 'savings' for capital gains/dividends) and notes these are STATE-level rates only, implying alternatives might be needed for regional scales. However, it doesn't explicitly name when-not-to-use cases or direct alternatives among siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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