Skip to main content
Glama
rspace-os

RSpace MCP Server

Official
by rspace-os

search_documents

Search across RSpace documents using text, tags, dates, or other criteria to find specific research data and information.

Instructions

Generic search tool for RSpace documents with flexible search options

Usage: Search across all your RSpace documents using various criteria

Parameters:

  • query: The search term(s) to look for

  • search_type: "simple" for basic search, "advanced" for multi-criteria search

  • query_types: List of search types to use (for advanced search):

    • "global": Search across all document content and metadata

    • "fullText": Search within document text content

    • "tag": Search by document tags

    • "name": Search by document names/titles

    • "created": Search by creation date (use ISO format like "2024-01-01")

    • "lastModified": Search by modification date

    • "form": Search by form type

    • "attachment": Search by attachments

  • operator: "and" (all criteria must match) or "or" (any criteria can match)

  • order_by: Sort results by field (e.g., "lastModified desc", "name asc")

  • page_number: Page number for pagination (0-based)

  • page_size: Number of results per page (max 200)

  • include_content: Whether to fetch full document content (slower but more complete)

Returns: Dictionary with search results and metadata

Examples:

  • Simple text search: search_documents("PCR protocol")

  • Search by tags: search_documents("experiment", search_type="advanced", query_types=["tag"])

  • Multi-criteria search: search_documents("DNA", search_type="advanced", query_types=["fullText", "tag"], operator="or")

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
search_typeNosimple
query_typesNo
operatorNoand
order_byNolastModified desc
page_numberNo
page_sizeNo
include_contentNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • main.py:172-272 (handler)
    The handler function for the 'search_documents' MCP tool. Decorated with @mcp.tool for automatic registration. Handles both simple and advanced searches across RSpace ELN documents using the eln_cli client, supporting various query types, operators, pagination, sorting, and optional full content retrieval.
    @mcp.tool(tags={"rspace", "search"})
    def search_documents(
        query: str,
        search_type: Literal["simple", "advanced"] = "simple",
        query_types: List[Literal["global", "fullText", "tag", "name", "created", "lastModified", "form", "attachment"]] = None,
        operator: Literal["and", "or"] = "and",
        order_by: str = "lastModified desc",
        page_number: int = 0,
        page_size: int = 20,
        include_content: bool = False
    ) -> dict:
        """
        Generic search tool for RSpace documents with flexible search options
        
        Usage: Search across all your RSpace documents using various criteria
        
        Parameters:
        - query: The search term(s) to look for
        - search_type: "simple" for basic search, "advanced" for multi-criteria search
        - query_types: List of search types to use (for advanced search):
            - "global": Search across all document content and metadata
            - "fullText": Search within document text content
            - "tag": Search by document tags
            - "name": Search by document names/titles
            - "created": Search by creation date (use ISO format like "2024-01-01")
            - "lastModified": Search by modification date
            - "form": Search by form type
            - "attachment": Search by attachments
        - operator: "and" (all criteria must match) or "or" (any criteria can match)
        - order_by: Sort results by field (e.g., "lastModified desc", "name asc")
        - page_number: Page number for pagination (0-based)
        - page_size: Number of results per page (max 200)
        - include_content: Whether to fetch full document content (slower but more complete)
        
        Returns: Dictionary with search results and metadata
        
        Examples:
        - Simple text search: search_documents("PCR protocol")
        - Search by tags: search_documents("experiment", search_type="advanced", query_types=["tag"])
        - Multi-criteria search: search_documents("DNA", search_type="advanced", 
                                                query_types=["fullText", "tag"], operator="or")
        """
        if page_size > 200:
            raise ValueError("page_size must be 200 or less")
        
        if search_type == "simple":
            # Use simple search - works like RSpace's "All" search
            results = eln_cli.get_documents(
                query=query,
                order_by=order_by,
                page_number=page_number,
                page_size=page_size
            )
        else:
            # Use advanced search with AdvancedQueryBuilder
            if query_types is None:
                query_types = ["global"]  # Default to global search
            
            builder = AdvancedQueryBuilder(operator=operator)
            
            # Add search terms for each specified query type
            for query_type in query_types:
                if query_type == "global":
                    builder.add_term(query, AdvancedQueryBuilder.QueryType.GLOBAL)
                elif query_type == "fullText":
                    builder.add_term(query, AdvancedQueryBuilder.QueryType.FULL_TEXT)
                elif query_type == "tag":
                    builder.add_term(query, AdvancedQueryBuilder.QueryType.TAG)
                elif query_type == "name":
                    builder.add_term(query, AdvancedQueryBuilder.QueryType.NAME)
                elif query_type == "created":
                    builder.add_term(query, AdvancedQueryBuilder.QueryType.CREATED)
                elif query_type == "lastModified":
                    builder.add_term(query, AdvancedQueryBuilder.QueryType.LAST_MODIFIED)
                elif query_type == "form":
                    builder.add_term(query, AdvancedQueryBuilder.QueryType.FORM)
                elif query_type == "attachment":
                    builder.add_term(query, AdvancedQueryBuilder.QueryType.ATTACHMENT)
            
            advanced_query = builder.get_advanced_query()
            results = eln_cli.get_documents_advanced_query(
                advanced_query=advanced_query,
                order_by=order_by,
                page_number=page_number,
                page_size=page_size
            )
        
        # Optionally fetch full content for each document
        if include_content and 'documents' in results:
            for doc in results['documents']:
                try:
                    full_doc = eln_cli.get_document(doc['globalId'])
                    # Add concatenated content to the document
                    content = ''
                    for field in full_doc.get('fields', []):
                        content += field.get('content', '')
                    doc['fullContent'] = content
                except Exception as e:
                    doc['fullContent'] = f"Error fetching content: {str(e)}"
        
        return results
Behavior3/5

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

With no annotations provided, the description carries full burden. It mentions performance impact ('slower but more complete' for include_content) and pagination behavior, but doesn't cover error conditions, rate limits, or authentication needs. It adequately describes core behavior but misses some operational details.

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 (generic description, usage, parameters, returns, examples). While comprehensive, it's appropriately sized for an 8-parameter tool. Some redundancy exists (e.g., repeating parameter details in examples), but overall 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 8 parameters with 0% schema coverage and no annotations, the description does an excellent job explaining inputs and providing examples. With an output schema present, it doesn't need to detail return values. It covers most essential context, though could benefit from more sibling differentiation.

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?

Schema description coverage is 0%, so the description must fully compensate. It provides detailed explanations for all 8 parameters, including enum values, defaults, and usage examples. This adds significant value beyond the bare schema, making parameter meanings clear.

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 searches RSpace documents with flexible options, specifying the resource (RSpace documents) and verb (search). It distinguishes from siblings like 'find_documents_by_content' and 'search_by_tags' by mentioning multiple search criteria, though not explicitly contrasting them.

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

Usage Guidelines3/5

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

The description implies usage through examples and parameter explanations, suggesting when to use simple vs. advanced search. However, it lacks explicit guidance on when to choose this tool over siblings like 'find_documents_by_content' or 'search_by_tags', leaving some ambiguity.

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/rspace-os/rspace-mcp'

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