Skip to main content
Glama
tsmndev

tavily-mcp-python

by tsmndev

tavily-map

Generate structured website maps to analyze site architecture, navigation paths, and content organization. Ideal for site audits, content discovery, and understanding web structure with customizable depth and breadth settings.

Instructions

A powerful web mapping tool that creates a structured map of website URLs, allowing you to discover and analyze site structure, content organization, and navigation paths. Perfect for site audits, content discovery, and understanding website architecture.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
allow_externalNoWhether to allow following links that go to external domains
categoriesNoFilter URLs using predefined categories like documentation, blog, api, etc
instructionsYesNatural language instructions for the crawler
limitNoTotal number of links the crawler will process before stopping
max_breadthNoMax number of links to follow per level of the tree (i.e., per page)
max_depthNoMax depth of the mapping. Defines how far from the base URL the crawler can explore
select_domainsNoRegex patterns to select crawling to specific domains or subdomains (e.g., ^docs\.example\.com$)
select_pathsNoRegex patterns to select only URLs with specific path patterns (e.g., /docs/.*, /api/v1.*)
urlYesRoot URL to begin the mapping

Implementation Reference

  • The core handler function for the 'tavily-map' tool, decorated with @mcp_server.tool(name='tavily-map'). It constructs parameters from inputs, sends a POST request to Tavily's map API endpoint, handles authentication/rate limit errors, and validates/returns the response using TavilyMapResponse schema.
    @mcp_server.tool(name='tavily-map')
    async def map(
        url: Annotated[str, Field(
            description="""Root URL to begin the mapping"""
        )],
        instructions: Annotated[str, Field(
            description="""Natural language instructions for the crawler"""
        )],
        max_depth: Annotated[int, Field(
            default=1,
            ge=1,
            description="""Max depth of the mapping. Defines how far from the base URL the crawler can explore"""
        )],
        max_breadth: Annotated[int, Field(
            default=20,
            ge=1,
            description="""Max number of links to follow per level of the tree (i.e., per page)"""
        )],
        limit: Annotated[int, Field(
            default=50,
            ge=1,
            description="""Total number of links the crawler will process before stopping"""
        )],
        select_paths: Annotated[list[str], Field(
            default_factory=list,
            description="""Regex patterns to select only URLs with specific path patterns (e.g., /docs/.*, /api/v1.*)"""
        )],
        select_domains: Annotated[list[str], Field(
            default_factory=list,
            description="""Regex patterns to select crawling to specific domains or subdomains (e.g., ^docs\\.example\\.com$)"""
        )],
        allow_external: Annotated[bool, Field(
            default=False,
            description="""Whether to allow following links that go to external domains"""
        )],
        categories: Annotated[list[CrawlCategoriesLiteral], Field(
            default_factory=list,
            description="""Filter URLs using predefined categories like documentation, blog, api, etc"""
        )],
    ) -> dict[str, Any]:
        """A powerful web mapping tool that creates a structured map of website URLs, allowing you to discover and analyze site structure, content organization, and navigation paths. Perfect for site audits, content discovery, and understanding website architecture."""
        endpoint = base_urls['map']
        search_params = {
            "url": url,
            "instructions": instructions,
            "max_depth": max_depth,
            "max_breadth": max_breadth,
            "limit": limit,
            "select_paths": select_paths,
            "select_domains": select_domains,
            "allow_external": allow_external,
            "categories": categories,
            "api_key": TAVILY_API_KEY,
        }
    
        try:
            async with httpx.AsyncClient(headers=headers) as client:
                response = await client.post(endpoint, json=search_params)
                if not response.is_success:
                    if response.status_code == 401:
                        raise ValueError("Invalid API Key")
                    elif response.status_code == 429:
                        raise ValueError("Usage limit exceeded")
                    _ = response.raise_for_status()
    
        except BaseException as e:
            raise e
    
        response_dict: dict[str, Any] = response.json()
        return TavilyMapResponse.model_validate(response_dict).model_dump()
  • Pydantic model (TavilyMapResponse) defining the expected response structure from the Tavily map API, used for validation in the tool handler.
    class TavilyMapResponse(BaseModel):
      base_url: str
      results: list[str]
      response_time: float
  • The @mcp_server.tool decorator registers the 'map' function as the 'tavily-map' tool with the MCP server.
    @mcp_server.tool(name='tavily-map')
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. While it mentions the tool 'creates a structured map' and is 'perfect for site audits,' it lacks critical behavioral details: what format the output takes (structured how?), whether it's a read-only operation (implied but not stated), performance characteristics, error handling, or any limitations beyond what parameters suggest. For a complex 9-parameter web crawling tool with no annotations, this is inadequate.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately concise with two sentences that efficiently communicate core functionality and use cases. The first sentence defines the tool's purpose, and the second provides application contexts. There's no wasted language, though it could be slightly more front-loaded with explicit differentiation from siblings.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex web mapping tool with 9 parameters, no annotations, and no output schema, the description is incomplete. It doesn't address what the output looks like (critical since there's no output schema), doesn't explain behavioral constraints or performance implications, and offers minimal guidance on parameter usage beyond what the schema provides. The agent would struggle to use this tool effectively without trial and error.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 9 parameters thoroughly. The description adds no specific parameter semantics beyond implying general mapping behavior. It doesn't explain how parameters like 'categories' or 'instructions' integrate with the mapping process, nor does it provide context for parameter interactions. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose as creating structured maps of website URLs for analysis of site structure, content organization, and navigation paths. It specifies the verb 'creates' and resource 'structured map of website URLs' with clear use cases (site audits, content discovery, website architecture). However, it doesn't explicitly differentiate from sibling tools like tavily-crawl or tavily-extract, which likely have overlapping functionality.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus its siblings (tavily-crawl, tavily-extract, tavily-search). It mentions general use cases like 'site audits, content discovery, and understanding website architecture' but offers no explicit when/when-not criteria or alternative selection guidance. The agent must infer usage from the tool name and description alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/tsmndev/tavily-mcp-python'

If you have feedback or need assistance with the MCP directory API, please join our Discord server