utilities
Encode and decode URLs with support for different encoding types through MCP protocol
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 PlansDecode percent-encoded URL back to original text
Encode text to URL-safe percent-encoded format (RFC 3986)
The URL Encoder/Decoder MCP server provides comprehensive URL encoding and decoding functionality through the Model Context Protocol (MCP). This server provides comprehensive functionality.
This MCP server exposes 2 tools for AI agents:
encode_urlPurpose: Encode text to URL-safe percent-encoded format (RFC 3986)
input (string), component (full|query|path|fragment), encoding optionsdecode_urlPurpose: Decode percent-encoded URL back to original text
input (percent-encoded string), validation options/api/mcp/utilities/url-encoder/sse/api/utilities/url-encoder/v1Endpoint: https://apistack.online/api/mcp/utilities/url-encoder/sse
Method: POST
Headers:
Content-Type: application/json
Authorization: Bearer YOUR_API_KEY
{
"jsonrpc": "2.0",
"id": "list-tools",
"method": "tools/list"
}
{
"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
}
}
}
{
"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
}
}
}
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}")
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);
}
})();
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();
}
}
}
All tool responses follow the MCP protocol format:
{
"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"
}
]
}
}
{
"jsonrpc": "2.0",
"id": "request-id",
"error": {
"code": -32603,
"message": "Input text exceeds maximum length of 8192 characters",
"data": "Length provided: 10000"
}
}
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
}
}
}'
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
{
"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"]
}
}
{
"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"]
}
}
For issues, feature requests, or integration help:
Note: This MCP server requires a PRO or ENTERPRISE subscription and valid API authentication. The server provides comprehensive functionality workflows.
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"
}
}
}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.