Skip to main content
Glama
iamfiro

Parcel Tracking MCP Server

by iamfiro

search-carrier

Find carrier names by keyword, supporting typos and case-insensitivity. Specify a limit for results to streamline parcel tracking on the Parcel Tracking MCP Server.

Instructions

Search carriers by name keyword (supports fuzzy typos)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMax number of results to return (default 10)
queryYesKeyword to search carrier names, case-insensitive (typos allowed)

Implementation Reference

  • src/index.ts:135-167 (registration)
    Registration of the 'search-carrier' tool with the MCP server, including name, description, input schema, and handler function.
    server.tool( "search-carrier", "Search carriers by name keyword (supports fuzzy typos)", { query: z.string().describe("Keyword to search carrier names, case-insensitive (typos allowed)"), limit: z.number().optional().describe("Max number of results to return (default 10)"), }, ({ query, limit = 10 }) => { const keyword = query.toLowerCase(); let exactMatches = carrierRows.filter( (row) => row.name_en.toLowerCase().includes(keyword) || row.name_cn.toLowerCase().includes(keyword) || row.name_hk.toLowerCase().includes(keyword) ); if (exactMatches.length === 0) { exactMatches = fuse.search(keyword).map((m) => m.item as CarrierRow); } const results = exactMatches.slice(0, limit).map((row) => ({ id: Number(row.key), name: row.name_en })); return { content: [ { type: "text", text: JSON.stringify(results, null, 2), } as const, ], }; } );
  • Handler function that performs carrier search: first exact substring match on names, fallback to fuzzy search with Fuse.js, limits results, returns JSON stringified list of {id, name}.
    ({ query, limit = 10 }) => { const keyword = query.toLowerCase(); let exactMatches = carrierRows.filter( (row) => row.name_en.toLowerCase().includes(keyword) || row.name_cn.toLowerCase().includes(keyword) || row.name_hk.toLowerCase().includes(keyword) ); if (exactMatches.length === 0) { exactMatches = fuse.search(keyword).map((m) => m.item as CarrierRow); } const results = exactMatches.slice(0, limit).map((row) => ({ id: Number(row.key), name: row.name_en })); return { content: [ { type: "text", text: JSON.stringify(results, null, 2), } as const, ], }; } );
  • Zod input schema defining 'query' (required string) and 'limit' (optional number) parameters for the tool.
    { query: z.string().describe("Keyword to search carrier names, case-insensitive (typos allowed)"), limit: z.number().optional().describe("Max number of results to return (default 10)"), },
  • Initialization of Fuse.js fuzzy search index on carrierRows, used in the handler for fallback search.
    const fuse = new Fuse(carrierRows, { keys: ["name_en", "name_cn", "name_hk"], threshold: 0.4, includeScore: true, });
  • Parsing of carriers.csv into carrierRows array, which is the data source for the search tool.
    const carrierRows: CarrierRow[] = parseCsv(fs.readFileSync(carriersCsvPath), { bom: true, columns: true, skip_empty_lines: true, trim: true, relax_quotes: true, });

Other Tools

Related 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/iamfiro/parcel-tracking-mcp'

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