Create your MCP Server with Tako
This Python script sets up a basic MCP (Model Context Protocol) server integrated with Tako Knowledge Search API. The provided code creates an agent powered by MCP that uses Tako’s Knowledge Search API to search for knowledge cards in response to user queries.
Introduction
LLMs have a cutoff date and relies on web search to get the most current data. It often hallucinates by using a unreliable source or outdated training data. In this tutorial, we’ll build a simple Tako MCP Server that clients can use to search Tako for real-time data and ground their answer based on authoritative sources.
Prerequisites
- Tako API key
- Python >= 3.9 or TypeScript >= 5.1.6
- Python Tako SDK or TypeScript Tako SDK
- MCP Server SDK
Building Tako MCP
Starting your project
Let’s start by creating a new project directory using uv and install necessary packages
Initialize MCP Server and Tako client
We will need to import all the necessary modules and initialize MCP Server and Tako client.
We initialize the client with TAKO_API_KEY
which is passed from an environment variable. We will configure the environment variable when we connect our server to a client.
Write Search Tako tool
We will write a tool that takes in client’s input as a string and search Tako by calling knowledge_search
from the Tako client.
Also add a docstring description so the client can understand the functionality of the tool.
Add a prompt to optimize your query
Although Tako can take any natural language queries, we can add a prompt for the client to use to fine-tune their queries to Tako. Check out this guide for more information!
Server Initialization
Now add a line to start your server when the code runs.
Add Tako MCP Server to Claude Desktop
Add the following to your .cursor/mcp.json or claude_desktop_config.json (MacOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json)
Starting your project
Let’s start by creating a new project directory using uv and install necessary packages
Initialize MCP Server and Tako client
We will need to import all the necessary modules and initialize MCP Server and Tako client.
We initialize the client with TAKO_API_KEY
which is passed from an environment variable. We will configure the environment variable when we connect our server to a client.
Write Search Tako tool
We will write a tool that takes in client’s input as a string and search Tako by calling knowledge_search
from the Tako client.
Also add a docstring description so the client can understand the functionality of the tool.
Add a prompt to optimize your query
Although Tako can take any natural language queries, we can add a prompt for the client to use to fine-tune their queries to Tako. Check out this guide for more information!
Server Initialization
Now add a line to start your server when the code runs.
Add Tako MCP Server to Claude Desktop
Add the following to your .cursor/mcp.json or claude_desktop_config.json (MacOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json)
Starting your project
Let’s start by creating a new project directory and adding necessary configuration files and libraries
In your project directory, create a new file package.json
and add the following configuration
Now we will install the necessary libraries
Initialize MCP Server and Tako client
First, we will need to import all the necessary modules and initialize MCP Server and Tako client.
We initialize the client with TAKO_API_KEY
which is passed from an environment variable. We will configure the environment variable when we connect our server to a client.
Write Search Tako tool
We will write a tool that takes in client’s input as a string and search Tako by calling knowledgeSearch
from the Tako client.
Also give add a docstring description so the client can understand the functionality of the tool.
Add a prompt to optimize your query
Although Tako can take any natural language queries, we can add a prompt for the client to use to fine-tune their queries to Tako. Check out this guide for more information!
Server Initialization
Now add a line to start your server when the code runs.
Compile your code
Add Tako MCP Server to Claude Desktop
Add the following to your .cursor/mcp.json or claude_desktop_config.json (MacOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json)
Query Tako MCP using Claude Desktop
Try using the prompt we created above and query Tako.
-
Query Input: “Compare Magnificent 7 stock companies on relevant metrics.”
-
Chat Input: Write me a research report on the magnificent 7 companies. Embed the result in an iframe whenever necessary
Result: