|
| 1 | +--- |
| 2 | +title: 'Exa' |
| 3 | +description: 'Learn how to use Klavis to connect your AI application to Exa MCP Server' |
| 4 | +--- |
| 5 | + |
| 6 | +import NoCodeSnippet from '/snippets/mcp-server-card/no-code.mdx'; |
| 7 | + |
| 8 | +<NoCodeSnippet /> |
| 9 | + |
| 10 | +--- |
| 11 | + |
| 12 | +## For Developer |
| 13 | + |
| 14 | +Follow the instructions below to integrate Exa MCP server to your AI application using our API or SDK. |
| 15 | + |
| 16 | +### Prerequisites |
| 17 | + |
| 18 | +- [Create an API key](https://www.klavis.ai/home/api-keys) |
| 19 | + |
| 20 | +### 1. Create an Exa MCP Server |
| 21 | + |
| 22 | +Use the following endpoint to create a new remote Exa MCP server instance: |
| 23 | + |
| 24 | +#### Request |
| 25 | +<CodeGroup> |
| 26 | +```python Python |
| 27 | +from klavis import Klavis |
| 28 | +from klavis.types import McpServerName |
| 29 | + |
| 30 | +klavis_client = Klavis(api_key="<YOUR_API_KEY>") |
| 31 | + |
| 32 | +# Create an Exa MCP server instance |
| 33 | +exa_server = klavis_client.mcp_server.create_server_instance( |
| 34 | + server_name=McpServerName.EXA, |
| 35 | + user_id="<YOUR_USER_ID>", |
| 36 | + platform_name="<YOUR_PLATFORM_NAME>", |
| 37 | +) |
| 38 | +``` |
| 39 | + |
| 40 | +```javascript TypeScript |
| 41 | +import { KlavisClient, Klavis } from 'klavis'; |
| 42 | + |
| 43 | +const klavisClient = new KlavisClient({ apiKey: '<YOUR_API_KEY>' }); |
| 44 | + |
| 45 | +// Create an Exa MCP server instance |
| 46 | +const exaServer = await klavisClient.mcpServer.createServerInstance({ |
| 47 | + serverName: Klavis.McpServerName.Exa, |
| 48 | + userId: "<YOUR_USER_ID>", |
| 49 | + platformName: "<YOUR_PLATFORM_NAME>", |
| 50 | +}); |
| 51 | +``` |
| 52 | + |
| 53 | +```bash cURL |
| 54 | +curl --request POST \ |
| 55 | + --url https://api.klavis.ai/mcp-server/instance/create \ |
| 56 | + --header 'Authorization: Bearer <YOUR_API_KEY>' \ |
| 57 | + --header 'Content-Type: application/json' \ |
| 58 | + --data '{ |
| 59 | + "serverName": "Exa", |
| 60 | + "userId": "<YOUR_USER_ID>", |
| 61 | + "platformName": "<YOUR_PLATFORM_NAME>" |
| 62 | +}' |
| 63 | +``` |
| 64 | + |
| 65 | +```go Go |
| 66 | +package main |
| 67 | + |
| 68 | +import ( |
| 69 | + "fmt" |
| 70 | + "strings" |
| 71 | + "net/http" |
| 72 | + "io/ioutil" |
| 73 | +) |
| 74 | + |
| 75 | +func main() { |
| 76 | + |
| 77 | + url := "https://api.klavis.ai/mcp-server/instance/create" |
| 78 | + |
| 79 | + payload := strings.NewReader("{\n \"serverName\": \"Exa\",\n \"userId\": \"<YOUR_USER_ID>\",\n \"platformName\": \"<YOUR_PLATFORM_NAME>\"\n}") |
| 80 | + |
| 81 | + req, _ := http.NewRequest("POST", url, payload) |
| 82 | + |
| 83 | + req.Header.Add("Authorization", "Bearer <YOUR_API_KEY>") |
| 84 | + req.Header.Add("Content-Type", "application/json") |
| 85 | + |
| 86 | + res, _ := http.DefaultClient.Do(req) |
| 87 | + |
| 88 | + defer res.Body.Close() |
| 89 | + body, _ := ioutil.ReadAll(res.Body) |
| 90 | + |
| 91 | + fmt.Println(res) |
| 92 | + fmt.Println(string(body)) |
| 93 | + |
| 94 | +} |
| 95 | +``` |
| 96 | + |
| 97 | +```java Java |
| 98 | +HttpResponse<String> response = Unirest.post("https://api.klavis.ai/mcp-server/instance/create") |
| 99 | + .header("Authorization", "Bearer <YOUR_API_KEY>") |
| 100 | + .header("Content-Type", "application/json") |
| 101 | + .body("{\n \"serverName\": \"Exa\",\n \"userId\": \"<YOUR_USER_ID>\",\n \"platformName\": \"<YOUR_PLATFORM_NAME>\"\n}") |
| 102 | + .asString(); |
| 103 | +``` |
| 104 | +</CodeGroup> |
| 105 | + |
| 106 | +#### Response |
| 107 | +<CodeGroup> |
| 108 | +```json Response |
| 109 | +{ |
| 110 | + "serverUrl": "https://exa-mcp-server.klavis.ai/mcp/?instance_id=<instance-id>", |
| 111 | + "instanceId": "<instance-id>" |
| 112 | +} |
| 113 | +``` |
| 114 | +</CodeGroup> |
| 115 | + |
| 116 | +<Check>**serverUrl** specifies the endpoint of the Exa MCP server, which allows you to perform AI-powered semantic search, content retrieval, similarity discovery, and comprehensive research through the Exa Search API.</Check> |
| 117 | +<Note>**instanceId** is used for authentication and identification of your server instance.</Note> |
| 118 | + |
| 119 | +### 2. Configure Exa API Key |
| 120 | + |
| 121 | +To use the Exa MCP Server, you need to configure it with your Exa API key. You can get your API key from the [Exa AI website](https://docs.exa.ai/reference/getting-started). |
| 122 | + |
| 123 | +#### Setting up Exa API Key |
| 124 | + |
| 125 | +<CodeGroup> |
| 126 | +```bash cURL |
| 127 | +curl --request POST \ |
| 128 | + --url https://api.klavis.ai/mcp-server/instance/set-auth \ |
| 129 | + --header 'Authorization: Bearer <YOUR_KLAVIS_API_KEY>' \ |
| 130 | + --header 'Content-Type: application/json' \ |
| 131 | + --data '{ |
| 132 | + "instanceId": "<YOUR_INSTANCE_ID>", |
| 133 | + "authData": { |
| 134 | + "token": "<YOUR_EXA_API_KEY>" |
| 135 | + } |
| 136 | +}' |
| 137 | +``` |
| 138 | + |
| 139 | +```python Python |
| 140 | +from klavis import Klavis |
| 141 | + |
| 142 | +klavis_client = Klavis(api_key="<YOUR_KLAVIS_API_KEY>") |
| 143 | + |
| 144 | +# Set the Exa API key for your instance |
| 145 | +response = klavis_client.mcp_server.set_instance_auth( |
| 146 | + instance_id="<YOUR_INSTANCE_ID>", |
| 147 | + auth_data={ |
| 148 | + "token": "<YOUR_EXA_API_KEY>" |
| 149 | + } |
| 150 | +) |
| 151 | + |
| 152 | +print(response) |
| 153 | +``` |
| 154 | + |
| 155 | +```javascript TypeScript |
| 156 | +import { KlavisClient } from 'klavis'; |
| 157 | + |
| 158 | +const klavisClient = new KlavisClient({ apiKey: '<YOUR_KLAVIS_API_KEY>' }); |
| 159 | + |
| 160 | +// Set the Exa API key for your instance |
| 161 | +const response = await klavisClient.mcpServer.setInstanceAuth({ |
| 162 | + instanceId: "<YOUR_INSTANCE_ID>", |
| 163 | + authData: { |
| 164 | + token: "<YOUR_EXA_API_KEY>" |
| 165 | + } |
| 166 | +}); |
| 167 | + |
| 168 | +console.log(response); |
| 169 | +``` |
| 170 | + |
| 171 | +```go Go |
| 172 | +package main |
| 173 | + |
| 174 | +import ( |
| 175 | + "bytes" |
| 176 | + "encoding/json" |
| 177 | + "fmt" |
| 178 | + "net/http" |
| 179 | +) |
| 180 | + |
| 181 | +func main() { |
| 182 | + url := "https://api.klavis.ai/mcp-server/instance/set-auth" |
| 183 | + |
| 184 | + payload := map[string]interface{}{ |
| 185 | + "instanceId": "<YOUR_INSTANCE_ID>", |
| 186 | + "authData": map[string]string{ |
| 187 | + "token": "<YOUR_EXA_API_KEY>", |
| 188 | + }, |
| 189 | + } |
| 190 | + |
| 191 | + jsonPayload, _ := json.Marshal(payload) |
| 192 | + |
| 193 | + req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonPayload)) |
| 194 | + req.Header.Set("Authorization", "Bearer <YOUR_KLAVIS_API_KEY>") |
| 195 | + req.Header.Set("Content-Type", "application/json") |
| 196 | + |
| 197 | + client := &http.Client{} |
| 198 | + resp, err := client.Do(req) |
| 199 | + if err != nil { |
| 200 | + panic(err) |
| 201 | + } |
| 202 | + defer resp.Body.Close() |
| 203 | + |
| 204 | + fmt.Println("Response Status:", resp.Status) |
| 205 | +} |
| 206 | +``` |
| 207 | + |
| 208 | +```java Java |
| 209 | +import java.net.URI; |
| 210 | +import java.net.http.HttpClient; |
| 211 | +import java.net.http.HttpRequest; |
| 212 | +import java.net.http.HttpResponse; |
| 213 | +import java.net.http.HttpResponse.BodyHandlers; |
| 214 | + |
| 215 | +public class SetAuthToken { |
| 216 | + public static void main(String[] args) { |
| 217 | + try { |
| 218 | + String requestBody = "{\"instanceId\":\"<YOUR_INSTANCE_ID>\",\"authData\":{\"token\":\"<YOUR_EXA_API_KEY>\"}}"; |
| 219 | + |
| 220 | + HttpClient client = HttpClient.newHttpClient(); |
| 221 | + HttpRequest request = HttpRequest.newBuilder() |
| 222 | + .uri(URI.create("https://api.klavis.ai/mcp-server/instance/set-auth")) |
| 223 | + .header("Authorization", "Bearer <YOUR_KLAVIS_API_KEY>") |
| 224 | + .header("Content-Type", "application/json") |
| 225 | + .POST(HttpRequest.BodyPublishers.ofString(requestBody)) |
| 226 | + .build(); |
| 227 | + |
| 228 | + HttpResponse<String> response = client.send(request, BodyHandlers.ofString()); |
| 229 | + System.out.println("Response: " + response.body()); |
| 230 | + } catch (Exception e) { |
| 231 | + e.printStackTrace(); |
| 232 | + } |
| 233 | + } |
| 234 | +} |
| 235 | +``` |
| 236 | +</CodeGroup> |
| 237 | + |
| 238 | +#### Response |
| 239 | +<CodeGroup> |
| 240 | +```json Response |
| 241 | +{ |
| 242 | + "success": true, |
| 243 | + "message": "<string>" |
| 244 | +} |
| 245 | +``` |
| 246 | +</CodeGroup> |
| 247 | + |
| 248 | +### Explore MCP Server Tools |
| 249 | + |
| 250 | +<Accordion title="Tools Information"> |
| 251 | +| Tool Name | Description | |
| 252 | +|-----------------------|--------------------------------------------------------------------------| |
| 253 | +| exa_search | Perform AI-powered semantic search across the web using neural or keyword search with advanced filtering options including domains, dates, and content patterns | |
| 254 | +| exa_get_contents | Retrieve clean, parsed HTML content from web pages using their Exa result IDs with optional highlighting and summarization | |
| 255 | +| exa_find_similar | Discover web pages that are semantically similar to a given URL based on content meaning and context | |
| 256 | +| exa_answer | Get direct, focused answers to specific questions by searching and analyzing web sources with citations | |
| 257 | +| exa_research | Conduct comprehensive, multi-source research on topics with structured analysis and detailed citations | |
| 258 | +</Accordion> |
| 259 | + |
| 260 | +<Note>For more details about tool input schema, use the [list_tool](https://docs.klavis.ai/api-reference/mcp-server/list-tools) API.</Note> |
0 commit comments