> ## Documentation Index
> Fetch the complete documentation index at: https://docs.llmquantdata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Wiki Search

> Semantic search over the LLMQuant Quant Wiki — find concepts, formulas, factors, and strategies for your agent.

<Note icon="sparkles">
  **Available as MCP tools**: `wiki_search` + `wiki_read` — call directly from Claude / Cursor / any MCP client. See [MCP Server](/en/integration/mcp-server) for the 60-second setup.
</Note>

<Badge color="green" icon="circle-check">Live</Badge>
 
<Badge color="blue" size="sm">1 credit · search</Badge>
 
<Badge color="gray" size="sm">free · read</Badge>

## What it does for your agent

`wiki_search` returns the most relevant Quant Wiki entries for a natural-language query — concepts, formulas, factors, and strategies. Use it as a **research entry point**: when an agent encounters a finance term mid-task ("what's the Black-Scholes assumption?", "explain pairs trading"), call `wiki_search` first to locate the right `wikiItemId`s, then `wiki_read` to load the full markdown body.

The hybrid ranker blends semantic similarity with keyword matching — so terse jargon and verbose questions both retrieve well.

## Agent flow

```mermaid theme={null}
sequenceDiagram
  participant Agent
  participant MCP as data-mcp
  Agent->>MCP: wiki_search(query, topK=5)
  MCP-->>Agent: items[] · wikiItemId · summary · scores
  Note over Agent: scan summaries
  alt summary is enough
    Agent->>Agent: answer from summary
  else need full text
    Agent->>MCP: wiki_read(wikiItemId, maxLength?)
    MCP-->>Agent: body_markdown
  end
```

## Response

### `wiki_search` response

<ResponseField name="data" type="WikiItem[]" required>
  Ranked array of wiki items (highest relevance first).

  <Expandable title="WikiItem fields">
    <ResponseField name="wikiItemId" type="string" required>
      Stable identifier. Pass to `wiki_read` for the full article.
    </ResponseField>

    <ResponseField name="slug" type="string" required>
      URL-friendly slug derived from the title.
    </ResponseField>

    <ResponseField name="title" type="string" required>
      Article title.
    </ResponseField>

    <ResponseField name="summary" type="string" required>
      LLM-generated 2–3 sentence summary. **Use this to decide whether to load the full article** before spending a `wiki_read`.
    </ResponseField>

    <ResponseField name="tags" type="string[]" required>
      Topic tags (e.g. `equity`, `factor`, `derivatives`).
    </ResponseField>

    <ResponseField name="scores" type="object" required>
      Hybrid relevance scores. `combined` is the blended final score; `semantic` and `lexical` are the components (all 0–1).
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="meta.creditsUsed" type="number">Credits consumed by this call (always `1` for search).</ResponseField>
<ResponseField name="meta.remainingCredits" type="number">Account credits remaining.</ResponseField>

```json title="200 OK · wiki_search" expandable theme={null}
{
  "data": [
    {
      "wikiItemId": "11111111-1111-4111-8111-111111111111",
      "slug": "momentum-factor",
      "title": "Momentum Factor",
      "summary": "Momentum captures the tendency of recent winners to keep winning over horizons of 3–12 months. It is one of the canonical Fama-French factors and underpins many systematic equity strategies.",
      "tags": ["equity", "factor"],
      "scores": { "combined": 0.91, "semantic": 0.88, "lexical": 0.79 }
    }
  ],
  "meta": { "creditsUsed": 1, "remainingCredits": 99 }
}
```

### `wiki_read` response

<ResponseField name="data" type="WikiItem" required>
  The full wiki entry.

  <Expandable title="WikiItem fields">
    <ResponseField name="wikiItemId" type="string" required>Stable identifier.</ResponseField>
    <ResponseField name="title" type="string" required>Article title.</ResponseField>
    <ResponseField name="summary" type="string" required>2–3 sentence summary.</ResponseField>

    <ResponseField name="body_markdown" type="string" required>
      Full article body in Markdown. Truncated to `maxLength` characters if specified.
    </ResponseField>

    <ResponseField name="item_type" type="string" required>
      One of `concept`, `formula`, `strategy`, `factor`.
    </ResponseField>

    <ResponseField name="tags" type="string[]" required>Topic tags.</ResponseField>
    <ResponseField name="source_url" type="string" required>Canonical URL on `quant-wiki.com`.</ResponseField>
    <ResponseField name="updated_at" type="datetime" required>ISO-8601 last-updated timestamp.</ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="meta.creditsUsed" type="number">Always `0` for read.</ResponseField>
<ResponseField name="meta.remainingCredits" type="number">Account credits remaining.</ResponseField>

## Notes

<Tip>
  **Two-step lookup is canonical**: search returns IDs + summaries cheaply (1 credit, multiple hits), then `wiki_read` loads only the article(s) the agent actually needs (free). Read top-1 by default; read top-2 only when summaries are ambiguous.
</Tip>

<Tip>
  Use `maxLength` on `wiki_read` to preview a long article before spending agent context tokens on the full body.
</Tip>

<Warning>
  Queries longer than **2,000 characters** are rejected with `400`. Truncate or summarize long agent context before calling.
</Warning>

<Warning>
  `topK` is capped at **10** for `wiki_search`. Higher values are silently clamped.
</Warning>

## Direct invocation

<Accordion title="HTTP / SDK examples" icon="terminal">
  <CodeGroup>
    ```typescript MCP (Claude / Cursor) theme={null}
    // 1) Search
    {
      "method": "tools/call",
      "params": {
        "name": "wiki_search",
        "arguments": { "query": "momentum factor", "topK": 5 }
      }
    }

    // 2) Read top hit
    {
      "method": "tools/call",
      "params": {
        "name": "wiki_read",
        "arguments": { "wikiItemId": "11111111-1111-4111-8111-111111111111", "maxLength": 1500 }
      }
    }
    ```

    ```python Python (HTTP) theme={null}
    import os, requests

    base = "https://api.llmquantdata.com"
    headers = {"Authorization": f"Bearer {os.environ['LLMQUANT_API_KEY']}"}

    # 1) Search
    hits = requests.post(
        f"{base}/api/wiki/search",
        headers=headers,
        json={"query": "momentum factor", "topK": 5},
    ).json()["data"]

    # 2) Read top hit
    top = requests.get(
        f"{base}/api/wiki/items/{hits[0]['wikiItemId']}",
        headers=headers,
        params={"max_length": 1500},
    ).json()["data"]
    print(top["body_markdown"])
    ```

    ```bash cURL theme={null}
    # 1) Search
    curl -X POST "https://api.llmquantdata.com/api/wiki/search" \
      -H "Authorization: Bearer $LLMQUANT_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{"query": "momentum factor", "topK": 5}'

    # 2) Read top hit (replace this sample UUID with wikiItemId from step 1)
    WIKI_ITEM_ID="11111111-1111-4111-8111-111111111111"
    curl "https://api.llmquantdata.com/api/wiki/items/${WIKI_ITEM_ID}?max_length=1500" \
      -H "Authorization: Bearer $LLMQUANT_API_KEY"
    ```
  </CodeGroup>
</Accordion>

## Full parameter reference

<AccordionGroup>
  <Accordion title="wiki_search — request parameters" icon="magnifying-glass">
    <ParamField body="query" type="string" required>
      Natural-language search query. Max 2,000 characters.
    </ParamField>

    <ParamField body="topK" type="number" default={5}>
      Maximum results to return. Range `1–10`.
    </ParamField>
  </Accordion>

  <Accordion title="wiki_read — request parameters" icon="book-open">
    <ParamField path="wikiItemId" type="string" required>
      The `wikiItemId` returned by `wiki_search`.
    </ParamField>

    <ParamField query="max_length" type="number">
      Maximum character length for `body_markdown`. Useful for previewing long articles before consuming agent context.
    </ParamField>
  </Accordion>
</AccordionGroup>

## Related

<Columns cols={2}>
  <Card title="Paper Search" icon="file-lines" href="/en/api/knowledge/paper-search">
    Same two-step pattern over the academic paper corpus.
  </Card>

  <Card title="MCP Server setup" icon="plug" href="/en/integration/mcp-server">
    Connect Claude / Cursor / any harness in 60 seconds.
  </Card>
</Columns>
