Programmatic QR code generation: API vs AI agents

Compare three approaches to programmatic QR code generation — REST API with SDKs, CLI automation, and AI agents via MCP. Understand when to use each method and how Linkbreakers supports all three.

Developer
6 min read
By Laurent Schaffner
Updated June 6, 2026

Short answer

There are three ways to generate and manage QR codes programmatically: REST APIs with SDKs, CLI scripting, and AI agents via MCP. Each approach serves different use cases. REST APIs are best for production applications that need reliability and control. CLI scripting fits DevOps pipelines and batch operations. AI agents through MCP enable conversational, ad-hoc operations without writing code. Linkbreakers is the only QR code platform that natively supports all three approaches on the same infrastructure.

Quick summary

  • REST API + SDKs — Best for production apps. Full control, type safety, error handling. Available in TypeScript, Python, Go, Java, and Rust.
  • CLI — Best for shell scripts, CI/CD, and quick terminal operations. Supports JSON output for machine parsing.
  • MCP AI agents — Best for ad-hoc tasks, prototyping, and non-technical users. Natural language operations through Claude Code or Claude Desktop.
  • All three connect to the same Linkbreakers API and produce identical results
  • Choose based on your use case: automation reliability (API), DevOps integration (CLI), or speed and flexibility (MCP)

The three approaches compared

REST API with SDKs

The traditional and most powerful approach. You write code using an official SDK, which calls the Linkbreakers REST API directly.

TypeScript example:

TypeScript
import { Configuration, LinksApi } from 'linkbreakers';

const config = new Configuration({
  accessToken: process.env.LINKBREAKERS_SECRET_KEY,
  basePath: 'https://api.linkbreakers.com',
});

const api = new LinksApi(config);

const response = await api.linksServiceCreate({
  createLinkRequest: {
    destination: 'https://example.com/spring-sale',
    name: 'Spring Sale Campaign',
    tags: ['marketing', 'spring-2026'],
  },
});

console.log(`Short URL: ${response.link.shortlink}`);
console.log(`QR Code: ${response.link.qrcodeSignedUrl}`);

Python example:

Python
from linkbreakers import Configuration, LinksApi

config = Configuration(
    access_token=os.environ['LINKBREAKERS_SECRET_KEY'],
    host='https://api.linkbreakers.com'
)

api = LinksApi(config)
response = api.links_service_create(
    create_link_request={
        'destination': 'https://example.com/spring-sale',
        'name': 'Spring Sale Campaign',
        'tags': ['marketing', 'spring-2026'],
    }
)

print(f"Short URL: {response.link.shortlink}")

When to use:

  • Production applications that run continuously
  • High-volume batch operations (bulk link creation)
  • Systems that need retry logic, error handling, and type safety
  • Integration into existing codebases

CLI scripting

Terminal-based access using the Linkbreakers CLI. Designed for both human operators and automated scripts.

Bash
# Create a link
linkbreakers links create \
  --destination "https://example.com/spring-sale" \
  --name "Spring Sale Campaign" \
  --tags marketing,spring-2026

# List links as JSON for scripting
linkbreakers links list --output json | jq '.links[].shortlink'

# Bulk create from a file
while IFS=, read -r url name tags; do
  linkbreakers links create \
    --destination "$url" \
    --name "$name" \
    --tags "$tags"
done < campaigns.csv

When to use:

  • CI/CD pipelines (create campaign links during deployment)
  • Shell scripts and cron jobs
  • Quick one-off operations from the terminal
  • Environments where installing an SDK is impractical

MCP AI agents

Natural language operations through any MCP-compatible AI client. No code required.

Setup (one command for Claude Code):

Bash
claude mcp add --transport http linkbreakers https://mcp.linkbreakers.com \
  --header "Authorization: Bearer YOUR_WORKSPACE_TOKEN"

Usage — just describe what you want:

"Create a tracked link for our spring sale at example.com/spring-sale. Tag it with marketing and spring-2026."

"Create 10 links for each product in this list, tag them all with product-catalog, and show me a summary table."

"Build a workflow with a form collecting name and email, then redirect to our thank-you page."

When to use:

  • Ad-hoc campaign setup without writing code
  • Prototyping workflows before building them into production systems
  • Non-technical team members who need to create links and pull analytics
  • Complex multi-step operations described faster in natural language than code

Feature comparison

Capability REST API + SDK CLI MCP Agent
Link creation Full control Full control Natural language
Bulk operations Programmatic loops Shell scripts Conversational batching
Workflow steps Full CRUD Limited Full CRUD
QR code design Create + customize Not available Create + customize
Analytics Query + aggregate List events Query + interpret
Custom domains Full management Full management Not available
Visitor identification Full tracking Not available Full tracking
Error handling Try/catch, retries Exit codes AI-managed
Type safety Full (TS, Go, Java, Rust) N/A N/A
Authentication Secret key / publishable key Workspace token Workspace token
Best for Production apps DevOps, scripting Ad-hoc, prototyping

Combining approaches

The approaches are not mutually exclusive. A common pattern:

  1. Prototype with MCP — Use Claude Code to quickly build and test a campaign workflow through conversation
  2. Automate with CLI — Add link creation to your deployment pipeline for recurring campaigns
  3. Integrate with SDK — Build the visitor tracking and analytics into your production application

All three connect to the same API and operate on the same workspace data. A link created through MCP appears identically in the CLI and SDK responses.

Performance considerations

API + SDK offers the lowest latency and highest throughput. Direct HTTP calls with connection pooling give you sub-100ms response times and the ability to parallelize requests.

CLI adds a small overhead per invocation (process startup, authentication lookup) but is negligible for most use cases. For high-volume batch operations, prefer the SDK.

MCP has the highest latency because each request goes through the AI model's reasoning loop. An operation that takes 100ms via the API might take 2-5 seconds via MCP as the model processes the request. This is acceptable for interactive use but not for high-throughput automation.

Why one platform matters

Most QR code services offer only a REST API — if they offer programmatic access at all. Having all three approaches on the same platform means:

  • No vendor lock-in on tooling — Switch between approaches without switching platforms
  • Consistent data model — Same links, same workflows, same analytics regardless of how they were created
  • Gradual adoption — Start with MCP for prototyping, move to SDK for production, without migrating data
  • Team flexibility — Developers use the SDK, marketing uses MCP, DevOps uses the CLI, all on the same workspace

Frequently Asked Questions

Can I mix API and MCP operations on the same workspace? Yes. All three approaches operate on the same workspace data. A link created via MCP is identical to one created via the SDK or CLI.

Which approach is fastest for creating a single link? MCP is fastest in wall-clock time for a human — you describe what you want and it's done. The API is fastest in execution time — a single HTTP call completes in under 100ms.

Do I need different credentials for each approach? The SDK uses secret keys or publishable keys. The CLI and MCP server use workspace tokens. All are created in the same dashboard section (Dashboard → API Tokens).

Can AI agents build complex workflows? Yes. MCP agents can create multi-step workflows with password gates, forms, conditional routing, contact cards, and social links pages — the same operations available through the API.

Is there a cost difference between approaches? No. All approaches use the same API and count toward the same rate limits and plan quotas.

What if I need an operation that MCP doesn't support? The MCP server exposes 35+ operations covering the most common use cases. For operations not yet exposed via MCP, use the REST API or CLI directly.

Getting started

Limits and caveats

  • All approaches share the same rate limits based on your workspace plan.
  • MCP operations have higher latency than direct API calls due to AI model processing time.
  • Some advanced operations (custom domain DNS verification, QR code template publishing) are only available through the REST API.
  • CLI does not currently support QR code design creation or visitor identification.
  • Feature availability and limits can vary by plan and workspace setup.

About the Author

LS

Laurent Schaffner

Founder & Engineer at Linkbreakers

Passionate about building tools that help businesses track and optimize their digital marketing efforts. Laurent founded Linkbreakers to make QR code analytics accessible and actionable for companies of all sizes.