Skip to content

Add server instructions + clarify tool descriptions - #189

Open
SynthLuvr wants to merge 6 commits into
tavily-ai:mainfrom
SynthLuvr:fix/server-instructions-tool-guidance
Open

Add server instructions + clarify tool descriptions#189
SynthLuvr wants to merge 6 commits into
tavily-ai:mainfrom
SynthLuvr:fix/server-instructions-tool-guidance

Conversation

@SynthLuvr

@SynthLuvr SynthLuvr commented Jul 15, 2026

Copy link
Copy Markdown

Fixes #188.

tavily-mcp advertises five overlapping tools (tavily_search, tavily_research, tavily_extract, tavily_crawl, tavily_map) but provided no server-level instructions and only isolated per-tool descriptions. As a result, agents frequently pick the wrong tool or misuse them (e.g. calling tavily_extract as a search, passing a query instead of URLs), and tools/list gave no guidance on which tool to start with or how they combine. Issue #188 also flagged that in keyless mode the server advertises tools that cannot actually run.

Changes

1. Add a server-level instructions string (the canonical MCP field) to the Server constructor's ServerOptions. Clients that surface instructions (Goose, Claude, Cursor) now get:

  • a tool-selection decision tree (tavily_search is the default; escalate to tavily_research only for broad multi-source synthesis; tavily_extract/crawl/map are URL/site-scoped),
  • how the tools combine (search -> extract; map -> crawl),
  • the return format: every tool returns a single markdown text string, not a JSON object.

2. Rewrite all five per-tool descriptions (both the ListTools request handler and the listTools() helper, kept consistent) to state when to use each tool, how they combine, and that the return value is plain text.

3. Surface keyless-mode limitations (second half of #188). In keyless mode (no TAVILY_API_KEY), only tavily_search and tavily_extract work; crawl/map/research return an 'API key required' message at call time. Now reflected in the advertisement:

  • The instructions API-key note is mode-aware (replacing the inaccurate 'All tools require TAVILY_API_KEY' line).
  • A describeTool() helper appends a 'requires API key' note to the crawl/map/research descriptions only when keyless, in both the ListTools handler and the listTools() CLI helper. The advertised tool set is unchanged (annotation, not omission) for backwards compatibility.

Compatibility

  • Backwards compatible: instructions is an optional field; no tool name, schema, or API-call behavior changes.

Verification

Verified end-to-end with an MCP stdio client against the built server (0.2.21), in both keyed and keyless modes:

  • initialize returns instructions (mode-aware; the keyless branch lists which tools are available).
  • tools/list returns the updated descriptions; crawl/map/research carry the keyless note only when TAVILY_API_KEY is unset; search/extract are always clean.
  • Calling crawl/map/research while keyless returns the expected 'API key required' message (no errors).
  • tsc --noEmit (strict) and npm run build pass; all 5 tools remain present with unchanged schemas.

)

The server advertised five overlapping tools with no server-level
'instructions' and only isolated per-tool descriptions, so agents picked
the wrong tool or misused them (e.g. calling tavily_extract as a search,
or reading .results on what is actually a text return).

- Add an 'instructions' string to the Server constructor (ServerOptions)
  so clients that surface it (Goose, Claude, Cursor) get a tool-selection
  decision tree, tool-combination guidance (search->extract, map->crawl),
  and the return format: every tool returns ONE markdown text string, not
  a JSON object.
- Rewrite all five per-tool descriptions (ListTools handler + listTools()
  helper) to state when to use each tool, how they combine, and that the
  return value is plain text with no .results/.answer.

Backwards compatible; no change to API calls themselves.
Only tavily_search and tavily_extract work without TAVILY_API_KEY; crawl/map/research return an 'API key required' message at call time (issue tavily-ai#188).

- instructions: replace the inaccurate 'All tools require TAVILY_API_KEY' line with mode-aware text (keyless vs keyed).

- Add describeTool() helper that appends a 'requires API key' note to crawl/map/research descriptions when IS_KEYLESS, in both the ListTools handler and the listTools() CLI helper. Advertised tool set unchanged (annotation, not omission).
@SynthLuvr
SynthLuvr marked this pull request as ready for review July 17, 2026 11:27
@SynthLuvr
SynthLuvr requested a review from a team July 17, 2026 11:27
RobertTylman and others added 2 commits August 13, 2026 10:50
The README listed only four tools (search, extract, map, crawl) despite
the server exposing five. Add tavily_research throughout:

- Replace the intro bullet list with a five-tool summary table
- Add a usage note explaining when to prefer research over search
(addresses the agent tool-selection confusion described in issue tavily-ai#188)
- Add a dedicated tavily_research section with parameter reference,
  example, and notes on rate limits, credit cost, and response format
- Update the Claude Code setup section to mention all five tools

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove the standalone endpoint section and decorative emojis in response to review feedback.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Server is missing an instructions field, leaving agents with no guidance on which tool to use or how they combine

2 participants