Using slim.to with Gemini
Two ways in: the MCP server (Gemini CLI, Google GenAI SDK) or the REST API (function calling, scripts).
Prerequisite for both: a personal API key.
Approach 1 — MCP server
Gemini CLI
Add the server to ~/.gemini/settings.json (global) or
.gemini/settings.json in a project:
{
"mcpServers": {
"slimto": {
"command": "uvx",
"args": ["--from", "/path/to/slimto/mcp", "slimto-mcp"],
"env": {
"SLIMTO_API_KEY": "slim_your_key_here"
}
}
}
}
Restart the CLI and check with /mcp — the four slimto tools should be
listed. Then:
You: Generate the launch one-pager as HTML and give me a slim.to link.
Gemini: (writes the file, calls
create_link_from_file) Your link: https://slim.to/9c4oww
Google GenAI SDK (Python)
The google-genai SDK accepts a live MCP ClientSession directly as a tool:
import asyncio
from google import genai
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
client = genai.Client() # GEMINI_API_KEY in env
server = StdioServerParameters(
command="uvx",
args=["--from", "/path/to/slimto/mcp", "slimto-mcp"],
env={"SLIMTO_API_KEY": "slim_your_key_here"},
)
async def main():
async with stdio_client(server) as (read, write):
async with ClientSession(read, write) as session:
await session.initialize()
response = await client.aio.models.generate_content(
model="gemini-2.5-pro",
contents="Shorten https://example.com/signup as slug 'launch' and report the link.",
config=genai.types.GenerateContentConfig(tools=[session]),
)
print(response.text)
asyncio.run(main())
Approach 2 — REST API
Declare slim.to operations as ordinary Gemini function tools and implement them with HTTP calls:
import os, requests
from google import genai
from google.genai import types
def create_short_link(target_url: str, title: str = "") -> dict:
"""Create a tracked slim.to short link for a URL."""
r = requests.post(
"https://slim.to/api/v1/links",
headers={"X-API-Key": os.environ["SLIMTO_API_KEY"]},
json={"target_url": target_url, "title": title or None},
)
r.raise_for_status()
return {"short_url": r.json()["short_url"]}
client = genai.Client()
response = client.models.generate_content(
model="gemini-2.5-pro",
contents="Shorten https://example.com/pricing and give me the link.",
config=types.GenerateContentConfig(tools=[create_short_link]), # auto function calling
)
print(response.text)
For file uploads and analytics, add functions wrapping
POST /api/v1/files (multipart) and GET /api/v1/analytics/links/{id} —
see the API quickstart for the exact shapes.
Which approach?
| MCP | REST function tools | |
|---|---|---|
| Gemini CLI | ✅ one config block | ❌ (CLI can still curl on request) |
| GenAI SDK apps | ✅ pass the session as a tool | ✅ a few lines per function |
| Discoverability | tools + descriptions come from the server | you write the declarations |