Skip to main content
Glama
needle-ai

Needle MCP Server

Official
by needle-ai

needle_search

Search documents using semantic understanding to find relevant content based on meaning rather than keywords. Understands natural language queries and returns ranked passages with source information.

Instructions

Perform intelligent semantic search across documents in a Needle collection. This tool uses advanced embedding technology to find relevant content based on meaning, not just keywords. The search: - Understands natural language queries - Finds conceptually related content - Returns relevant text passages with source information - Ranks results by semantic relevance

        Use this tool when you need to:
        - Find specific information within documents
        - Answer questions from document content
        - Research topics across multiple documents
        - Locate relevant passages and their sources
        
        More effective than traditional keyword search for:
        - Natural language questions
        - Conceptual queries
        - Finding related content
        
        Returns matching text passages with their source file IDs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collection_idYesThe unique collection identifier to search within
queryYesNatural language query describing the information you're looking for

Implementation Reference

  • Executes the needle_search tool by validating arguments, calling NeedleClient.collections.search(), formatting results with content and file_id, and returning as JSON TextContent.
    elif name == "needle_search":
        if not isinstance(arguments, dict) or not all(k in arguments for k in ["collection_id", "query"]):
            raise ValueError("Missing required parameters")
        
        results = client.collections.search(
            collection_id=arguments["collection_id"],
            text=arguments["query"],
            # Optionally add these parameters if needed:
            # max_distance=0.8,  # Adjust threshold as needed
            # top_k=5  # Adjust number of results as needed
        )
        
        result = [{
            "content": r.content,
            "file_id": r.file_id,
        } for r in results]
    
        return [TextContent(
            type="text",
            text=json.dumps(result, indent=2, default=str)
        )]
  • Input schema for needle_search tool defining required collection_id and query parameters as strings.
    inputSchema={
        "type": "object",
        "properties": {
            "collection_id": {
                "type": "string",
                "description": "The unique collection identifier to search within"
            },
            "query": {
                "type": "string",
                "description": "Natural language query describing the information you're looking for"
            }
        },
        "required": ["collection_id", "query"]
    }
  • Registers the needle_search tool with the MCP server via list_tools(), including name, detailed description, and input schema.
    Tool(
        name="needle_search",
        description="""Perform intelligent semantic search across documents in a Needle collection.
        This tool uses advanced embedding technology to find relevant content based on meaning,
        not just keywords. The search:
        - Understands natural language queries
        - Finds conceptually related content
        - Returns relevant text passages with source information
        - Ranks results by semantic relevance
        
        Use this tool when you need to:
        - Find specific information within documents
        - Answer questions from document content
        - Research topics across multiple documents
        - Locate relevant passages and their sources
        
        More effective than traditional keyword search for:
        - Natural language questions
        - Conceptual queries
        - Finding related content
        
        Returns matching text passages with their source file IDs.""",
        inputSchema={
            "type": "object",
            "properties": {
                "collection_id": {
                    "type": "string",
                    "description": "The unique collection identifier to search within"
                },
                "query": {
                    "type": "string",
                    "description": "Natural language query describing the information you're looking for"
                }
            },
            "required": ["collection_id", "query"]
        }
    )
Behavior4/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 effectively describes key behavioral traits: it's a search operation (implied read-only), uses semantic matching rather than keywords, returns ranked results with source information, and handles natural language queries. However, it doesn't mention potential limitations like rate limits, authentication requirements, or performance characteristics.

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 well-structured with clear sections (purpose, usage guidelines, effectiveness, returns) and uses bullet points for readability. While comprehensive, it could be slightly more concise by combining some bullet points or reducing redundancy in the effectiveness section.

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?

For a search tool with 2 parameters, 100% schema coverage, and no output schema, the description provides good context about what the tool does, when to use it, and what it returns. It explains the semantic nature of the search and provides usage scenarios. The main gap is the lack of output format details beyond 'matching text passages with their source file IDs' - more specificity about the return structure would be helpful.

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%, providing clear parameter documentation. The description adds some context by mentioning 'natural language queries' which aligns with the query parameter description, and 'collection' context which matches collection_id. However, it doesn't provide significant additional semantic meaning beyond what's already in the schema 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 performs 'intelligent semantic search across documents in a Needle collection' with specific details about using embedding technology, finding relevant content based on meaning, and distinguishing it from keyword search. It explicitly differentiates from sibling tools like needle_add_file (adds files), needle_create_collection (creates collections), and needle_list_files (lists files) by focusing on search functionality.

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

Usage Guidelines5/5

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

The description provides explicit guidance with a dedicated 'Use this tool when you need to:' section listing four specific scenarios (find information, answer questions, research topics, locate passages) and a 'More effective than traditional keyword search for:' section with three cases (natural language questions, conceptual queries, finding related content). This clearly indicates when to use this tool versus alternatives like keyword-based search methods.

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/needle-ai/needle-mcp'

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