---
title: search | CodeWeaver Docs
description: API reference for codeweaver.server.agent_api.search
url: "https://docs.knitli.com/api/server/agent_api/search"
type: static
generatedAt: "2026-04-17T17:21:09.645Z"
---

# search
       [Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fserver%2Fagent_api%2Fsearch%2F.%20I%20want%20to%20ask%20questions%20about%20it.)[Open in Claude](https://claude.ai/new?q=Read%20https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fserver%2Fagent_api%2Fsearch%2F.%20I%20want%20to%20ask%20questions%20about%20it.)[View in Markdown](/codeweaver/api/server/agent_api/search.md)       [Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fserver%2Fagent_api%2Fsearch%2F)[Share on X](https://x.com/intent/tweet?url=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fserver%2Fagent_api%2Fsearch%2F&text=search)[Share on Threads](https://threads.net/intent/post?url=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fserver%2Fagent_api%2Fsearch%2F&text=search)[Share on Bluesky](https://bsky.app/intent/compose?text=search%20https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fserver%2Fagent_api%2Fsearch%2F)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fserver%2Fagent_api%2Fsearch%2F)[Share on Reddit](https://reddit.com/submit?url=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fserver%2Fagent_api%2Fsearch%2F&title=search)[Share on Hacker News](https://news.ycombinator.com/submitlink?u=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fserver%2Fagent_api%2Fsearch%2F&t=search)[Share on Email](mailto:?subject=search&body=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fserver%2Fagent_api%2Fsearch%2F)[Share on WhatsApp](https://wa.me/?text=search%20https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fserver%2Fagent_api%2Fsearch%2F)[Share on Telegram](https://t.me/share/url?url=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fserver%2Fagent_api%2Fsearch%2F&text=search)
# `codeweaver.server.agent_api.search`
[Section titled “codeweaver.server.agent_api.search”](#codeweaverserveragent_apisearch)
# Implementation of the find_code tool.
[Section titled “Implementation of the find_code tool.”](#implementation-of-the-find_code-tool)
CodeWeaver differentiates between *internal* and *external* tools. External tools — and there is only one, this one, the **`find_code`** tool — are exposed to the user and user’s AI agents. `find_code` is intentionally very simple. This module contains the back-end, execution-side, of the `find_code` tool. The entry-point exposed to users and agents is in `codeweaver.server.mcp`.

## How it Works
[Section titled “How it Works”](#how-it-works)
You, or your AI agents, simply ask a question, explain what you are trying to do or what you need information for, and CodeWeaver will answer it.

For example, your agent might say: > Note: The main parameters for `find_code` that are exposed to users and agents are `query`, `intent`, and `focus_languages`. There’s also `token_limit`, but that’s self-explanatory.


**

```

```

`find_code` is different from other MCP tools in that it:

 1. Is intentionally designed to reduce “*cognitive load*”[1](#user-content-fn-1) on *agents*. Put simply, AI agents have “great minds and terrible hands.” `find_code` aims to bridge that gap between intellect and action. The explosion of MCP tools has also increased the cognitive load on agents — when there are 100 tools, which one do you use? It’s a hard task for a human, and harder for an AI. `find_code` aims to be a simple, universal tool that can be used in many situations.
 1. `find_code`, and all of CodeWeaver, is entirely designed to *narrow context*. AI agents are very prone to “*context poisoning*” and “*context overload*”. In even small codebases, this can happen very quickly — often before the agent even gets to the point of using a tool. `find_code` intentionally filters and shields the user’s agent from unnecessary context, and only provides the context that is relevant to the query. This is a key part of CodeWeaver’s design philosophy.
 1. It’s context-aware. `find_code` understands the context of your project, the files, the languages, and the structure. It uses this context to provide relevant results.

## Architecture
[Section titled “Architecture”](#architecture)
The find_code package is organized into focused modules:

 - **conversion.py**: Converts SearchResult objects to CodeMatch responses
 - **filters.py**: Post-search filtering (test files, language focus)
 - **pipeline.py**: Query embedding and vector search orchestration
 - **scoring.py**: Score calculation, reranking, and semantic weighting

This modular structure makes it easy to:

 - Add new filtering strategies
 - Extend scoring mechanisms
 - Integrate new search providers
 - Test individual components in isolation

## Philosophy: Agent UX
[Section titled “Philosophy: Agent UX”](#philosophy-agent-ux)
The design of `find_code` is heavily influenced by the concept of *Agent User Experience (Agent UX)*. Just as traditional UX focuses on making software intuitive and efficient for human users, Agent UX aims to optimize how AI agents interact with tools and systems. When we ask agents to use a tool with a human API, we need to consider how the agent will perceive and utilize that tool. `find_code` is designed to be as straightforward and effective as possible for AI agents, minimizing the complexity they have to deal with.

## Class: `MatchedSection`
[Section titled “Class: MatchedSection”](#class-matchedsection)
Represents a matched section within a file.

## Function: `find_code`
[Section titled “Function: find_code”](#function-find_code)

**

```
find_code()
```

Find relevant code based on semantic search with intent-driven ranking.

## Footnotes
[Section titled “Footnotes”](#footnote-label)
 1. AI agents don’t experience ‘cognitive load’ in the human sense, but we use the term here metaphorically. Practically speaking, two things actually happen: 1) Context ‘poisoning’ — the agent’s context gets filled with irrelevant information that steers it away from the results you want, 2) The agent, which really doesn’t ‘think’ in the human sense, can’t tell what tool to use, so it often picks the wrong one — tool use is more of a side effect of their training to generate language. [↩](#user-content-fnref-1)