Skip to main content
Glama
kesslerio

YOURLS-MCP

by kesslerio

delete_url

Remove a short URL or keyword from your YOURLS URL shortener to clean up unused or outdated links, ensuring your short URL directory remains organized and relevant.

Instructions

Delete a short URL

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
shorturlYesThe short URL or keyword to delete

Implementation Reference

  • The createDeleteUrlTool factory function that returns the MCP tool object for 'delete_url', including the execute handler that performs the deletion using yourlsClient.deleteUrl with fallback handling and response formatting.
    export default function createDeleteUrlTool(yourlsClient) {
      return {
        name: 'delete_url',
        description: 'Delete a short URL',
        inputSchema: {
          type: 'object',
          properties: {
            shorturl: {
              type: 'string',
              description: 'The short URL or keyword to delete'
            }
          },
          required: ['shorturl']
        },
        execute: async ({ shorturl }) => {
          try {
            // Use the deleteUrl method with fallback enabled
            const result = await yourlsClient.deleteUrl(shorturl, true);
            
            if (result.status === 'success' || result.message === 'success: deleted') {
              const responseData = {
                shorturl: shorturl,
                message: result.message || result.simple || 'Short URL deleted successfully'
              };
              
              // Add fallback information if applicable
              if (result.fallback_used) {
                responseData.fallback_used = true;
                if (result.fallback_limited) {
                  responseData.fallback_limited = true;
                  
                  // Special handling for the limited delete fallback
                  if (result.status === 'info') {
                    return {
                      content: [
                        {
                          type: 'text',
                          text: JSON.stringify({
                            status: 'info',
                            shorturl: shorturl,
                            message: result.message,
                            code: result.code || 'not_supported',
                            fallback_used: true,
                            fallback_limited: true
                          })
                        }
                      ]
                    };
                  }
                }
              }
              
              return createMcpResponse(true, responseData);
            } else if (result.status === 'info') {
              // Special handling for the info status (fallback limitation)
              return {
                content: [
                  {
                    type: 'text',
                    text: JSON.stringify({
                      status: 'info',
                      shorturl: shorturl,
                      message: result.message,
                      fallback_used: result.fallback_used,
                      fallback_limited: result.fallback_limited
                    })
                  }
                ]
              };
            } else {
              throw new Error(result.message || 'Unknown error');
            }
          } catch (error) {
            return createMcpResponse(false, {
              message: error.message,
              shorturl: shorturl
            });
          }
        }
      };
    }
  • src/index.js:220-227 (registration)
    Registration of the delete_url tool on the MCP server using server.tool(), providing name, description, input schema (zod), and execute function reference.
    server.tool(
      deleteUrlTool.name,
      deleteUrlTool.description,
      {
        shorturl: z.string().describe('The short URL or keyword to delete')
      },
      deleteUrlTool.execute
    );
  • JSON schema definition for the delete_url tool input parameters within the tool factory.
    inputSchema: {
      type: 'object',
      properties: {
        shorturl: {
          type: 'string',
          description: 'The short URL or keyword to delete'
        }
      },
      required: ['shorturl']
    },
  • The YourlsClient.deleteUrl method, called by the tool handler, which checks for the API Delete plugin availability and provides fallback response explaining limitations.
    async deleteUrl(shorturl, useNativeFallback = true) {
      try {
        // First check if the plugin is available
        const isAvailable = await isPluginAvailable(this, 'delete', 'delete', { shorturl: 'test' });
        
        if (isAvailable) {
          return this.request('delete', { shorturl });
        } else if (useNativeFallback) {
          // Use our fallback implementation with admin interface emulation
          return this._deleteUrlFallback(shorturl);
        } else {
          throw new Error('The delete action is not available. Please install the API Delete plugin.');
        }
      } catch (error) {
        // If the error is not about a missing plugin, re-throw it
        if (!isPluginMissingError(error)) {
          throw error;
        }
        
        // If we're here, the plugin is missing and we need to use the fallback
        if (useNativeFallback) {
          return this._deleteUrlFallback(shorturl);
        } else {
          throw new Error('The delete action is not available. Please install the API Delete plugin.');
        }
      }
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. 'Delete' implies a destructive mutation, but the description doesn't specify whether this action is reversible, what permissions are required, or what the response looks like. It lacks details on side effects or error conditions.

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 a single, efficient sentence with zero waste. It's front-loaded and appropriately sized for a simple tool, making it easy to parse quickly.

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

Completeness2/5

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

For a destructive mutation tool with no annotations and no output schema, the description is incomplete. It doesn't explain what 'delete' entails (e.g., permanent removal, effects on analytics), return values, or error handling, leaving significant gaps for an AI agent.

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?

Schema description coverage is 100%, with the parameter 'shorturl' documented as 'The short URL or keyword to delete'. The description adds no additional meaning beyond this, so it meets the baseline of 3 where the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Delete a short URL' clearly states the action (delete) and resource (short URL). It distinguishes from siblings like 'update_url' or 'change_keyword' by specifying deletion rather than modification, though it doesn't explicitly contrast with all alternatives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like 'update_url' or 'change_keyword'. The description states what it does but offers no context about prerequisites, when deletion is appropriate, or what happens after deletion.

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

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/kesslerio/yourls-mcp'

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