Skip to content
SZ-MCP
Get Support

Examples

You do not write these programs yourself — Claude does, from a plain-language request. They are here so you can see what it is composing on your behalf, and so you can ask for something shaped like one.

Each example is the body of an async arrow function, which is what code_mode takes.

Start here. These are requests that map onto the programs below:

List the AP zones on my SmartZone and how many APs are in each.

Find the endpoint that creates a WLAN and tell me what fields it requires.

How many switches are in each switch group?

Show me every DHCP-related endpoint on the wireless API.

The simplest useful call — a GET with pagination parameters, checking ok before touching the body.

async () => {
const r = await wifi.call({
method: 'GET',
path: '/domains',
query: { listSize: 100, index: 0 },
});
if (!r.ok) return { error: r.status, body: r.body };
return {
total: r.body?.totalCount,
names: r.body?.list?.map(d => d.name),
};
}

WSG list endpoints typically return { list, hasMore, totalCount }, which is what makes the shape above work across most of the surface.

Discover an endpoint, then read its schema

Section titled “Discover an endpoint, then read its schema”

Discovery and inspection in one run — no round trip back to the model between the two steps.

async () => {
const hits = await wifi.search_endpoints({ query: 'wlan', limit: 5 });
if (hits.results.length === 0) return { found: 0 };
const top = hits.results.find(e => e.method === 'POST') ?? hits.results[0];
const details = await wifi.get_endpoint_details({
method: top.method,
path: top.path,
});
// Swagger 2.0: the body schema is a parameter, not `requestBody`.
const bodyParam = details.parameters?.find(p => p.in === 'body');
const required = details.parameters?.filter(p => p.required).map(p => p.name);
return { endpoint: `${top.method} ${top.path}`, required, bodyParam };
}

Note the parameters lookup rather than requestBody — on these specs requestBody is always null. See Code mode primitives.

The run budget is 20 seconds of wall clock, shared by every call the program makes. Bound the loop explicitly rather than trusting hasMore to terminate it.

async () => {
const all = [];
const listSize = 100;
let index = 0;
for (let page = 0; page < 10; page++) {
const r = await wifi.call({
method: 'GET',
path: '/domains',
query: { listSize, index },
});
if (!r.ok) return { error: r.status, body: r.body, collected: all.length };
all.push(...(r.body?.list ?? []));
if (!r.body?.hasMore) break;
index += listSize;
}
return { count: all.length };
}

If the cap is reached before hasMore goes false, return what you have and continue in a fresh code_mode call — each one gets its own budget.

{placeholder} segments are filled from pathParams and URL-encoded for you.

async () => {
const r = await wifi.call({
method: 'GET',
path: '/rkszones/{zoneId}/wlans',
pathParams: { zoneId: 'd1f2a3b4-0000-0000-0000-000000000000' },
query: { listSize: 50, index: 0 },
});
return r.ok
? { count: r.body?.totalCount }
: { failed: r.status, statusText: r.statusText };
}

switches works identically, against SwitchM. Start from the tag list, which is the top of the discovery hierarchy on both surfaces.

async () => {
const { tags } = await switches.list_tags();
const switchTags = tags
.filter(t => t.operationCount > 5)
.sort((a, b) => b.operationCount - a.operationCount);
const health = await switches.list_endpoints_by_tag({
tag: 'Switch Health',
method: 'GET',
});
return {
biggestTags: switchTags.slice(0, 5),
healthEndpoints: health.results.map(e => `${e.method} ${e.path}`),
};
}

Nothing stops a single program touching both namespaces — they share the run budget and the detected API version.

async () => {
const [zones, sw] = await Promise.all([
wifi.call({ method: 'GET', path: '/rkszones', query: { listSize: 100, index: 0 } }),
switches.call({ method: 'GET', path: '/switches', query: { listSize: 100, index: 0 } }),
]);
return {
zones: zones.ok ? zones.body?.totalCount : { error: zones.status },
switches: sw.ok ? sw.body?.totalCount : { error: sw.status },
};
}