url_shorten
Shorten URLs to create compact links for sharing and tracking. This tool from IteraTools MCP converts long web addresses into manageable short links.
Instructions
Shorten a URL ($0.001)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes |
Implementation Reference
- index.js:50-79 (handler)The generic `callTool` function that handles API requests for all tools, including `url_shorten`.
async function callTool(endpoint, params) { const fetch = (await import('node-fetch')).default; const isGet = ['GET'].includes((TOOLS.find(t => t.endpoint === endpoint) || {}).method); const url = isGet ? `${BASE_URL}${endpoint}?${new URLSearchParams(params)}` : `${BASE_URL}${endpoint}`; const res = await fetch(url, { method: isGet ? 'GET' : 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${API_KEY}`, }, body: isGet ? undefined : JSON.stringify(params), }); const text = await res.text(); let data; try { data = JSON.parse(text); } catch { data = { raw: text }; } if (!res.ok) { if (res.status === 402) { throw new Error(`Insufficient credits. Add credits at https://iteratools.com. Cost: ${TOOLS.find(t=>t.endpoint===endpoint)?.price || 'see docs'}`); } throw new Error(`API error ${res.status}: ${text.substring(0, 200)}`); } return data; } - index.js:37-37 (registration)Registration of the `url_shorten` tool within the `TOOLS` array.
{ name: 'url_shorten', description: 'Shorten a URL', inputSchema: { type: 'object', properties: { url: { type: 'string' } }, required: ['url'] }, endpoint: '/url/shorten', price: '$0.001' },