Typed Retrieval Reference
Typed retrieval is how agents read your site: instead of fetching pages and extracting facts from prose, they query your knowledge graph and get values by contract — structured JSON-LD fields, filtered and sorted in the index. This page is the full reference for the three retrieval tools on your site's MCP server: nxis_list_types, nxis_query, and nxis_get.
Why typed, not scraped
On a typical business page, under 5% of the loaded tokens contain useful information. Typed retrieval returns just the fields:
| Retrieval strategy | Tokens | Ratio |
|---|---|---|
| Full HTML page | ~7,000 | baseline |
| Visible text only | ~1,200 | 6× smaller |
| JSON-LD record | ~700 | 10× smaller |
Typed field (e.g. Plumber.telephone) | ~30 | 233× smaller |
The benefits compound beyond token cost:
- Determinism —
LocalBusiness.telephonealways returns the telephone field. No extraction, no disambiguation, no hallucination surface. - Composability — typed fields can be filtered, aggregated, and sorted deterministically in the index.
- Reproducibility — same query, same data, same result, every time. Auditable and testable.
The discover → query → get pattern
Every retrieval session follows the same three steps:
| Step | Tool | Purpose |
|---|---|---|
| 1 · Discover | nxis_list_types | Learn which Schema.org types the corpus contains, with counts and hierarchy |
| 2 · Query | nxis_query | Search records of a type with field filters, sorting, semantic search, and pagination |
| 3 · Get | nxis_get | Fetch one entity's full JSON-LD by its canonical @id |
An agent never guesses what a site offers — it lists the types, narrows with filters, then pulls full records only for the entities it actually needs.
Two ways to call
Every example below is shown both ways:
- Raw MCP: JSON-RPC
tools/callrequests toPOST https://<your-domain>.mcp.nxis.ai/mcp, for agents and clients that speak MCP directly. - TypeScript: the official MCP SDK,
@modelcontextprotocol/sdk, connected to the same endpoint by URL. NxisAI doesn't publish a separate client package; any MCP client works.
npm install @modelcontextprotocol/sdk
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
const transport = new StreamableHTTPClientTransport(
new URL("https://acme.mcp.nxis.ai/mcp"),
// Omit requestInit for a site with Public Access on.
{ requestInit: { headers: { "nxis-api-key": process.env.NXIS_API_KEY! } } },
);
const client = new Client({ name: "my-agent", version: "1.0.0" });
await client.connect(transport);
// Each tool answers with JSON; read it from structuredContent, or parse the text content.
async function call(name: string, args: Record<string, unknown> = {}) {
const res = await client.callTool({ name, arguments: args });
if (res.isError) throw new Error(JSON.stringify(res.content));
if (res.structuredContent) return res.structuredContent as any;
const [first] = res.content as { type: string; text: string }[];
return JSON.parse(first.text);
}
// ... nxis_list_types / nxis_query / nxis_get ...
await client.close();
From a terminal, the NxisAI CLI runs the same reads against a public site: nxis types and nxis query <type> --filter path=op:value.
The three retrieval tools are the only tools available without an API key, and only on sites that enable Public Access, at a stricter rate limit. See Public vs. authenticated access.
nxis_list_types — discover
Lists every Schema.org type present in the corpus. Each entry carries the type's name, its specialist group and the entity count. With include_ancestors: true, it also carries the type's Schema.org ancestors, so an agent can tell that Plumber is a LocalBusiness without knowing your site in advance.
Raw MCP:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "nxis_list_types",
"arguments": { "include_ancestors": true }
}
}
TypeScript:
const { types, total } = await call("nxis_list_types", { include_ancestors: true });
for (const t of types) {
console.log(`${t.name} (${t.count}) — group: ${t.group}`);
// t.ancestors → e.g. ["Thing", "Organization", "LocalBusiness", "HomeAndConstructionBusiness"]
}
| Argument | Type | Description |
|---|---|---|
limit | number | Maximum types to return, by count descending (default 200) |
include_ancestors | boolean | Include each type's ancestor chain (default false) |
| Result field | Type | Description |
|---|---|---|
types | object[] | One entry per type: name, group, count, and ancestors when requested |
total | number | Total number of types in the corpus |
truncated | boolean | Present and true when limit cut the list short |
nxis_query — search
Searches typed records with filters, sorting, semantic search, and pagination, executed in the index rather than in memory.
Raw MCP:
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "nxis_query",
"arguments": {
"filter": {
"schema_type": "Plumber",
"field_filters": [
{ "path": "areaServed.postalCode", "operator": "EQUALS", "value": "48067" },
{ "path": "aggregateRating.ratingValue", "operator": "GREATER_THAN_OR_EQUAL", "value": 4.0 }
],
"sort_option": {
"property": "aggregateRating.ratingValue",
"order": "DESCENDING"
}
},
"text": "emergency plumbing",
"limit": 5
}
}
}
TypeScript:
const result = await call("nxis_query", {
filter: {
schema_type: "Plumber",
field_filters: [
{ path: "areaServed.postalCode", operator: "EQUALS", value: "48067" },
{ path: "aggregateRating.ratingValue", operator: "GREATER_THAN_OR_EQUAL", value: 4.0 },
],
sort_option: { property: "aggregateRating.ratingValue", order: "DESCENDING" },
},
text: "emergency plumbing",
limit: 5,
});
Parameters
| Parameter | Type | Description |
|---|---|---|
filter.schema_type | string | Required. The Schema.org type to query (e.g. "Restaurant", "Plumber") |
filter.exact_type_match | boolean | false (default) expands to subtypes, so querying LocalBusiness also matches Plumber, Restaurant, etc. true matches the exact type only |
filter.field_filters | object[] | Field conditions, ANDed together. See below |
filter.sort_option | object | { property, order }, where order is ASCENDING or DESCENDING |
text | string | Semantic search over the matched records |
limit | number | Page size, 1–100 (default 10) |
page_token | string | Resume token from a previous result's next_page_token |
Field filters
Each field filter is { path, operator, value }. The path is a dotted JSON-LD path into the entity. Nested objects are traversed with ., so "aggregateRating.ratingValue" reaches the ratingValue inside the entity's aggregateRating.
| Operator | Matches when the field… |
|---|---|
EQUALS | equals the value |
NOT_EQUALS | does not equal the value |
GREATER_THAN | is greater than the value |
GREATER_THAN_OR_EQUAL | is greater than or equal to the value |
LESS_THAN | is less than the value |
LESS_THAN_OR_EQUAL | is less than or equal to the value |
CONTAINS | contains the value (substring / membership) |
IN | equals any of the given values |
EXISTS | is present on the entity at all (no value needed) |
EQUALS, NOT_EQUALS and IN only match a stored value of the same JSON type. A ZIP code stored as the text "48067" isn't matched by the number 48067.
Result shape
| Field | Type | Description |
|---|---|---|
results | object[] | Matching JSON-LD entity objects |
total | number | Total matching entities across all pages |
matched_types | string[] | Types that matched, including any subtypes expanded from schema_type |
next_page_token | string | null | Pass as page_token to fetch the next page; null when exhausted |
Paginating everything
Follow next_page_token until it's null:
let page_token: string | undefined;
do {
const page = await call("nxis_query", {
filter: { schema_type: "Product" },
limit: 50,
...(page_token ? { page_token } : {}),
});
for (const entity of page.results) console.log(entity["name"]);
page_token = page.next_page_token ?? undefined;
} while (page_token);
nxis_get — fetch
Fetches a single entity's full JSON-LD by its canonical @id. That's the same @id that appears on entities in nxis_query results, which is how the two tools chain.
Raw MCP:
{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": {
"name": "nxis_get",
"arguments": {
"id": "https://royaloak.example.com/hatzel-and-sons-plumbing"
}
}
}
TypeScript:
const { result, score } = await call("nxis_get", {
id: "https://royaloak.example.com/hatzel-and-sons-plumbing",
});
| Result field | Type | Description |
|---|---|---|
result | object | The full JSON-LD entity |
score | number | Relevance score (0–1) |
Error handling
Failures arrive in two standard MCP forms:
- Protocol errors (a failed connection or handshake, or an unknown tool) are JSON-RPC error responses. The MCP SDK throws them from
connect()orcallTool(). - Tool errors (bad arguments, a rate limit, a site that isn't public) come back as a normal result with
isError: trueand the reason incontent. Thecall()helper above turns those into a thrownError.
A rate-limited read says how long to wait before trying again.
Typed retrieval covers reading the corpus. It returns what the structured data layer contains — no more, no less; if a field wasn't extracted or published, no query will surface it. To act on what you retrieve (quotes, bookings, orders), see Actions & Bindings.
Related
- MCP for AI Agents — endpoints, API keys, OAuth 2.1, and public access
- Actions & Bindings — execute the actions discovered on entities
- Agent Skills Library — packaged skills built on discover → query → get
- agents.md & llms.txt — publish the retrieval pattern for visiting agents