Skip to main content
Glama

validate_polish_nip

Validates a Polish NIP tax identification number using the official checksum algorithm. Accepts dashes/spaces and returns validity status.

Instructions

Validate a Polish NIP (tax identification number).

Applies the official 10-digit checksum algorithm. Accepts NIP with or without dashes/spaces.

Returns {'valid': bool, 'nip': str, 'normalized': str}.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nipYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The tool handler for 'validate_polish_nip'. It is decorated with @mcp.tool, accepts a NIP string, normalizes it (removes dashes/spaces), delegates to validate_nip(), and returns a dict with valid, nip, normalized, and message fields.
    @mcp.tool
    async def validate_polish_nip(nip: str) -> dict[str, Any]:
        """Validate a Polish NIP (tax identification number).
    
        Applies the official 10-digit checksum algorithm.
        Accepts NIP with or without dashes/spaces.
    
        Returns {'valid': bool, 'nip': str, 'normalized': str}.
        """
        import re
    
        normalized = re.sub(r"[\s\-]", "", nip)
        valid = validate_nip(nip)
        return {
            "valid": valid,
            "nip": nip,
            "normalized": normalized,
            "message": "NIP is valid." if valid else "NIP failed checksum validation.",
        }
  • The core checksum validation function. Strips non-digit characters, verifies 10 digits, computes weighted sum modulo 11, and checks the checksum digit.
    def validate_nip(nip: str) -> bool:
        """Return True when *nip* passes the Polish NIP checksum algorithm."""
        digits = re.sub(r"[\s\-]", "", nip)
        if not digits.isdigit() or len(digits) != 10:
            return False
        total = sum(int(d) * w for d, w in zip(digits, _NIP_WEIGHTS))
        remainder = total % 11
        return remainder != 10 and remainder == int(digits[9])
  • Registration of the tool via the @mcp.tool decorator on the async function.
    @mcp.tool
    async def validate_polish_nip(nip: str) -> dict[str, Any]:
  • Input schema is implicitly defined by the function signature (nip: str). Output is dict[str, Any].
    @mcp.tool
    async def validate_polish_nip(nip: str) -> dict[str, Any]:
  • The import of validate_nip from party_validator module.
    from .party_validator import PolishPartyValidator, validate_nip, validate_regon
Behavior4/5

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

No annotations are provided, so the description carries full burden. It discloses the checksum algorithm, input format acceptance, and return fields. While it does not explicitly state behavior on invalid input (e.g., returns valid:false), the return format implies it. This is adequate for a validation tool.

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 extremely concise, with two sentences and a return format spec. Every sentence adds value, and the key information is front-loaded. No wasted words.

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 simple nature of the tool (validation with one parameter) and the presence of an output schema, the description covers the algorithm, input format, and return shape. It could be more explicit about error handling, but overall it is sufficiently complete.

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

Parameters4/5

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

The schema has 0% description coverage, only specifying type string. The description adds meaning by stating 'Accepts NIP with or without dashes/spaces', which clarifies acceptable input formats beyond the schema.

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 'Validate a Polish NIP (tax identification number)' using the official checksum algorithm. This specifies the exact verb and resource, and it distinguishes from sibling tools like validate_polish_regon which validate a different identifier.

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 implicitly indicates when to use: when you need to validate a Polish NIP. However, it does not explicitly provide when-not-to-use scenarios or compare with sibling tools. It does mention input format flexibility (with/without dashes/spaces), which is helpful.

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/cmendezs/mcp-ksef-pl'

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