Skip to main content
Glama
paulieb89

UK Legal Research MCP Server

Check MTD VAT Status

hmrc_check_mtd_status
Read-onlyIdempotent

Check whether a UK business is mandated for Making Tax Digital (MTD) for VAT by providing its VAT Registration Number. Returns mandate status, effective date, and trading name.

Instructions

Check a business's Making Tax Digital VAT mandate status via the HMRC API.

NOTE: Connects to the HMRC sandbox by default. Set HMRC_API_BASE env var to 'https://api.service.hmrc.gov.uk' for production. Requires HMRC_CLIENT_ID and HMRC_CLIENT_SECRET environment variables (OAuth 2.0). Returns whether the business is mandated for MTD, effective date, and trading name.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYesHMRCMTDStatusInput with the 9-digit VAT Registration Number.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
vrnYesVAT Registration Number queried
mandatedYesWhether this business is mandated for MTD VAT
effective_dateNoDate from which MTD obligation applies
trading_nameNoRegistered trading name if available

Implementation Reference

  • The main handler function for 'hmrc_check_mtd_status'. It checks a business's Making Tax Digital VAT mandate status via the HMRC API. It obtains an OAuth2 bearer token using client credentials, then calls the HMRC organisations/vat/{vrn}/obligations endpoint to determine if the business is mandated for MTD, returning an MTDStatus model with vrn, mandated flag, effective_date, and trading_name.
    @mcp.tool(
        name="check_mtd_status",
        annotations={"title": "Check MTD VAT Status", "readOnlyHint": True, "destructiveHint": False, "idempotentHint": True, "openWorldHint": True},
    )
    async def hmrc_check_mtd_status(params: HMRCMTDStatusInput, ctx: Context) -> MTDStatus:
        """Check a business's Making Tax Digital VAT mandate status via the HMRC API.
    
        NOTE: Connects to the HMRC sandbox by default. Set HMRC_API_BASE env var to
        'https://api.service.hmrc.gov.uk' for production.
        Requires HMRC_CLIENT_ID and HMRC_CLIENT_SECRET environment variables (OAuth 2.0).
        Returns whether the business is mandated for MTD, effective date, and trading name.
    
        Args:
            params: HMRCMTDStatusInput with the 9-digit VAT Registration Number.
        """
        client_id = os.getenv("HMRC_CLIENT_ID")
        client_secret = os.getenv("HMRC_CLIENT_SECRET")
        if not client_id or not client_secret:
            raise RuntimeError(
                "HMRC OAuth credentials not configured. "
                "Set HMRC_CLIENT_ID and HMRC_CLIENT_SECRET. "
                "Register at https://developer.service.hmrc.gov.uk"
            )
    
        client: httpx.AsyncClient = ctx.lifespan_context["http"]
        token_resp = await client.post(
            f"{HMRC_API_BASE}/oauth/token",
            data={"grant_type": "client_credentials", "client_id": client_id, "client_secret": client_secret, "scope": "read:vat"},
        )
        token_resp.raise_for_status()
        access_token = token_resp.json().get("access_token")
        vrn = params.vrn.strip().lstrip("GB").lstrip("gb")
        resp = await client.get(
            f"{HMRC_API_BASE}/organisations/vat/{vrn}/obligations",
            headers={"Authorization": f"Bearer {access_token}"},
            params={"status": "O"},
        )
        resp.raise_for_status()
        data = resp.json()
        obligations = data.get("obligations", [])
        effective_date = None
        if obligations:
            start = obligations[0].get("start")
            if start:
                effective_date = date.fromisoformat(start)
        return MTDStatus(
            vrn=vrn,
            mandated=len(obligations) > 0,
            effective_date=effective_date,
            trading_name=data.get("tradingName"),
        )
  • Input schema (HMRCMTDStatusInput) for the check_mtd_status tool: a Pydantic model with a single 'vrn' field (VAT Registration Number).
    class HMRCMTDStatusInput(BaseModel):
        model_config = ConfigDict(str_strip_whitespace=True, extra="forbid")
    
        vrn: str = Field(..., description="VAT Registration Number: 9 digits, e.g. '123456789'. GB prefix accepted and stripped automatically.", min_length=9, max_length=12)
  • Output schema (MTDStatus) returned by the check_mtd_status handler: a Pydantic model with fields vrn, mandated, effective_date, and trading_name.
    class MTDStatus(BaseModel):
        """Making Tax Digital VAT status for a VAT registration number."""
    
        model_config = ConfigDict(str_strip_whitespace=True)
    
        vrn: str = Field(..., description="VAT Registration Number queried")
        mandated: bool = Field(..., description="Whether this business is mandated for MTD VAT")
        effective_date: date | None = Field(None, description="Date from which MTD obligation applies")
        trading_name: str | None = Field(None, description="Registered trading name if available")
  • Registration of the hmrc MCP server using FastMCP. The module creates 'hmrc_mcp' and calls register_tools(hmrc_mcp) which internally decorates the hmrc_check_mtd_status function as a tool.
    hmrc_mcp = FastMCP(
        name="hmrc",
        instructions=(
            "Look up UK tax information via HMRC APIs and GOV.UK. "
            "Use hmrc_get_vat_rate to find the VAT rate for any commodity or service type. "
            "Use hmrc_check_mtd_status to check Making Tax Digital VAT status (requires HMRC OAuth credentials). "
            "Use hmrc_search_guidance to find HMRC guidance documents on GOV.UK."
        ),
    )
    
    hmrc_mcp.add_middleware(ResponseCachingMiddleware(call_tool_settings=CallToolSettings(ttl=7776000)))
    
    register_tools(hmrc_mcp)
    
    __all__ = ["hmrc_mcp"]
  • The register_tools function that registers the tool via the @mcp.tool decorator. Line 121-124 show the @mcp.tool decorator with name='check_mtd_status' and annotations.
    def register_tools(mcp: FastMCP) -> None:
    
        @mcp.tool(
Behavior4/5

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

Annotations already declare readOnlyHint and idempotentHint as true, so the tool's safety profile is clear. The description adds valuable behavioral details beyond annotations: it notes the default sandbox connection, required OAuth credentials, and the return fields (mandate status, effective date, trading name). This enhances transparency without contradicting annotations.

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 concise at 5 sentences, with a clear note about sandbox/production and required credentials. It is front-loaded with the tool's purpose, uses bullet-point style, and every sentence adds value without redundancy.

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

Completeness5/5

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

For a simple query tool with an output schema (signaled as true) and full annotation coverage, the description is complete. It explains what the tool returns, environment setup, and authentication requirements. No major gaps are apparent, and the tool is well-positioned among its siblings.

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?

The input schema has 100% coverage: the 'vrn' parameter is described with min/max length and note about GB prefix handling. The description does not add extra semantic meaning beyond the schema, which is adequate. Baseline score of 3 is appropriate since schema already handles parameter documentation.

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 tool checks a business's Making Tax Digital VAT mandate status via the HMRC API. It uses a specific verb ('check') and resource ('MTD VAT status'), and is distinct from sibling tools like 'hmrc_get_vat_rate' and 'hmrc_search_guidance'.

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 usage context: it connects to the HMRC sandbox by default, explains how to switch to production via an env var, and lists required environment variables for OAuth 2.0. It does not explicitly state when not to use this tool or name alternatives, but the context is sufficient for correct selection.

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/paulieb89/uk-legal-mcp'

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