Skip to main content
Glama
philipithomas

Contraption Company MCP

Official

search

Find relevant blog posts and essays using semantic search with AI-powered embeddings. Enter a query to retrieve content with relevance scores.

Instructions

Search blog posts using semantic search.

Args: query: Search query text limit: Maximum number of results to return (default: 10)

Returns: List of search results with relevance scores

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
limitNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The primary handler function for the 'search' MCP tool, decorated with @mcp.tool(name="search"). It limits results using settings.search_top_k, calls ChromaService.search, serializes PostSearchResult objects into a response dictionary with query, results list, and count.
    @mcp.tool(name="search")
    async def search(
        query: str,
        limit: int = 10,
    ) -> dict[str, Any]:
        """
        Search blog posts using semantic search.
    
        Args:
            query: Search query text
            limit: Maximum number of results to return (default: 10)
    
        Returns:
            List of search results with relevance scores
        """
        if limit > settings.search_top_k:
            limit = settings.search_top_k
    
        chroma_service = await get_chroma_service()
        results = await chroma_service.search(query, limit)
    
        serialized_results: list[dict[str, Any]] = []
        for result in results:
            if not result.post_url:
                logger.debug("Skipping search result without canonical URL: %s", result.post_slug)
                continue
    
            serialized_results.append(
                {
                    "id": result.post_url,
                    "title": result.post_title,
                    "url": result.post_url,
                    "excerpt": result.excerpt,
                    "relevance_score": result.relevance_score,
                    "published_at": result.published_at.isoformat() if result.published_at else None,
                    "tags": result.tags,
                }
            )
    
        return {
            "query": query,
            "results": serialized_results,
            "count": len(serialized_results),
        }
  • Pydantic BaseModel defining the structure of individual search results (aliased as PostSearchResult), including post metadata, excerpt, relevance score, used directly in the tool's implementation.
    class SearchResult(BaseModel):
        post_slug: str
        post_title: str
        post_url: str
        excerpt: str
        relevance_score: float
        published_at: datetime | None
        tags: list[str] = Field(default_factory=list)
  • ChromaService.search method implementing hybrid dense+sparse semantic search using RRF fusion, embedding the query, executing via _hybrid_rrf_search, parsing into PostSearchResult list; invoked by the MCP tool handler.
    async def search(self, query: str, limit: int = 10) -> list[PostSearchResult]:
        dense_embedding = self.embedding_service.embed_query(query)
        sparse_embedding = self.embedding_service.sparse_embed_query(query)
    
        results = self._hybrid_rrf_search(
            dense_embedding=dense_embedding,
            sparse_embedding=sparse_embedding,
            limit=limit,
        )
    
        # Console-friendly printout for quick debugging/inspection
        try:
            print(f"\nšŸ“Š Hybrid Search Results (RRF Combined) — Query: {query!r}")
            if results:
                for i, result in enumerate(results):
                    title = result.post_title or "Unknown"
                    score = result.relevance_score or 0.0
                    excerpt = (result.excerpt or "").strip()
                    print(f"   {i + 1}. [{title}] Score: {score:.4f}")
                    if excerpt:
                        print(f"      Text: {excerpt[:100]}...")
            else:
                print("   No results")
        except Exception:  # Best-effort printing; never block search on logging issues
            pass
    
        return results
  • Configuration setting search_top_k used to cap the limit parameter in the search tool handler.
    search_top_k: int = Field(default=10, description="Number of search results to return")
Behavior2/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 mentions semantic search and returns relevance scores, but fails to describe key traits like whether this is a read-only operation, potential rate limits, authentication needs, or how results are ordered. This leaves significant gaps in understanding the tool's behavior.

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 well-structured and front-loaded with the core purpose, followed by clear sections for Args and Returns. Every sentence adds value without redundancy, making it efficient and easy to parse for an AI agent.

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's moderate complexity (2 parameters, semantic search), no annotations, and an output schema present (which handles return values), the description is reasonably complete. It covers the purpose, parameters, and return type, though it lacks behavioral context like error handling or performance considerations, which holds it back from a perfect score.

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

Parameters4/5

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

The schema description coverage is 0%, so the description must compensate. It adds meaningful context for both parameters: 'query' is described as 'Search query text' and 'limit' as 'Maximum number of results to return (default: 10),' which clarifies their purposes beyond the bare schema. However, it doesn't detail constraints like query length or limit ranges.

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's purpose as 'Search blog posts using semantic search,' which is a specific verb+resource combination. However, it doesn't explicitly differentiate this semantic search capability from potential sibling tools like 'fetch' or 'list_posts,' which might offer different search methods or scopes.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'fetch' or 'list_posts.' It lacks any context about prerequisites, such as whether blog posts need to be indexed or if authentication is required, leaving the agent with no usage differentiation.

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/philipithomas/ghost-mcp'

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