DIM · Dagon Inference Marketplace

MCP tools

The discovery index serves two read-only MCP tools, list_routes and get_route, so an AI assistant or agent framework can browse DIM routes the way it calls any other tool. Every result is a signed envelope bound to your exact tool name and arguments, so a client can prove the answer came from the index it pinned. The tools only discover; paying for inference still goes through a client that signs holds, such as the SDK.

Connecting

The index speaks MCP over two transports:

  • Streamable HTTP at POST <index>/mcp. It is stateless: each POST gets one JSON response; there is no standalone SSE stream, and GET, DELETE and HEAD return a signed 405. Request bodies are limited to 16 KiB, and browser origins must be allowlisted by the operator.
  • stdio, by running the index yourself: bun services/discovery/src/cli.ts stdio indexer.json. This starts your own index from its configuration file, so you also need the seller and operator pins that file holds.

Point any MCP client that supports Streamable HTTP at the index's /mcp URL. How you register a server depends on your client.

list_routes

Lists verified routes with their seller and probe evidence.

Argument Type Meaning
model_identity_id 64 lowercase hex Only routes for this exact model identity.
family string, 1–256 characters Only routes in this model family.
limit integer 1–200 Routes per page. The index default is 100.
cursor string The next_cursor of a previous page, with the same filters.

All arguments are optional, and unknown arguments are rejected. The signed document contains:

  • listings: each full signed seller listing once, keyed by the lowercase hex SHA-256 of its canonical {doc, key, sig};
  • routes: entries of {listing_digest, route_id, capacity, observations, score_inputs};
  • next_cursor: a string for the next page, or null on the last page;
  • query and issued_at: the tool call it answers and when it was signed.

Pages are ordered by seller, then route ID, so do not assume a global route order. A page stays under 1 MiB and may hold fewer rows than limit.

get_route

Reads one route by route_id (64 lowercase hex). The answer carries the route's full signed listing directly, plus its capacity, the latest fresh observation per pinned operator, and score_inputs.

Reading a result

The tool result puts the signed envelope {doc, key, sig} in structuredContent, and the same JSON as text in content. Errors are signed too, carry {error: {code, message}} in doc, and set isError. Codes you may see include invalid_filter, not_found and service_unavailable.

Before you trust a result, check four things: the key is the one you pinned, the signature is valid, doc.query equals {tool, args} exactly as you sent them, and issued_at is within 300 seconds of your clock. The index package exports this check as verifyAttestation; @im/discovery and @im/protocol are workspace packages, added as workspace:* dependencies like the SDK in the quickstart.

import { verifyAttestation } from "@im/discovery/attest";
import { parseJson } from "@im/protocol";
import { PublicKey } from "@solana/web3.js";

const pinned = new PublicKey(process.env.DIM_INDEXER_KEY ?? "").toBytes();

/** `text` is the tool result's text content; `args` must be exactly what you sent. */
export function verifiedToolResult(text: string, tool: "list_routes" | "get_route", args: Record<string, unknown>) {
  const envelope = parseJson(text); // strict: rejects duplicate keys, floats and oversized input
  if (!verifyAttestation(envelope, pinned, { tool, args }, Math.floor(Date.now() / 1000))) {
    throw new Error("result is not from the pinned index, not for this call, or not fresh");
  }
  return envelope;
}

The index's signature covers the page. Each seller listing inside still carries the seller's own signature, and each observation its operator's. Verify those before you act, or hand the route_id you picked to the SDK's discovery.get(routeId), which checks all of them.

From tool call to paid request

A typical agent loop:

  1. The model calls list_routes with family to see which exact identities exist and what they cost.
  2. It picks a model_identity_id, or a route_id, from the evidence.
  3. Your code passes that ID to the SDK: discovery.list({ modelIdentityId }) or discovery.get(routeId), then sdk.setRoutes(...).
  4. The SDK signs the hold, calls the seller and checks the receipt.