Skip to main content

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 strategyTokensRatio
Full HTML page~7,000baseline
Visible text only~1,2006× smaller
JSON-LD record~70010× smaller
Typed field (e.g. Plumber.telephone)~30233× smaller

The benefits compound beyond token cost:

  • Determinism — LocalBusiness.telephone always 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:

StepToolPurpose
1 · Discovernxis_list_typesLearn which Schema.org types the corpus contains, with counts and hierarchy
2 · Querynxis_querySearch records of a type with field filters, sorting, semantic search, and pagination
3 · Getnxis_getFetch 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/call requests to POST 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.

Public vs. authenticated

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"]
}
ArgumentTypeDescription
limitnumberMaximum types to return, by count descending (default 200)
include_ancestorsbooleanInclude each type's ancestor chain (default false)
Result fieldTypeDescription
typesobject[]One entry per type: name, group, count, and ancestors when requested
totalnumberTotal number of types in the corpus
truncatedbooleanPresent and true when limit cut the list short

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​

ParameterTypeDescription
filter.schema_typestringRequired. The Schema.org type to query (e.g. "Restaurant", "Plumber")
filter.exact_type_matchbooleanfalse (default) expands to subtypes, so querying LocalBusiness also matches Plumber, Restaurant, etc. true matches the exact type only
filter.field_filtersobject[]Field conditions, ANDed together. See below
filter.sort_optionobject{ property, order }, where order is ASCENDING or DESCENDING
textstringSemantic search over the matched records
limitnumberPage size, 1–100 (default 10)
page_tokenstringResume 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.

OperatorMatches when the field…
EQUALSequals the value
NOT_EQUALSdoes not equal the value
GREATER_THANis greater than the value
GREATER_THAN_OR_EQUALis greater than or equal to the value
LESS_THANis less than the value
LESS_THAN_OR_EQUALis less than or equal to the value
CONTAINScontains the value (substring / membership)
INequals any of the given values
EXISTSis 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​

FieldTypeDescription
resultsobject[]Matching JSON-LD entity objects
totalnumberTotal matching entities across all pages
matched_typesstring[]Types that matched, including any subtypes expanded from schema_type
next_page_tokenstring | nullPass 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 fieldTypeDescription
resultobjectThe full JSON-LD entity
scorenumberRelevance 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() or callTool().
  • Tool errors (bad arguments, a rate limit, a site that isn't public) come back as a normal result with isError: true and the reason in content. The call() helper above turns those into a thrown Error.

A rate-limited read says how long to wait before trying again.


Honest scope

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.