Agents

Build a fact finder agent with code

Copy page

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 walkthrough available

Follow along with our visual guide to see each step in action.

Watch: Fact finder agent tutorial

Prerequisites

  • An existing Inkeep project running (follow the quick start guide to get started)
  • Or access to Inkeep Cloud

Setting up the project

Step 1: Create the project directory

Navigate to your projects directory:

cd src/projects  

Create a new directory for your fact finder project:

mkdir fact-finder  

Navigate into the new directory:

cd fact-finder  

Step 2: Create the project configuration

Create an index.ts file with the following content:

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
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.

Step 3: Push the project to Visual Builder

From the fact-finder directory, run:

inkeep push  

Verify in the Visual Builder that the project is created successfully.

Creating the agent

Step 1: Create the agent directory

mkdir agents  

Step 2: Create the fact finder agent

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

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

mkdir tools  

Step 2: Create the Inkeep RAG MCP tool

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

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
Tip

Inkeep Unified Search is part of Inkeep's Enterprise offering. Connect 25+ data sources to create a unified knowledge base that your agents can access.

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

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

From the fact-finder directory, run:

inkeep push  

Verify in the Visual Builder that the fact finder agent is created successfully.

Testing your agent

In the Visual Builder, click the Try it button to open the chat interface.

Test your agent by asking questions like:

  • "What is Inkeep?"
  • "Tell me about Inkeep's features"
  • "How does Inkeep work?"

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

On this page