url_encode
Percent-encode a string so it is safe to embed in a URL component such as a query parameter value,
a path segment, or an authority credential. Follows RFC 3986 — only unreserved characters
(A–Z a–z 0–9 - _ . ~) are left unencoded.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | Yes | The string to percent-encode (e.g. "hello world" → "hello%20world"). |
Response
| Field | Type | Description |
|---|---|---|
encoded | string | Percent-encoded string safe for use in a URL component. |
Examples
Input:
{
"input": "hello world"
}
Result:
{
"encoded": "hello%20world"
}
Input (query parameter with special characters):
{
"input": "key=value&other=x"
}
Result:
{
"encoded": "key%3Dvalue%26other%3Dx"
}
Input (Unicode):
{
"input": "héllo"
}
Result:
{
"encoded": "h%C3%A9llo"
}
Errors
Each failure carries a precise code in the response. Argument-schema and server errors are JSON-RPC protocol errors; a rejected value is returned as a tool result with isError: true (so the agent can read the code and self-correct).
Any valid UTF-8 string can be percent-encoded, so this tool never rejects the input value itself — only an ill-formed request or a server fault can fail.
| Code | When | Delivered as |
|---|---|---|
invalid_arguments | An argument is missing or the wrong type. | protocol error (invalid_params) |
internal_error | An unexpected server error. | protocol error (internal_error) |
Notes
- This tool follows RFC 3986 percent-encoding. The
+character is not treated as a space — that convention belongs toapplication/x-www-form-urlencoded(HTML form encoding), which is a different encoding scheme. - Encode individual values before embedding them in a query string. Do not encode an already
assembled query string like
key=value&other=xas a whole — that would double-encode the=and&separators. - To decode a percent-encoded string, use
url_decode.