# Build a fact finder agent with code (/tutorials/agents/fact-finder)





## Overview

In this tutorial, you'll build a fact finder agent using code and the Inkeep SDK. When you ask "What is Inkeep?", the agent will:

1. Search your knowledge base using the Inkeep RAG MCP tool
2. Present relevant facts about Inkeep

<Video src="youtube.com/watch?v=76HP-P269RI&feature=youtu.be" title="Fact finder agent tutorial" />

## Prerequisites

* An existing Inkeep project running (follow the [quick start guide](/get-started/quick-start) to get started)
* Or access to Inkeep Cloud

## Setting up the project

### Step 1: Create the project directory

<Steps>
  <Step>
    Navigate to your projects directory:

    ```bash
    cd src/projects  
    ```
  </Step>

  <Step>
    Create a new directory for your fact finder project:

    ```bash
    mkdir fact-finder  
    ```
  </Step>

  <Step>
    Navigate into the new directory:

    ```bash
    cd fact-finder  
    ```
  </Step>
</Steps>

### Step 2: Create the project configuration

Create an `index.ts` file with the following content:

```typescript
import { project } from "@inkeep/agents-sdk";

export const myProject = project({
  id: "<project-id>",
  name: "<project-name>",
  description: "Fact finder project template",
  models: {
    base: {
      model: "<model-name>",
    },
    structuredOutput: {
      model: "<model-name>",
    },
    summarizer: {
      model: "<model-name>",
    },
  },
});
```

<Note>
  Replace the placeholder values (`<project-id>`, `<project-name>`, `<model-name>`) with your actual project details. If you need help recreating the boilderplate, you can reuse the index.ts file from the default activities planner project.
</Note>

### Step 3: Push the project to Visual Builder

<Steps>
  <Step>
    From the `fact-finder` directory, run:

    ```bash
    inkeep push  
    ```
  </Step>

  <Step>
    Verify in the Visual Builder that the project is created successfully.
  </Step>
</Steps>

## Creating the agent

### Step 1: Create the agent directory

```bash
mkdir agents  
```

### Step 2: Create the fact finder agent

Create `agents/fact-finder-agent.ts` with the following content:

```typescript
import { agent, subAgent } from "@inkeep/agents-sdk";
import { inkeepRagMcpTool } from "../tools/inkeep-rag-mcp";

const mySubAgent = subAgent({
  id: 'fact-finder-sub-agent',
  name: 'Fact Finder SubAgent',
  description: 'A sub agent that can help you find facts about Inkeep',
  prompt: 'You are a fact finder sub agent that can help you find facts about Inkeep',
  canUse: () => [inkeepRagMcpTool]
});

export const factFinderAgent = agent({
  id: "fact-finder-agent",
  name: "Fact Finder Agent",
  description: "A agent that can help you find facts about Inkeep",
  defaultSubAgent: mySubAgent,
  subAgents: () => [mySubAgent],
});
```

## Adding the MCP tool

### Step 1: Create the tools directory

```bash
mkdir tools  
```

### Step 2: Create the Inkeep RAG MCP tool

Create `tools/inkeep-rag-mcp.ts` with the following content:

```typescript
import { mcpTool } from "@inkeep/agents-sdk";

export const inkeepRagMcpTool = mcpTool({
  id: "inkeep-rag-mcp",
  name: "Inkeep RAG MCP",
  serverUrl: "https://mcp.inkeep.com/inkeep/mcp",
});
```

This tool enables your agent to search your Inkeep knowledge base for relevant information, leveraging Inkeep Unified Search's RAG capabilities to provide accurate and relevant results.

<Tip>
  Inkeep Unified Search is part of [Inkeep's Enterprise offering](https://inkeep.com/enterprise). Connect 25+ data sources to create a unified knowledge base that your agents can access.
</Tip>

### Step 3: Register the fact finder agent and rag mcp tool in the project

```typescript
import { project } from "@inkeep/agents-sdk";
import { factFinderAgent } from "./agents/fact-finder-agent";
import { inkeepRagMcpTool } from "./tools/inkeep-rag-mcp";

export const myProject = project({
  id: "<project-id>",
  name: "<project-name>",
  description: "Fact finder project template",
  agents: () => [factFinderAgent],
  tools: () => [inkeepRagMcpTool],
  models: {
    base: {
      model: "<model-name>",
    },
    structuredOutput: {
      model: "<model-name>",
    },
    summarizer: {
      model: "<model-name>",
    },
  },
});
```

## Deploying your agent

<Steps>
  <Step>
    From the `fact-finder` directory, run:

    ```bash
    inkeep push  
    ```
  </Step>

  <Step>
    Verify in the Visual Builder that the fact finder agent is created successfully.
  </Step>
</Steps>

## Testing your agent

<Steps>
  <Step>
    In the Visual Builder, click the **Try it** button to open the chat interface.
  </Step>

  <Step>
    Test your agent by asking questions like:

    * "What is Inkeep?"
    * "Tell me about Inkeep's features"
    * "How does Inkeep work?"
  </Step>
</Steps>

When working correctly, the agent will search your knowledge base and present relevant facts about Inkeep.