b59.link MCP Server
b59.link exposes a Model Context Protocol (MCP) server at https://b59.link/api/mcp. Connect Claude, OpenAI, or Gemini agents to shorten links, generate QR codes, and read stats — without any sign-up.
Available tools
shorten_urlShorten a long URL. Returns a short_url and stats_url. Custom slug optional.
Parameters
url: string // required
slug?: string // optional custom slugReturns
{
slug: string,
short_url: string,
stats_url: string
}generate_qrGenerate a QR code for a URL and create a short link at the same time.
Parameters
url: string // requiredReturns
{
slug: string,
short_url: string,
stats_url: string,
qr_code_data: string // base64 PNG
}get_statsGet click statistics. Pass a slug (e.g. 'cool-jump') or the original URL.
Parameters
identifier: string // slug or original URLReturns
{
slug: string,
original_url: string,
short_url: string,
total_hits: number
}lookup_urlCheck if a URL already has a b59 link. Handles http/https/www/trailing-slash variations.
Parameters
url: string // requiredReturns
{ found: false }
// or
{
found: true,
slug: string,
short_url: string,
stats_url: string,
qr_code_data: string | null
}Use with Claude (claude.ai)
In Claude's settings, add a new MCP server with the URL below. Claude will automatically discover the available tools and can call them during conversation.
https://b59.link/api/mcpExample prompt: "Shorten https://my-long-url.com/path and give me a QR code."
Use with Claude Code (CLI)
Add b59.link as an MCP server in your ~/.claude/claude.json or via the CLI:
Via CLI
claude mcp add b59link --transport http https://b59.link/api/mcpOr add to claude.json manually
{
"mcpServers": {
"b59link": {
"type": "http",
"url": "https://b59.link/api/mcp"
}
}
}After adding, restart Claude Code. Type /mcp to verify the server is connected.
Use with OpenAI
Fetch the OpenAI-compatible function schema and pass it as the tools parameter. Route tool calls to POST /api/mcp.
import OpenAI from "openai";
const openai = new OpenAI();
// 1. Fetch tool definitions
const schemaRes = await fetch("https://b59.link/api/mcp/schema");
const { tools } = await schemaRes.json();
// 2. Call the model
const response = await openai.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "Shorten https://example.com/long/path" }],
tools,
tool_choice: "auto",
});
// 3. Execute tool calls
const msg = response.choices[0].message;
if (msg.tool_calls) {
for (const call of msg.tool_calls) {
const mcpRes = await fetch("https://b59.link/api/mcp", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "tools/call",
params: {
name: call.function.name,
arguments: JSON.parse(call.function.arguments),
},
}),
});
const result = await mcpRes.json();
console.log(result.result.content[0].text);
}
}Use with Gemini
Gemini uses the same function-calling schema as OpenAI. Fetch the schema and convert it to Gemini's FunctionDeclaration format.
import { GoogleGenerativeAI } from "@google/generative-ai";
const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY);
// Fetch and convert tool schema
const { tools: openaiTools } = await fetch("https://b59.link/api/mcp/schema").then(r => r.json());
const tools = [{
functionDeclarations: openaiTools.map(t => ({
name: t.function.name,
description: t.function.description,
parameters: t.function.parameters,
})),
}];
const model = genAI.getGenerativeModel({ model: "gemini-1.5-pro", tools });
const chat = model.startChat();
const result = await chat.sendMessage("Shorten https://example.com for me.");
// Handle function calls
const response = result.response;
const calls = response.functionCalls();
if (calls) {
for (const call of calls) {
const mcpRes = await fetch("https://b59.link/api/mcp", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
jsonrpc: "2.0", id: 1,
method: "tools/call",
params: { name: call.name, arguments: call.args },
}),
});
const toolResult = await mcpRes.json();
console.log(toolResult.result.content[0].text);
}
}Raw JSON-RPC
The MCP server speaks JSON-RPC 2.0 over HTTP POST. Supported methods: initialize, tools/list, tools/call, ping.
List tools
curl -X POST https://b59.link/api/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'Call a tool
curl -X POST https://b59.link/api/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "shorten_url",
"arguments": {
"url": "https://example.com/very/long/path",
"slug": "my-link"
}
}
}'