# Base64 & Binary Encoder MCP

> Base64 & Binary Encoder handles data corruption when you move files or raw data through APIs. Use this MCP to safely encode and decode strings into standard Base64, Hex, or URL-safe formats without losing characters.

## Overview
- **Category:** data
- **Price:** Free
- **Tags:** base64, hex, binary, encoding, decoder

## Description

Moving non-textual data—like image bytes, encrypted payloads, or structured logs—through modern APIs is a pain point. Most web services expect everything in string format, but raw binary data will corrupt the payload if you just paste it into JSON or XML. This MCP solves that by managing all the dirty work of encoding and decoding.

It uses an underlying engine to guarantee zero data loss when converting UTF-8 buffers into standard Base64, Hex, or URL-safe equivalents. You can encode complex strings for transmission, and just as easily, decode those payloads back into usable raw text. If you're connecting your AI agent workflow through the Vinkius catalog, this MCP ensures that regardless of what format your API requires, your data payload remains intact.

## Tools

### encode_binary
This tool encodes or decodes strings into Base64, Base64URL, or Hex formats safely without any data loss.

## Prompt Examples

**Prompt:** 
```
Encode this long string into Base64 so I can append it to the API call.
```

**Response:** 
```
Binary Output: Returned valid Base64 string.
```

**Prompt:** 
```
Decode this Hex payload back into readable UTF-8 text.
```

**Response:** 
```
Binary Output: Extracted raw string successfully.
```

**Prompt:** 
```
Convert this text into Base64URL format to be used as a JWT payload.
```

**Response:** 
```
Encoded Output: Generated URL-safe Base64 string.
```

## Capabilities

### Encode binary content
Converts raw strings into Base64, Hex, or URL-safe formats for safe API transmission.

### Decode various payloads
Takes encoded data and reliably converts it back to readable text or original binary structures.

### Handle JWT formatting
Generates URL-safe Base64 strings, perfect for secure tokens like JSON Web Tokens (JWT).

## Use Cases

### Sending an image attachment via API
A user wants their AI agent to send a screenshot. Instead of failing because the raw PNG data is binary, your agent calls `encode_binary` first. This converts the image into a safe Base64 string that the receiving service accepts and processes.

### Debugging network packets
A connection fails, leaving only a Hex dump of the failure point. You pass this payload to the MCP's decoding function. It returns the clean, readable text necessary for your ops engineer to identify the exact protocol error.

### Generating secure user tokens
Your system needs a JWT token. Instead of risking invalid characters in the payload, you use `encode_binary` with Base64URL encoding on the claim data. This guarantees the resulting string is safe for web URLs.

### Passing serialized model inputs
A machine learning module outputs a complex set of bytes that needs to be passed as an API argument. You encode these bytes into Base64, ensuring the upstream service treats them as a simple string input without failing.

## Benefits

- Stops payload corruption: You can safely transmit file attachments or complex buffers because the tool handles conversion to Base64, preventing characters from getting lost in transit.
- Creates secure tokens easily: Use the encoder to generate URL-safe Base64 strings. This is critical for correctly formatting JWT payloads used across microservices.
- Simplifies debugging logs: Instead of manually converting hex dumps or raw data into a readable format, you use this MCP to decode them directly and get clean UTF-8 text back.
- Maintains data integrity: It handles the nuances of different character sets (UTF-8) and encoding standards (Base64 vs. Hex), so your original data always makes it to its destination.
- Builds complex pipelines: You can chain this MCP into larger workflows, letting your agent reliably manage and pass non-textual inputs between various systems.

## How It Works

The bottom line is you get reliable, corruption-proof data payloads every time.

1. Pass the raw data or string you need to encode into this MCP.
2. Specify the required format and direction (e.g., Base64, Hex) using the encoder tool.
3. Receive a clean, validated output payload ready for direct use in your API call.

## Frequently Asked Questions

**Does it support URL-safe Base64?**
Yes, just pass `base64url` as the format argument. It removes `+` and `/` characters.

**Is this needed if my LLM can write code?**
Yes, because the LLM is running in a sandbox without a Node.js runtime. This MCP gives the LLM direct access to `Buffer` execution.

**What happens if I try to decode an invalid Base64 string?**
The V8 engine will safely catch the error and return a formatted error message without crashing your agent.

**How does the `encode_binary` tool handle different data types like UTF-8 vs raw bytes?**
It handles both. The MCP ensures that whether you pass a standard UTF-8 string or raw binary data, it processes the payload correctly before encoding. This means you don't have to worry about losing characters when preparing complex payloads for API calls.

**What is the input limit for `encode_binary`? Can I process very large files?**
While there isn't a hard-coded file size limit, performance depends on the length of the payload. For massive data streams, you should chunk your input and run multiple calls to avoid timeouts or memory issues in your agent.

**Does `encode_binary` support all encoding formats I might encounter, like MIME types?**
No, it strictly supports standard Base64, Hexadecimal, and URL-safe Base64 formats. If you're dealing with a proprietary or complex MIME type, you'll need to pre-process the data outside of this MCP first.

**If I use `encode_binary` frequently, are there any rate limits I should be aware of?**
Vinkius manages resource allocation across all connected clients. Generally, you won't hit immediate rate limits unless your entire agent workflow is designed to spam the endpoint continuously.

**What happens if my AI client sends malformed input to `encode_binary`?**
The tool validates all inputs before processing. If the data doesn't match the expected format (e.g., trying to decode a non-hex string), it returns a clear, descriptive error message so your agent knows exactly what went wrong.