Skip to main content
Glama
rspace-os

RSpace MCP Server

Official
by rspace-os

find_documents_by_content

Search RSpace documents by content terms using AND/OR operators, with options to exclude terms, sort results, and control page size.

Instructions

Advanced content-based document search

Usage: Find documents containing specific content terms

Parameters:

  • content_terms: List of terms that should appear in document content

  • operator: "and" (all terms must appear) or "or" (any term can appear)

  • exclude_terms: Optional list of terms to exclude from results

  • order_by: Sort results by field

  • page_size: Number of results to return

Returns: Dictionary with search results

Example: find_documents_by_content(["DNA", "extraction"], operator="and")

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
content_termsYes
operatorNoand
exclude_termsNo
order_byNolastModified desc
page_sizeNo

Implementation Reference

  • main.py:355-404 (handler)
    The handler function for the 'find_documents_by_content' MCP tool. It uses RSpace's AdvancedQueryBuilder for full-text search on document content with support for AND/OR operators and post-query exclusion filtering on document metadata.
    @mcp.tool(tags={"rspace", "search"})
    def find_documents_by_content(
        content_terms: List[str],
        operator: Literal["and", "or"] = "and",
        exclude_terms: List[str] = None,
        order_by: str = "lastModified desc",
        page_size: int = 20
    ) -> dict:
        """
        Advanced content-based document search
        
        Usage: Find documents containing specific content terms
        
        Parameters:
        - content_terms: List of terms that should appear in document content
        - operator: "and" (all terms must appear) or "or" (any term can appear)
        - exclude_terms: Optional list of terms to exclude from results
        - order_by: Sort results by field
        - page_size: Number of results to return
        
        Returns: Dictionary with search results
        
        Example: find_documents_by_content(["DNA", "extraction"], operator="and")
        """
        builder = AdvancedQueryBuilder(operator=operator)
        
        for term in content_terms:
            builder.add_term(term, AdvancedQueryBuilder.QueryType.FULL_TEXT)
        
        # Note: RSpace API doesn't directly support exclusion, but we can filter results
        advanced_query = builder.get_advanced_query()
        results = eln_cli.get_documents_advanced_query(
            advanced_query=advanced_query,
            order_by=order_by,
            page_number=0,
            page_size=page_size
        )
        
        # Filter out documents containing excluded terms if specified
        if exclude_terms and 'documents' in results:
            filtered_docs = []
            for doc in results['documents']:
                # Check if any exclude terms are in the document name or other available text
                doc_text = (doc.get('name', '') + ' ' + doc.get('tags', '')).lower()
                if not any(exclude_term.lower() in doc_text for exclude_term in exclude_terms):
                    filtered_docs.append(doc)
            results['documents'] = filtered_docs
            results['totalHits'] = len(filtered_docs)
        
        return results

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