Skip to main content
Glama
rcdelacruz

Nexus MCP Server

by rcdelacruz

nexus_search

Perform hybrid web searches combining broad coverage with technical documentation focus. Choose between general web search or documentation-optimized mode to get relevant results with titles, URLs, and snippets.

Instructions

A hybrid search tool combining Exa's breadth and Ref's specificity.

Args:
    query: The search term.
    mode: 'general' for broad web search (Exa style).
          'docs' to prioritize technical documentation (Ref style).
    max_results: Number of results to return (1-20).

Returns:
    Formatted search results with titles, URLs, and snippets.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
modeNogeneral
max_resultsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The core handler function for the 'nexus_search' tool. It performs hybrid search using DuckDuckGo (DDGS), supports 'general' and 'docs' modes, validates inputs, handles errors, and formats results with titles, URLs, and snippets.
    @mcp.tool()
    async def nexus_search(
        query: str,
        mode: str = "general",
        max_results: int = DEFAULT_MAX_RESULTS
    ) -> str:
        """
        A hybrid search tool combining Exa's breadth and Ref's specificity.
    
        Args:
            query: The search term.
            mode: 'general' for broad web search (Exa style).
                  'docs' to prioritize technical documentation (Ref style).
            max_results: Number of results to return (1-20).
    
        Returns:
            Formatted search results with titles, URLs, and snippets.
        """
        logger.info(f"Search requested - Query: '{query}', Mode: {mode}, Max results: {max_results}")
    
        # Validate inputs
        if not query or not query.strip():
            error_msg = "Query cannot be empty"
            logger.error(error_msg)
            return f"Error: {error_msg}"
    
        if mode not in ["general", "docs"]:
            error_msg = f"Invalid mode '{mode}'. Must be 'general' or 'docs'"
            logger.error(error_msg)
            return f"Error: {error_msg}"
    
        # Clamp max_results to reasonable range
        max_results = max(1, min(max_results, 20))
    
        # If 'docs' mode is selected, we modify the query to target technical sources
        final_query = query.strip()
        if mode == "docs":
            final_query += " site:readthedocs.io OR site:github.com OR site:stackoverflow.com OR documentation API"
            logger.debug(f"Enhanced query for docs mode: '{final_query}'")
    
        results = []
        try:
            # Use DuckDuckGo as our free backend
            with DDGS(timeout=SEARCH_TIMEOUT) as ddgs:
                # Convert generator to list to properly check if empty
                ddg_results = list(ddgs.text(final_query, max_results=max_results))
    
                if not ddg_results:
                    logger.warning(f"No results found for query: '{query}'")
                    return "No results found. Try a different query or mode."
    
                for r in ddg_results:
                    title = r.get('title', 'No title')
                    url = r.get('href', 'No URL')
                    snippet = r.get('body', 'No description')
                    results.append(f"- [Title]: {title}\n  [URL]: {url}\n  [Snippet]: {snippet}")
    
                logger.info(f"Search successful - Found {len(results)} results")
                return "\n\n".join(results)
    
        except TimeoutError:
            error_msg = "Search timed out. Please try again."
            logger.error(f"Search timeout for query: '{query}'")
            return f"Error: {error_msg}"
        except Exception as e:
            error_msg = f"Search failed: {str(e)}"
            logger.exception(f"Unexpected error during search: {query}")
            return f"Error: {error_msg}"
  • Function signature with type annotations and comprehensive docstring defining the input schema (query: str required, mode: str='general', max_results: int=5) and output (str of formatted results). Used by FastMCP for JSON schema generation.
    async def nexus_search(
        query: str,
        mode: str = "general",
        max_results: int = DEFAULT_MAX_RESULTS
    ) -> str:
        """
        A hybrid search tool combining Exa's breadth and Ref's specificity.
    
        Args:
            query: The search term.
            mode: 'general' for broad web search (Exa style).
                  'docs' to prioritize technical documentation (Ref style).
            max_results: Number of results to return (1-20).
    
        Returns:
            Formatted search results with titles, URLs, and snippets.
        """
  • nexus_server.py:28-28 (registration)
    The @mcp.tool() decorator registers the nexus_search function as an MCP tool in the FastMCP server instance 'mcp'.
    @mcp.tool()
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It explains the hybrid nature of the search and the two modes, but doesn't mention rate limits, authentication requirements, or what happens with invalid inputs. The description adds some context but lacks comprehensive behavioral details.

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

Conciseness5/5

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

The description is perfectly structured and front-loaded: it starts with the core purpose, then clearly lists arguments with explanations, and ends with return information. Every sentence earns its place with no wasted words, making it highly efficient.

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

Completeness4/5

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

Given the tool has an output schema (which handles return value documentation) and the description provides good parameter semantics, it's mostly complete. However, for a search tool with no annotations, it could benefit from mentioning rate limits or authentication requirements to achieve full completeness.

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

Parameters5/5

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

The description adds significant meaning beyond the input schema, which has 0% description coverage. It explains what each parameter does: 'query' as the search term, 'mode' with specific explanations for 'general' and 'docs' options, and 'max_results' with its range constraint (1-20). This fully compensates for the schema's lack of descriptions.

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

Purpose5/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: 'A hybrid search tool combining Exa's breadth and Ref's specificity.' It specifies the verb (search) and resource (web/technical documentation), and distinguishes it from its sibling 'nexus_read' by focusing on search rather than reading operations.

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

Usage Guidelines4/5

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

The description provides clear context for when to use different modes: 'general' for broad web search and 'docs' to prioritize technical documentation. However, it doesn't explicitly state when NOT to use this tool or mention alternatives beyond the mode selection, which prevents a perfect score.

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

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/rcdelacruz/nexus-mcp'

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