Skip to main content
Glama
SoapyRED

FreightUtils MCP Server

uk_duty_calculator

Read-onlyIdempotent

Estimate UK import duty and VAT for any HS commodity code. Uses live Trade Tariff data to calculate CIF value, applies duty rate, then adds 20% VAT.

Instructions

Estimate UK import duty and VAT for any commodity code.

Uses live GOV.UK Trade Tariff data. Calculates CIF value from goods value + freight + insurance, applies the appropriate duty rate, then calculates VAT (standard 20%) on the duty-inclusive value.

Use this tool when you need to:

  • Estimate import costs for UK-bound shipments

  • Check duty rates for specific HS/commodity codes

  • Compare landed costs for different origin countries

  • Determine if preferential rates apply

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commodity_codeYesHS/tariff code (6–10 digits, e.g., "847989")
origin_countryYesISO 2-letter origin country code (e.g., "CN", "DE")
customs_valueYesGoods value in GBP
freight_costNoFreight cost in GBP (added to CIF value)
insurance_costNoInsurance cost in GBP (added to CIF value)
incotermNoIncoterm (e.g., "FOB", "CIF", "EXW")

Implementation Reference

  • The handler function for uk_duty_calculator. It calls apiPost('duty', args) which POSTs to the FreightUtils API endpoint '/duty' with the validated arguments.
    handler: async (args) => apiPost('duty', args),
  • Zod schema defining input validation: commodity_code (6-10 digits), origin_country (2-letter ISO), customs_value (positive GBP), optional freight_cost, insurance_cost, and incoterm. Strict mode rejects unknown keys.
    schema: z.object({
      commodity_code: z.string().regex(/^\d{6,10}$/, 'Commodity code must be 6–10 digits').describe('HS/tariff code (6–10 digits, e.g., "847989")'),
      origin_country: z.string().length(2, 'Origin country must be a 2-letter ISO code').regex(/^[A-Z]{2}$/i, 'Origin country must be a 2-letter ISO code (e.g., "CN", "DE")').describe('ISO 2-letter origin country code (e.g., "CN", "DE")'),
      customs_value: z.number().positive().describe('Goods value in GBP'),
      freight_cost: z.number().optional().describe('Freight cost in GBP (added to CIF value)'),
      insurance_cost: z.number().optional().describe('Insurance cost in GBP (added to CIF value)'),
      incoterm: z.string().optional().describe('Incoterm (e.g., "FOB", "CIF", "EXW")'),
    }).strict(),
  • src/tools.ts:728-728 (registration)
    The tool is registered in the ALL_TOOLS array at line 728, which is iterated over in server.ts to register each tool with the MCP server.
    ukDutyCalculator,
  • src/server.ts:20-41 (registration)
    Server registration loop in createServer(): iterates ALL_TOOLS and calls server.tool() with name, description, schema, annotations, and a wrapper handler that catches errors.
    server.tool(
      tool.name,
      tool.description,
      tool.schema.shape,
      tool.annotations,
      async (args: Record<string, unknown>) => {
        try {
          const result = await tool.handler(args);
          return {
            content: [
              { type: 'text' as const, text: JSON.stringify(result, null, 2) },
            ],
          };
        } catch (err: unknown) {
          const message = err instanceof Error ? err.message : String(err);
          return {
            content: [{ type: 'text' as const, text: `Error: ${message}` }],
            isError: true,
          };
        }
      },
    );
  • The apiPost helper function used by the handler to POST to the FreightUtils API. It constructs the URL from BASE_URL + endpoint, sends JSON body, and returns parsed JSON response.
    export async function apiPost(endpoint: string, body: unknown): Promise<unknown> {
      const res = await fetch(`${BASE_URL}/${endpoint}`, {
        method: 'POST',
        headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' },
        body: JSON.stringify(body),
      });
    
      if (!res.ok) {
        const text = await res.text();
        throw new Error(`FreightUtils API error ${res.status}: ${text}`);
      }
    
      return res.json();
    }
Behavior4/5

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

Annotations already provide readOnlyHint and idempotentHint. The description adds behavioral details: it uses live GOV.UK data, calculates CIF value, applies duty rates, and calculates VAT. This goes beyond annotations without contradicting them.

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, front-loaded with purpose, and uses a clear structure with a paragraph and bullet list. Every sentence adds value with no redundancy.

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 complexity and lack of output schema, the description explains the calculation steps (CIF, duty, VAT) well, allowing inference of the output. It covers use cases and methodology adequately, though explicit output details would be beneficial.

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 with descriptions for all parameters. The description adds context about CIF calculation but does not elaborate on individual parameters beyond the schema. Baseline 3 is appropriate.

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 estimates UK import duty and VAT for any commodity code, with specific steps. It explicitly lists use cases in bullet points, distinguishing it from sibling calculators like cbm_calculator or adr_exemption_calculator.

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 four explicit use cases for when to use the tool. While it doesn't specify when not to use it or alternative tools, the listed scenarios are clear and relevant.

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/SoapyRED/freightutils-mcp'

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