MCP Servers/URL Encoder/Decoder

URL Encoder/Decoder

utilities

active

Encode and decode URLs with support for different encoding types through MCP protocol

utilitiesmcputilitiesai-tools

API Access Requires Subscription

While you can view all details here, using this MCP server's API requires a Enterprise subscription. API calls with FREE plan keys will return an access error.

View Pricing Plans

Available Tools

decode_url

function

Decode percent-encoded URL back to original text

urlutility

encode_url

function

Encode text to URL-safe percent-encoded format (RFC 3986)

urlutility

Documentation

URL Encoder/Decoder Documentation

URL Encoder/Decoder MCP Server

Overview

The URL Encoder/Decoder MCP server provides comprehensive URL encoding and decoding functionality through the Model Context Protocol (MCP). This server provides comprehensive functionality.

๐Ÿ”ง Exposed Tools

This MCP server exposes 2 tools for AI agents:

1. encode_url

Purpose: Encode text to URL-safe percent-encoded format (RFC 3986)

  • Input: input (string), component (full|query|path|fragment), encoding options
  • Output: URL-encoded string with metadata
  • Example: "hello world!" โ†’ "hello%20world%21"

2. decode_url

Purpose: Decode percent-encoded URL back to original text

  • Input: input (percent-encoded string), validation options
  • Output: Decoded original text with format validation
  • Example: "hello%20world%21" โ†’ "hello world!"

๐Ÿ”— Server Details

  • Category: Utilities / Web Development
  • Transport: Server-Sent Events (SSE)
  • Endpoint: /api/mcp/utilities/url-encoder/sse
  • Authentication: Required (PRO/ENTERPRISE plans)
  • Wrapped API: /api/utilities/url-encoder/v1
  • RFC Compliance: RFC 3986 URL encoding standard

๐Ÿ“‹ Prerequisites

  • Subscription: PRO or ENTERPRISE plan
  • API Key: Valid API key with URL Encoder access
  • MCP Client: Any MCP-compatible client or AI agent

๐Ÿš€ Quick Start

Connection Setup

Endpoint: https://apistack.online/api/mcp/utilities/url-encoder/sse
Method: POST
Headers:
  Content-Type: application/json
  Authorization: Bearer YOUR_API_KEY

Basic MCP Requests

List Available Tools

{
  "jsonrpc": "2.0",
  "id": "list-tools",
  "method": "tools/list"
}

Encode URL Text

{
  "jsonrpc": "2.0",
  "id": "encode-1",
  "method": "tools/call",
  "params": {
    "name": "encode_url",
    "arguments": {
      "input": "hello world & special chars!",
      "component": "full",
      "preserveReserved": false,
      "includeMetadata": true
    }
  }
}

Decode URL Text

{
  "jsonrpc": "2.0",
  "id": "decode-1",
  "method": "tools/call",
  "params": {
    "name": "decode_url",
    "arguments": {
      "input": "hello%20world%20%26%20special%20chars%21",
      "includeMetadata": true,
      "validateFormat": true
    }
  }
}

๐Ÿ’ป Implementation Examples

Python Example

import requests
import json
from urllib.parse import quote, unquote

class URLEncoderMCPClient:
    def __init__(self, base_url, api_key):
        self.base_url = base_url
        self.headers = {
            "Content-Type": "application/json",
            "Authorization": f"Bearer {api_key}"
        }
        self.endpoint = f"{base_url}/api/mcp/utilities/url-encoder/sse"
    
    def encode_url(self, text, component="full", preserve_reserved=False, include_metadata=False):
        request = {
            "jsonrpc": "2.0",
            "id": "encode",
            "method": "tools/call",
            "params": {
                "name": "encode_url",
                "arguments": {
                    "input": text,
                    "component": component,
                    "preserveReserved": preserve_reserved,
                    "includeMetadata": include_metadata
                }
            }
        }
        
        response = requests.post(self.endpoint, headers=self.headers, json=request)
        result = response.json()
        return result["result"]["content"][0]["text"]
    
    def decode_url(self, encoded_text, include_metadata=False, validate_format=True):
        request = {
            "jsonrpc": "2.0",
            "id": "decode",
            "method": "tools/call",
            "params": {
                "name": "decode_url",
                "arguments": {
                    "input": encoded_text,
                    "includeMetadata": include_metadata,
                    "validateFormat": validate_format
                }
            }
        }
        
        response = requests.post(self.endpoint, headers=self.headers, json=request)
        result = response.json()
        return result["result"]["content"][0]["text"]
    
    def encode_url_components(self, urls_dict):
        """
        Encode different URL components with appropriate settings
        urls_dict: {"query": "search term", "path": "/api/users", "fragment": "section1"}
        """
        results = {}
        
        for component_type, text in urls_dict.items():
            encoded = self.encode_url(
                text=text,
                component=component_type,
                preserve_reserved=(component_type in ["path", "query"]),
                include_metadata=True
            )
            results[component_type] = encoded
            
        return results

# Usage Examples
client = URLEncoderMCPClient("https://apistack.online", "YOUR_API_KEY")

# Basic encoding
original_text = "Hello World & Special Characters!"
encoded = client.encode_url(original_text, include_metadata=True)
print(f"Original: {original_text}")
print(f"Encoded: {encoded}")

# Basic decoding
encoded_text = "Hello%20World%20%26%20Special%20Characters%21"
decoded = client.decode_url(encoded_text, include_metadata=True)
print(f"Encoded: {encoded_text}")
print(f"Decoded: {decoded}")

# Component-specific encoding
url_components = {
    "query": "search query with spaces",
    "path": "/api/users/john doe",
    "fragment": "section with #hashtag"
}

encoded_components = client.encode_url_components(url_components)
for component, result in encoded_components.items():
    print(f"{component}: {result}")

# Build complete URL
base_url = "https://example.com"
encoded_path = client.encode_url("/api/search", component="path")
encoded_query = client.encode_url("q=hello world&type=exact", component="query")
encoded_fragment = client.encode_url("results section", component="fragment")

complete_url = f"{base_url}{encoded_path}?{encoded_query}#{encoded_fragment}"
print(f"Complete URL: {complete_url}")

JavaScript/Node.js Example

const axios = require('axios');

class URLEncoderMCPClient {
    constructor(baseUrl, apiKey) {
        this.baseUrl = baseUrl;
        this.endpoint = `${baseUrl}/api/mcp/utilities/url-encoder/sse`;
        this.headers = {
            'Content-Type': 'application/json',
            'Authorization': `Bearer ${apiKey}`
        };
    }

    async encodeUrl(text, options = {}) {
        const request = {
            jsonrpc: "2.0",
            id: "encode",
            method: "tools/call",
            params: {
                name: "encode_url",
                arguments: {
                    input: text,
                    component: options.component || "full",
                    preserveReserved: options.preserveReserved || false,
                    includeMetadata: options.includeMetadata || false
                }
            }
        };

        const response = await axios.post(this.endpoint, request, { headers: this.headers });
        return response.data.result.content[0].text;
    }

    async decodeUrl(encodedText, options = {}) {
        const request = {
            jsonrpc: "2.0",
            id: "decode",
            method: "tools/call",
            params: {
                name: "decode_url",
                arguments: {
                    input: encodedText,
                    includeMetadata: options.includeMetadata || false,
                    validateFormat: options.validateFormat !== false
                }
            }
        };

        const response = await axios.post(this.endpoint, request, { headers: this.headers });
        return response.data.result.content[0].text;
    }

    async encodeUrlComponents(urlParts) {
        const results = {};
        
        for (const [component, text] of Object.entries(urlParts)) {
            const preserveReserved = ['path', 'query'].includes(component);
            
            results[component] = await this.encodeUrl(text, {
                component,
                preserveReserved,
                includeMetadata: true
            });
        }
        
        return results;
    }

    async buildSafeUrl(baseUrl, pathParts = [], queryParams = {}, fragment = null) {
        // Encode path parts
        const encodedPathParts = [];
        for (const part of pathParts) {
            const encoded = await this.encodeUrl(part, { component: 'path' });
            // Extract just the encoded value from the response
            const match = encoded.match(/```\n(.*?)\n```/);
            encodedPathParts.push(match ? match[1] : part);
        }
        
        // Encode query parameters
        const encodedQueryPairs = [];
        for (const [key, value] of Object.entries(queryParams)) {
            const encodedKey = await this.encodeUrl(key, { component: 'query' });
            const encodedValue = await this.encodeUrl(value, { component: 'query' });
            
            // Extract encoded values
            const keyMatch = encodedKey.match(/```\n(.*?)\n```/);
            const valueMatch = encodedValue.match(/```\n(.*?)\n```/);
            
            encodedQueryPairs.push(
                `${keyMatch ? keyMatch[1] : key}=${valueMatch ? valueMatch[1] : value}`
            );
        }
        
        // Build final URL
        let url = baseUrl;
        if (encodedPathParts.length > 0) {
            url += '/' + encodedPathParts.join('/');
        }
        if (encodedQueryPairs.length > 0) {
            url += '?' + encodedQueryPairs.join('&');
        }
        if (fragment) {
            const encodedFragment = await this.encodeUrl(fragment, { component: 'fragment' });
            const fragmentMatch = encodedFragment.match(/```\n(.*?)\n```/);
            url += '#' + (fragmentMatch ? fragmentMatch[1] : fragment);
        }
        
        return url;
    }
}

// Usage Examples
(async () => {
    const client = new URLEncoderMCPClient("https://apistack.online", "YOUR_API_KEY");
    
    try {
        // Basic encoding and decoding
        const originalText = "Hello World & Special Characters!";
        const encoded = await client.encodeUrl(originalText, { includeMetadata: true });
        console.log("Encoded:", encoded);

        const encodedText = "Hello%20World%20%26%20Special%20Characters%21";
        const decoded = await client.decodeUrl(encodedText, { includeMetadata: true });
        console.log("Decoded:", decoded);

        // Component-specific encoding
        const urlComponents = {
            query: "search term with spaces",
            path: "/api/users/john doe",
            fragment: "section with special chars!"
        };

        const encodedComponents = await client.encodeUrlComponents(urlComponents);
        console.log("Encoded Components:", encodedComponents);

        // Build a complete safe URL
        const safeUrl = await client.buildSafeUrl(
            "https://api.example.com",
            ["users", "john doe", "profile"],
            {
                "search": "hello world",
                "type": "exact match",
                "format": "json"
            },
            "user details section"
        );
        console.log("Safe URL:", safeUrl);

        // Encode different types of content
        const testCases = [
            { text: "simple text", component: "full" },
            { text: "/api/path with spaces", component: "path" },
            { text: "search=hello world&type=exact", component: "query" },
            { text: "section with #hashtag", component: "fragment" }
        ];

        for (const testCase of testCases) {
            const result = await client.encodeUrl(testCase.text, {
                component: testCase.component,
                includeMetadata: true
            });
            console.log(`${testCase.component.toUpperCase()}:`, result);
        }

    } catch (error) {
        console.error("Error:", error.response?.data || error.message);
    }
})();

.NET Core Example

using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using System.Web;

public class URLEncoderMCPClient
{
    private readonly HttpClient _httpClient;
    private readonly string _endpoint;

    public URLEncoderMCPClient(string baseUrl, string apiKey)
    {
        _httpClient = new HttpClient();
        _endpoint = $"{baseUrl}/api/mcp/utilities/url-encoder/sse";
        _httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}");
    }

    public async Task<string> EncodeUrlAsync(string text, string component = "full", 
        bool preserveReserved = false, bool includeMetadata = false)
    {
        var request = new
        {
            jsonrpc = "2.0",
            id = "encode",
            method = "tools/call",
            @params = new
            {
                name = "encode_url",
                arguments = new
                {
                    input = text,
                    component,
                    preserveReserved,
                    includeMetadata
                }
            }
        };

        return await SendRequestAsync(request);
    }

    public async Task<string> DecodeUrlAsync(string encodedText, 
        bool includeMetadata = false, bool validateFormat = true)
    {
        var request = new
        {
            jsonrpc = "2.0",
            id = "decode",
            method = "tools/call",
            @params = new
            {
                name = "decode_url",
                arguments = new
                {
                    input = encodedText,
                    includeMetadata,
                    validateFormat
                }
            }
        };

        return await SendRequestAsync(request);
    }

    public async Task<Dictionary<string, string>> EncodeUrlComponentsAsync(
        Dictionary<string, string> urlComponents)
    {
        var results = new Dictionary<string, string>();

        foreach (var kvp in urlComponents)
        {
            var component = kvp.Key;
            var text = kvp.Value;
            var preserveReserved = component == "path" || component == "query";

            var encoded = await EncodeUrlAsync(text, component, preserveReserved, true);
            results[component] = encoded;
        }

        return results;
    }

    public async Task<string> BuildSafeUrlAsync(string baseUrl, 
        string[] pathParts = null, 
        Dictionary<string, string> queryParams = null, 
        string fragment = null)
    {
        var urlBuilder = new StringBuilder(baseUrl);

        // Encode and append path parts
        if (pathParts != null && pathParts.Length > 0)
        {
            var encodedParts = new List<string>();
            foreach (var part in pathParts)
            {
                var encoded = await EncodeUrlAsync(part, "path");
                // Extract the encoded value from the response
                var match = System.Text.RegularExpressions.Regex.Match(encoded, @"```\n(.*?)\n```");
                encodedParts.Add(match.Success ? match.Groups[1].Value : part);
            }
            urlBuilder.Append("/").Append(string.Join("/", encodedParts));
        }

        // Encode and append query parameters
        if (queryParams != null && queryParams.Count > 0)
        {
            var encodedParams = new List<string>();
            foreach (var kvp in queryParams)
            {
                var encodedKey = await EncodeUrlAsync(kvp.Key, "query");
                var encodedValue = await EncodeUrlAsync(kvp.Value, "query");
                
                // Extract encoded values
                var keyMatch = System.Text.RegularExpressions.Regex.Match(encodedKey, @"```\n(.*?)\n```");
                var valueMatch = System.Text.RegularExpressions.Regex.Match(encodedValue, @"```\n(.*?)\n```");
                
                var key = keyMatch.Success ? keyMatch.Groups[1].Value : kvp.Key;
                var value = valueMatch.Success ? valueMatch.Groups[1].Value : kvp.Value;
                
                encodedParams.Add($"{key}={value}");
            }
            urlBuilder.Append("?").Append(string.Join("&", encodedParams));
        }

        // Encode and append fragment
        if (!string.IsNullOrEmpty(fragment))
        {
            var encodedFragment = await EncodeUrlAsync(fragment, "fragment");
            var fragmentMatch = System.Text.RegularExpressions.Regex.Match(encodedFragment, @"```\n(.*?)\n```");
            var fragmentValue = fragmentMatch.Success ? fragmentMatch.Groups[1].Value : fragment;
            urlBuilder.Append("#").Append(fragmentValue);
        }

        return urlBuilder.ToString();
    }

    private async Task<string> SendRequestAsync(object request)
    {
        var json = JsonSerializer.Serialize(request);
        var content = new StringContent(json, Encoding.UTF8, "application/json");
        
        var response = await _httpClient.PostAsync(_endpoint, content);
        var responseJson = await response.Content.ReadAsStringAsync();
        
        using var doc = JsonDocument.Parse(responseJson);
        return doc.RootElement.GetProperty("result")
                  .GetProperty("content")[0]
                  .GetProperty("text").GetString();
    }

    public void Dispose()
    {
        _httpClient?.Dispose();
    }
}

// Usage Examples
class Program
{
    static async Task Main(string[] args)
    {
        var client = new URLEncoderMCPClient("https://apistack.online", "YOUR_API_KEY");
        
        try
        {
            // Basic encoding and decoding
            var originalText = "Hello World & Special Characters!";
            var encoded = await client.EncodeUrlAsync(originalText, includeMetadata: true);
            Console.WriteLine($"Encoded: {encoded}");

            var encodedText = "Hello%20World%20%26%20Special%20Characters%21";
            var decoded = await client.DecodeUrlAsync(encodedText, includeMetadata: true);
            Console.WriteLine($"Decoded: {decoded}");

            // Component-specific encoding
            var urlComponents = new Dictionary<string, string>
            {
                ["query"] = "search term with spaces",
                ["path"] = "/api/users/john doe",
                ["fragment"] = "section with special chars!"
            };

            var encodedComponents = await client.EncodeUrlComponentsAsync(urlComponents);
            foreach (var kvp in encodedComponents)
            {
                Console.WriteLine($"{kvp.Key}: {kvp.Value}");
            }

            // Build a complete safe URL
            var pathParts = new[] { "users", "john doe", "profile" };
            var queryParams = new Dictionary<string, string>
            {
                ["search"] = "hello world",
                ["type"] = "exact match",
                ["format"] = "json"
            };

            var safeUrl = await client.BuildSafeUrlAsync(
                "https://api.example.com", 
                pathParts, 
                queryParams, 
                "user details section"
            );
            Console.WriteLine($"Safe URL: {safeUrl}");

            // Test different component types
            var testCases = new[]
            {
                new { Text = "simple text", Component = "full" },
                new { Text = "/api/path with spaces", Component = "path" },
                new { Text = "search=hello world&type=exact", Component = "query" },
                new { Text = "section with #hashtag", Component = "fragment" }
            };

            foreach (var testCase in testCases)
            {
                var result = await client.EncodeUrlAsync(
                    testCase.Text, 
                    testCase.Component, 
                    includeMetadata: true
                );
                Console.WriteLine($"{testCase.Component.ToUpper()}: {result}");
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine($"Error: {ex.Message}");
        }
        finally
        {
            client.Dispose();
        }
    }
}

๐Ÿ”’ Security & Authentication

  • Authentication Required: All requests must include a valid Bearer token
  • Plan Restrictions: Only PRO and ENTERPRISE users can access this MCP server
  • Rate Limiting: 60 requests/minute, 1000 requests/hour, 10,000 requests/day
  • Input Validation: All inputs are validated for type, length (max 8192 chars), and format
  • RFC 3986 Compliance: Follows URL encoding standards strictly
  • No Logging: Encoded/decoded content is never logged or stored

๐Ÿ“Š Response Format

All tool responses follow the MCP protocol format:

Success Response

{
  "jsonrpc": "2.0",
  "id": "request-id",
  "result": {
    "content": [
      {
        "type": "text",
        "text": "โœ… **URL Encoding Complete**\n\n**Original Text:**\n```\nhello world test!\n```\n\n**Encoded URL:**\n```\nhello%20world%20test!\n```\n\n**Component Type:** full\n**Preserve Reserved:** No\n"
      }
    ]
  }
}

Error Response

{
  "jsonrpc": "2.0",
  "id": "request-id",
  "error": {
    "code": -32603,
    "message": "Input text exceeds maximum length of 8192 characters",
    "data": "Length provided: 10000"
  }
}

๐Ÿงช Testing

Test the URL Encoder MCP server:

# Test encoding
curl -X POST http://apistack.online/api/mcp/utilities/url-encoder/sse \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "jsonrpc": "2.0",
    "id": "test-encode",
    "method": "tools/call",
    "params": {
      "name": "encode_url",
      "arguments": {
        "input": "hello world & special chars!",
        "component": "full",
        "includeMetadata": true
      }
    }
  }'

# Test decoding
curl -X POST http://apistack.online/api/mcp/utilities/url-encoder/sse \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "jsonrpc": "2.0",
    "id": "test-decode",
    "method": "tools/call",
    "params": {
      "name": "decode_url",
      "arguments": {
        "input": "hello%20world%20%26%20special%20chars%21",
        "includeMetadata": true
      }
    }
  }'

๐Ÿ—๏ธ Architecture

AI Agent/Client
       โ†“
MCP Protocol (JSON-RPC 2.0)
       โ†“
URL Encoder MCP Server (/api/mcp/utilities/url-encoder/sse)
       โ†“
Authentication & Validation
       โ†“
URL Encoder API (/api/utilities/url-encoder/v1)
       โ†“
RFC 3986 Encoding/Decoding Engine
       โ†“
Response via MCP Protocol

๐Ÿ“ Tool Schemas

encode_url Schema

{
  "name": "encode_url",
  "description": "Encode text to URL-safe percent-encoded format (RFC 3986)",
  "inputSchema": {
    "type": "object",
    "properties": {
      "input": {
        "type": "string",
        "description": "Text to encode for URL safety",
        "maxLength": 8192
      },
      "component": {
        "type": "string",
        "enum": ["full", "query", "path", "fragment"],
        "default": "full",
        "description": "URL component encoding type (full, query, path, fragment)"
      },
      "preserveReserved": {
        "type": "boolean",
        "default": false,
        "description": "Preserve reserved characters when encoding"
      },
      "includeMetadata": {
        "type": "boolean",
        "default": false,
        "description": "Include detailed encoding metadata and statistics"
      }
    },
    "required": ["input"]
  }
}

decode_url Schema

{
  "name": "decode_url",
  "description": "Decode percent-encoded URL back to original text",
  "inputSchema": {
    "type": "object",
    "properties": {
      "input": {
        "type": "string",
        "description": "Percent-encoded URL text to decode",
        "maxLength": 8192
      },
      "includeMetadata": {
        "type": "boolean",
        "default": false,
        "description": "Include detailed decoding metadata and validation"
      },
      "validateFormat": {
        "type": "boolean",
        "default": true,
        "description": "Validate that input is properly percent-encoded"
      }
    },
    "required": ["input"]
  }
}

๐ŸŽฏ Use Cases

Web Development

  • Encode URL parameters for API calls
  • Decode URLs received from webhooks
  • Build safe URLs for web applications
  • Handle international characters in URLs

API Integration

  • Prepare data for GET request parameters
  • Encode path segments for REST APIs
  • Handle URL fragments for single-page applications
  • Process webhook URLs with special characters

Data Processing

  • Clean and normalize URL data
  • Validate URL format compliance
  • Process URLs from CSV/JSON files
  • Handle URLs in data migration scenarios

Security & Compliance

  • Ensure RFC 3986 compliance
  • Prevent URL injection attacks
  • Validate URL encoding in security audits
  • Clean user-provided URL input

๐Ÿค Support

For issues, feature requests, or integration help:

  • Check the API documentation
  • Review the examples above
  • Test with the provided curl commands
  • Contact support for PRO/ENTERPRISE users

Note: This MCP server requires a PRO or ENTERPRISE subscription and valid API authentication. The server provides comprehensive functionality workflows.

Quick Info

Endpoint
/api/mcp/utilities/url-encoder/sse
Transport
Server-Sent Events (SSE)
Tools Available
2
Plan Required
PRO, ENTERPRISE

MCP Configuration

Add this configuration to your MCP client:

Note: Replace "YOUR_API_KEY" with a valid Enterprise API key. FREE plan keys will receive access errors.

{
  "mcpServers": {
    "url-encoder-utilities": {
      "command": "curl",
      "args": [
        "-X",
        "POST",
        "https://apistack.online/api/mcp/utilities/url-encoder/sse",
        "-H",
        "Content-Type: application/json",
        "-H",
        "Authorization: Bearer YOUR_API_KEY",
        "--data-raw",
        "@-"
      ],
      "transport": "sse"
    }
  }
}

Try It Out

Use the MCP configuration above in your AI client, or test the underlying APIs in our playground.

API playground requires a Enterprise subscription for access.

Open in Playground