# Set up duleno

duleno lets an AI agent run exact, complete queries over large public web datasets: every
site that mentions a phrase, counts by any column, and a model reading each matching site to
classify it or extract facts. This page is written for the agent doing the setup.

## Recommended: add the MCP server

Add this remote MCP server (Streamable HTTP):

    https://mcp.duleno.com/mcp

There is no key to handle. The person signs in through their browser when the server is
added; your MCP client runs that sign-in itself. duleno is invitation-only for now, so they
should sign in with the address that was invited.

How, by agent:

- **Claude Code:** ask the person to run this in their terminal, or run it if they have asked
  you to set duleno up:

      claude mcp add --transport http duleno https://mcp.duleno.com/mcp

  Then they type `/mcp`, choose duleno, and sign in. The tools appear in the next session.
- **Claude (desktop and web):** Settings, Connectors, Add custom connector, with the address above.
- **ChatGPT:** Settings, Connectors, add a custom connector with the address above.
- **Cursor**, in `.cursor/mcp.json`: `{"mcpServers": {"duleno": {"url": "https://mcp.duleno.com/mcp"}}}`
- **VS Code**, in `.vscode/mcp.json`: `{"servers": {"duleno": {"type": "http", "url": "https://mcp.duleno.com/mcp"}}}`
- **Anything else that speaks MCP over HTTP:** the address above, with OAuth sign-in.

Once connected, call the `guide` tool first. It explains the query language with worked
examples and shows the account's plan and credits. A good first query is a count: it is cheap
and shows how big an answer is.

## Without MCP: the plain API

For scripts, and for agents that cannot add an MCP server. The API is at
`https://api.duleno.com` and takes an API key:

    Authorization: Bearer dln_...

The person makes a key on their account page, https://duleno.com/account.html, and gives it
to you in whatever way they choose. Do not go looking for one, and keep it out of anything
that is committed or shared. If they ask you to obtain a key for them from the terminal, and
only then, the API can run the sign-in: `POST /v1/signin/start` returns a link for them to
open; when they tell you they have confirmed, `POST /v1/signin/finish` with the `ticket`
returns the key. Ask them where they want it kept.

| Request | Does |
|---|---|
| `GET /v1/guide` | How to query, worked examples, the account. Start here. |
| `GET /v1/tables`, `GET /v1/tables/{name}` | The tables; one table's columns and filters |
| `POST /v1/estimate` with `{"query": ...}` | What a query may return and cost. Free. |
| `POST /v1/query` with `{"query": ..., "max_credits": n}` | Runs a query |
| `POST /v1/result` with `{"query_id": ...}` | The answer of a query that was still running; with `"next"`, the next page of a large result. Free. |
| `GET /v1/account`, `GET /v1/usage` | Plan and credits; recent queries and charges |

## Good to know

- Every answer says what it charged, in credits, and what is left. Listing tables,
  describing them, estimating and the guide are free.
- On the free month, counts are complete and lists are a sample; the answer says what was
  held back. Tell the person when that happens.
- A rejected query says why and which step: fix that step and send it again.
- A query that takes longer than 20 seconds answers `"status": "running"` with its id and
  keeps going: ask `result` for its answer. It is charged once, when it ends, and never
  more than `max_credits`.
- A large result comes a page at a time: an answer with `next` has more rows, and `result`
  with that `next` gives them.
- To read what a page says about your search, add `{"snippets": {"text": 300}}` after
  `select` instead of taking the whole text.
- If sign-in says duleno is invitation-only, the person's address has not been invited yet:
  support@duleno.com.
