# Use SimilarIQ with LlamaIndex

> SimilarIQ has no LlamaIndex-specific package. LlamaIndex agents use it through the llama-index-tools-mcp package: create a BasicMCPClient for https://similariq.ai/mcp with an X-API-Key header, convert it with McpToolSpec, and pass the tools to an agent. Raise the client's 30-second default timeout. Each search returns up to 100 look-alike companies for $0.25.

Source: https://similariq.ai/integrations/llamaindex · Updated 2026-11-25

## What LlamaIndex is and where MCP fits

LlamaIndex is a framework for building agents and data applications on top of language models. It began with retrieval over your own documents and now includes agent classes that plan, call tools and return answers. A tool in LlamaIndex is a function with a name, a description and a typed signature that the model can choose to call.

The framework's documentation describes MCP support in a separate package, `llama-index-tools-mcp`, installed with `pip install llama-index-tools-mcp`. It provides two classes. `BasicMCPClient` connects to a server; the docs show it taking a URL for Streamable HTTP or SSE, or a command with arguments for a local process. `McpToolSpec` turns that client's tools into LlamaIndex tools.

SimilarIQ does not ship a LlamaIndex integration and has no listing in a LlamaIndex catalog. It runs a hosted [MCP server](https://similariq.ai/features/mcp-server) at `https://similariq.ai/mcp` over streamable HTTP, which is one of the connection forms `BasicMCPClient` documents.

## Why pair a retrieval framework with look-alike search

LlamaIndex is strong at answering from what you already hold: indexed documents, notes, CRM exports. It cannot retrieve what is not in the index. Ask which companies resemble a given customer and the retriever returns whatever happens to mention that customer, while the model fills the gaps from memory.

SimilarIQ covers that gap with a live call. Send one domain and receive up to 100 ranked companies, each with `matchScore`, a relationship `type` of Direct, Indirect, Adjacent or Emerging, a `confidence` score and a `likelyCompetitor` flag. Each search is a fresh research pass cross-validated across multiple independent intelligence sources.

The two combine well. An agent can pull a look-alike list, then use your index to check which of those companies already appear in your notes or pipeline. The list can also be written into an index as structured records, a pattern covered in the [RAG knowledge base use case](https://similariq.ai/use-cases/rag-knowledge-base).

## Setup walkthrough: connect the MCP server

Install the package, then create a SimilarIQ API key in the app. The key starts with `sk-live-`, is shown once, and should live in an environment variable.

Import the classes with `from llama_index.tools.mcp import BasicMCPClient, McpToolSpec`. Build the client as `BasicMCPClient('https://similariq.ai/mcp', headers={'X-API-Key': KEY}, timeout=120)`. The API reference lists `headers` as an optional dictionary and `timeout` as an integer that defaults to 30. Then create `McpToolSpec(client=mcp_client)` and call `await mcp_tool_spec.to_tool_list_async()` to get the tool list.

The docs pass that list straight to an agent: `FunctionAgent(tools=tools, llm=..., system_prompt=...)`, with `FunctionAgent` imported from `llama_index.core.agent.workflow`, and then `await agent.run('your request')`. Use whichever model class you already have configured. The reference also documents a one-call helper, `aget_tools_from_mcp_url`, which accepts an existing client and returns the same list of tools.

## The timeout default, and OAuth

The `timeout` parameter on `BasicMCPClient` defaults to 30 seconds according to the API reference, with a separate `sse_read_timeout` that defaults to 300. A SimilarIQ search takes roughly 30 to 60 seconds. This page did not verify exactly which phase of a request each value bounds, so the safe move is to set `timeout` to 120 or more, as in the snippet above. If a search is cut off anyway, check history with `list_recent_searches` before paying again.

For a desktop or notebook setting where a person can sign in, the reference documents a `with_oauth` class method on `BasicMCPClient`. It requires a client name, redirect URIs, a redirect handler and a callback handler, and takes an optional `token_storage`. The reference warns that without `token_storage` it keeps tokens in memory and they are lost on restart. SimilarIQ's server supports OAuth 2.1 with PKCE, so that route is available; see [OAuth for assistants](https://similariq.ai/features/oauth-for-assistants).

For servers, jobs and anything unattended, use the API key header. It is one line and there is no browser step.

## Restricting tools, and the REST alternative

`McpToolSpec` accepts an `allowed_tools` list. The reference says that when it is set, only tools with those names are returned. This is the cleanest way to build a read-only agent: allow `list_recent_searches`, `get_search_results`, `list_my_companies` and `get_search_balance`, and leave out the two tools that cost credits.

You can also skip MCP. Write a Python function that sends `POST https://similariq.ai/api/v1/search` with the body `{"domain":"stripe.com","limit":100}` and the header `X-API-Key: sk-live-...`, and register it as a tool using the function-tool mechanism your LlamaIndex version documents. This page does not name that helper because it was not re-verified for this write-up. The [Python guide](https://similariq.ai/find-competitors-with-python) has the request itself, and the SDK installed with `pip install similariq` wraps it in a `search` method.

## Example prompts

With the tools loaded, an agent can complete requests like these. Tool names are the ones the SimilarIQ MCP server exposes.

- What is my search balance? Calls `get_search_balance`, free.
- Find companies similar to notion.so and show the 20 with the highest match score. Calls `find_similar_companies`, one credit.
- Have we searched this domain before? If yes, load that result. Calls `list_recent_searches`, then `get_search_results`.
- Which results for this search are typed Emerging with confidence above 70? Reads a past result at no cost.
- Run these 25 domains as a bulk job and summarise when it completes. Calls `start_bulk_search`, then `get_bulk_job`.
- Add the top three to my saved companies. Calls `save_company` three times.
- Make a public link to this search. Calls `create_share_link`.
- Across all past searches, which companies came up more than once? Calls `list_my_companies`.

## Controlling spend

Two tools cost credits: `find_similar_companies` at one credit and `start_bulk_search` at one credit per domain. The other eight are free. A credit is $0.25 and buys up to 100 look-alikes, so 20 searches cost $5.00 and 1,000 cost $250. App searches, API calls and MCP tool calls all draw on the same balance at the same price.

Put the rule in the system prompt: check the balance, check recent searches, and search only when the domain is not already in history. Re-reading a past search is immediate and free, so an agent that follows this rule pays once per company however many times users ask.

Then set limits the agent cannot talk its way past. Use `allowed_tools` to keep paid tools away from agents that only report. In SimilarIQ, leave auto-refill off for experiments so spending stops at the balance, or set a monthly cap when it is on. If a failed search returns a 502, the credit is refunded automatically.

## Two workflows end to end

**Account-research agent over your own notes.** Index your call notes and CRM export as usual. Give the agent the SimilarIQ tools plus a query tool over that index. Asked to find accounts like a named customer, it runs one search, then queries the index for each high-scoring domain to see whether you have history with it. The answer separates net-new look-alikes from companies you have already spoken to. Cost: $0.25 per seed customer.

**Category index builder.** Start a bulk job for a dozen seed domains in one market, wait for it, and read each result. Write every company into an index as a record with its domain, score, type and the seed it came from. Later questions about the category are answered from the index with no further spend. Twelve seeds cost $3.00. SimilarIQ supplies names, domains and scores; firmographic fields must come from another source. The [market mapping guide](https://similariq.ai/guides/how-to-build-a-market-map) shows how to group the output.

## Troubleshooting and security

If the tool list is empty or the client fails to connect, check that the URL is exactly `https://similariq.ai/mcp` and that the `headers` dictionary uses the key `X-API-Key`. A 401 means a missing or revoked key. A 402 means no credits remain. A 429 means the rate limiter is smoothing a burst; wait and retry. A 502 means the search failed and was refunded. A timeout near 30 seconds points to the client default described above.

Issue a separate key for each agent or environment, and revoke it in the SimilarIQ app if it leaks. Keep keys in environment variables, never in prompts or indexed documents. If you store results in an index, remember that company names originate on the open web: treat them as content to cite, and do not let retrieved text override the agent's instructions.

## Frequently asked questions

### Is there an official SimilarIQ integration for LlamaIndex?

No. SimilarIQ publishes no LlamaIndex package. You connect through LlamaIndex's own `llama-index-tools-mcp` package pointed at the hosted SimilarIQ MCP server, or by wrapping the REST API as a function tool.

### Which classes connect LlamaIndex to a remote MCP server?

LlamaIndex's docs use `BasicMCPClient` to connect and `McpToolSpec` to convert the server's tools, both imported from `llama_index.tools.mcp`. Calling `to_tool_list_async()` returns tools you pass to an agent such as `FunctionAgent`.

### How do I pass the SimilarIQ API key?

Give `BasicMCPClient` a `headers` dictionary containing `X-API-Key` with your `sk-live-` key. For interactive use, the client's `with_oauth` method can run a browser sign-in against SimilarIQ's OAuth 2.1 flow instead.

### Why does the search time out after 30 seconds?

The API reference gives 30 seconds as the default for the client's `timeout` parameter, and a search takes roughly 30 to 60 seconds. Set a larger value, such as 120, when you construct the client.

### Can I stop a LlamaIndex agent from spending credits?

Yes. Pass `allowed_tools` to `McpToolSpec` with only the free tools, such as `list_recent_searches`, `get_search_results` and `get_search_balance`. The agent can then read existing results but cannot start a search.

### Can I index SimilarIQ results for retrieval?

Yes. Results are structured JSON: company, domain, match score, relationship type, confidence and a likely-competitor flag. Store them as records in your index. They contain no contacts or firmographic fields.
