Skip to main content
Glama
needle-ai

Needle MCP Server

Official
by needle-ai

needle_add_file

Add documents to a collection by providing a URL for download, processing them for text extraction, and indexing them for semantic search.

Instructions

Add a new document to a Needle collection by providing a URL for download. Supports multiple file formats including: - PDF documents - Microsoft Word files (DOC, DOCX) - Plain text files (TXT) - Web pages (HTML)

        The document will be:
        1. Downloaded from the provided URL
        2. Processed for text extraction
        3. Indexed for semantic search
        
        Use this tool when you need to:
        - Add new documents to a collection
        - Make documents searchable
        - Expand your knowledge base
        
        Important: Documents require processing time before they're searchable.
        Check processing status using needle_list_files before searching new content.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collection_idYesThe unique collection identifier where the file will be added
nameYesA descriptive filename that will help identify this document in results
urlYesPublic URL where the document can be downloaded from

Implementation Reference

  • Executes the needle_add_file tool: validates collection_id, name, and url parameters, calls Needle client's collections.files.add() to upload the file from URL, and returns the new file ID.
    elif name == "needle_add_file":
        if not isinstance(arguments, dict) or not all(k in arguments for k in ["collection_id", "name", "url"]):
            raise ValueError("Missing required parameters")
        if not validate_collection_id(arguments["collection_id"]):
            raise ValueError("Invalid collection ID format")
        if not validate_url(arguments["url"]):
            raise ValueError("Invalid URL format")
        files = client.collections.files.add(
            collection_id=arguments["collection_id"],
            files=[FileToAdd(name=arguments["name"], url=arguments["url"])]
        )
        result = {"file_id": files[0].id}
  • Input schema definition for needle_add_file tool, specifying required string parameters: collection_id, name, and url with descriptions.
    inputSchema={
        "type": "object",
        "properties": {
            "collection_id": {
                "type": "string",
                "description": "The unique collection identifier where the file will be added"
            },
            "name": {
                "type": "string",
                "description": "A descriptive filename that will help identify this document in results"
            },
            "url": {
                "type": "string",
                "description": "Public URL where the document can be downloaded from"
            }
        },
        "required": ["collection_id", "name", "url"]
    }
  • Registers the needle_add_file tool in the MCP server's list_tools() function with name, detailed description, and input schema.
    Tool(
        name="needle_add_file",
        description="""Add a new document to a Needle collection by providing a URL for download.
        Supports multiple file formats including:
        - PDF documents
        - Microsoft Word files (DOC, DOCX)
        - Plain text files (TXT)
        - Web pages (HTML)
        
        The document will be:
        1. Downloaded from the provided URL
        2. Processed for text extraction
        3. Indexed for semantic search
        
        Use this tool when you need to:
        - Add new documents to a collection
        - Make documents searchable
        - Expand your knowledge base
        
        Important: Documents require processing time before they're searchable.
        Check processing status using needle_list_files before searching new content.""",
        inputSchema={
            "type": "object",
            "properties": {
                "collection_id": {
                    "type": "string",
                    "description": "The unique collection identifier where the file will be added"
                },
                "name": {
                    "type": "string",
                    "description": "A descriptive filename that will help identify this document in results"
                },
                "url": {
                    "type": "string",
                    "description": "Public URL where the document can be downloaded from"
                }
            },
            "required": ["collection_id", "name", "url"]
        }
    ),
Behavior4/5

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

With no annotations provided, the description carries full burden and discloses key behavioral traits: the three-step processing pipeline (download, text extraction, indexing), supported file formats, and the important latency consideration ('Documents require processing time before they're searchable'). It doesn't mention error handling or authentication needs, but covers core operational behavior well.

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?

Well-structured with clear sections (supported formats, processing steps, usage guidelines, important note) and front-loaded core purpose. Every sentence adds value, though the bullet-point formatting for file formats could be slightly more concise.

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 3-parameter mutation tool with no annotations and no output schema, the description provides comprehensive context: purpose, usage guidelines, behavioral transparency, and important limitations. It doesn't describe return values or error cases, but given the tool's complexity and lack of structured metadata, it's reasonably complete.

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 three parameters. The description adds context about what the 'url' parameter represents ('Public URL where the document can be downloaded from') and implies the purpose of 'name' ('descriptive filename'), but doesn't provide additional semantic meaning beyond what's in the schema. Baseline 3 is appropriate when schema does the heavy lifting.

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 specific action ('Add a new document'), target resource ('Needle collection'), and mechanism ('by providing a URL for download'). It distinguishes from siblings like needle_create_collection (creates collections) and needle_list_files (lists files) by focusing on document ingestion.

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?

Explicitly provides three use cases ('when you need to: - Add new documents to a collection - Make documents searchable - Expand your knowledge base') and mentions an alternative tool ('Check processing status using needle_list_files before searching new content'), giving clear guidance on when to use this tool versus others.

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