rustypaste_shorten_url
Shorten long URLs into compact redirect links using the rustypaste service. Convert lengthy web addresses into manageable short URLs for sharing and tracking.
Instructions
Shorten a long URL using rustypaste.
Creates a short redirect URL that points to the original long URL.
Args:
url (string): The URL to shorten (must be a valid URL)
Returns: The shortened URL.
Examples:
Shorten a link: url="https://example.com/very/long/path/to/resource?with=params"
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | The long URL to shorten |
Implementation Reference
- src/tools/shorten-url.ts:39-62 (handler)The tool handler function for rustypaste_shorten_url, which uses RustypasteClient to shorten the provided URL.
async (params: Input) => { try { const client = new RustypasteClient(); const result = await client.shortenUrl(params.url); return { content: [ { type: "text" as const, text: `✅ URL shortened!\n\nShort URL: ${result.url}\nOriginal: ${params.url}`, }, ], }; } catch (error) { return { isError: true, content: [ { type: "text" as const, text: `Error: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } } - src/tools/shorten-url.ts:5-10 (schema)The InputSchema for the tool, validating that the input 'url' is a valid URL string.
const InputSchema = z.object({ url: z .string() .url("Must be a valid URL") .describe("The long URL to shorten"), }); - src/tools/shorten-url.ts:14-64 (registration)The registration function that defines the 'rustypaste_shorten_url' tool to the MCP server.
export function registerShortenUrl(server: McpServer): void { server.registerTool( "rustypaste_shorten_url", { title: "Shorten URL", description: `Shorten a long URL using rustypaste. Creates a short redirect URL that points to the original long URL. Args: - url (string): The URL to shorten (must be a valid URL) Returns: The shortened URL. Examples: - Shorten a link: url="https://example.com/very/long/path/to/resource?with=params"`, inputSchema: InputSchema, annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true, }, }, async (params: Input) => { try { const client = new RustypasteClient(); const result = await client.shortenUrl(params.url); return { content: [ { type: "text" as const, text: `✅ URL shortened!\n\nShort URL: ${result.url}\nOriginal: ${params.url}`, }, ], }; } catch (error) { return { isError: true, content: [ { type: "text" as const, text: `Error: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } } ); }