Merge pull request #159 from tavily-ai/chore/add-human-id-support

Chore/add human id support
This commit is contained in:
pulvedu
2026-04-24 14:35:14 -04:00
committed by GitHub
4 changed files with 33 additions and 5 deletions
+23
View File
@@ -206,6 +206,29 @@ export DEFAULT_PARAMETERS='{"include_images": true}'
}
```
## Identifying the End User (Optional)
You can optionally identify the end user on whose behalf requests are being made by setting the `TAVILY_HUMAN_ID` environment variable. When set, Tavily MCP forwards it as the `X-Human-Id` header on every API call, enabling per-user analytics.
This is **entirely optional** — leave it unset and behavior is unchanged.
```json
{
"mcpServers": {
"tavily-mcp": {
"command": "npx",
"args": ["-y", "tavily-mcp@latest"],
"env": {
"TAVILY_API_KEY": "your-api-key-here",
"TAVILY_HUMAN_ID": "your-user-id"
}
}
}
}
```
**Privacy note:** Tavily hashes `human_id` server-side (SHA-256) before storage, so the raw value is never persisted. Even so, prefer opaque identifiers (e.g. an internal user ID) over raw PII like emails when possible.
## Acknowledgments ✨
- [Model Context Protocol](https://modelcontextprotocol.io) for the MCP specification
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "tavily-mcp",
"version": "0.2.18",
"version": "0.2.19",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "tavily-mcp",
"version": "0.2.18",
"version": "0.2.19",
"license": "MIT",
"dependencies": {
"@modelcontextprotocol/sdk": "1.26.0",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "tavily-mcp",
"version": "0.2.18",
"version": "0.2.19",
"mcpName": "io.github.tavily-ai/tavily-mcp",
"description": "MCP server for advanced web search using Tavily",
"repository": {
+7 -2
View File
@@ -4,6 +4,7 @@ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import {CallToolRequestSchema, ListToolsRequestSchema, Tool} from "@modelcontextprotocol/sdk/types.js";
import axios from "axios";
import { randomUUID } from "crypto";
import dotenv from "dotenv";
import { McpError, ErrorCode } from "@modelcontextprotocol/sdk/types.js";
import yargs from 'yargs';
@@ -12,6 +13,8 @@ import { hideBin } from 'yargs/helpers';
dotenv.config();
const API_KEY = process.env.TAVILY_API_KEY;
const HUMAN_ID = process.env.TAVILY_HUMAN_ID;
const SESSION_ID = randomUUID();
interface TavilyResponse {
@@ -81,7 +84,7 @@ class TavilyClient {
this.server = new Server(
{
name: "tavily-mcp",
version: "0.2.18",
version: "0.2.19",
},
{
capabilities: {
@@ -95,7 +98,9 @@ class TavilyClient {
'accept': 'application/json',
'content-type': 'application/json',
'Authorization': `Bearer ${API_KEY}`,
'X-Client-Source': 'MCP'
'X-Client-Source': 'MCP',
'X-Session-Id': SESSION_ID,
...(HUMAN_ID ? { 'X-Human-Id': HUMAN_ID } : {}),
}
});