Skip to main content
Glama

recommend_next

Analyzes your current MCP server stack and a new development context to recommend the next server to add, with reasoning for the choice.

Instructions

Mid-project advisor: given your current MCP stack (comma-separated server names) and a new development context, recommend what to add next and why. Example: current_stack="github,filesystem", new_context="adding Stripe payments and PDF invoices"

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
current_stackYes
new_contextYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the 'recommend_next' tool. It accepts current_stack (comma-separated server names) and new_context, finds semantically similar servers excluding already-installed ones, and returns a formatted recommendation.
    def recommend_next(current_stack: str, new_context: str) -> str:
        """
        Mid-project advisor: given your current MCP stack (comma-separated server names) and a new
        development context, recommend what to add next and why.
        Example: current_stack="github,filesystem", new_context="adding Stripe payments and PDF invoices"
        """
        try:
            _ensure_index()
            installed = [s.strip() for s in current_stack.split(",") if s.strip()]
            results = find_similar(new_context, top_k=5, exclude=installed)
    
            header = (
                f"## What to add next\n"
                f"**Current stack:** {current_stack}\n"
                f"**New context:** {new_context}\n\n"
            )
            return header + _format_results(results, new_context)
        except Exception as e:
            return _error_response("computing next recommendations", e)
  • The tool is registered via the @mcp.tool() decorator on line 75, which is a FastMCP decorator that registers the function as an MCP tool named 'recommend_next'.
    @mcp.tool()
    def recommend_next(current_stack: str, new_context: str) -> str:
  • Error formatting helper used by recommend_next when an exception occurs.
    def _error_response(context: str, exc: Exception) -> str:
        traceback.print_exc(file=sys.stderr)
        return (
            f"## Error while {context}\n\n"
            f"{type(exc).__name__}: {exc}\n\n"
            f"See server logs for details. If this persists, try rebuilding the "
            f"index with `uv run python -m mcpilot.indexer --force`."
        )
  • Result formatting helper used by recommend_next to format the list of recommended servers into markdown.
    def _format_results(results: list[dict], project_description: str) -> str:
        if not results:
            return "No matching MCP servers found. Try a more descriptive project description."
    
        lines = []
        for i, r in enumerate(results, 1):
            rationale = generate_rationale(r, project_description)
            lines.append(
                f"{i}. **{r['name']}**\n"
                f"   {r['url']}\n"
                f"   {rationale}\n"
            )
        return "\n".join(lines)
  • The semantic search function called by recommend_next. Takes a query string and optional exclude list to filter out already-installed servers.
    def find_similar(
        query: str,
        top_k: int = 10,
        exclude: list[str] | None = None,
        min_score: float = DEFAULT_MIN_SCORE,
    ) -> list[dict]:
        """
        Return top_k servers most semantically similar to query.
        Each result: {name, url, description, category, score}
        """
        model = _get_model()
        query_emb = model.encode([query])[0].tolist()
    
        excluded_lower = {n.lower() for n in (exclude or [])}
        fetch_limit = top_k + max(len(excluded_lower) * 3, 10)
    
        con = get_connection()
        rows = con.execute(
            """
            SELECT name, description, url, category, score FROM (
                SELECT name, description, url, category,
                       array_cosine_similarity(embedding, ?::FLOAT[384]) AS score
                FROM servers
            )
            WHERE score >= ?
            ORDER BY score DESC
            LIMIT ?
            """,
            [query_emb, min_score, fetch_limit],
        ).fetchall()
        con.close()
    
        results = []
        for name, desc, url, cat, score in rows:
            name_lower = name.lower()
            short_name = name_lower.split("/")[-1]
            if any(
                e == name_lower or e == short_name or e in name_lower
                for e in excluded_lower
            ):
                continue
            results.append(
                {
                    "name": name,
                    "url": url,
                    "description": desc,
                    "category": cat,
                    "score": float(score),
                }
            )
            if len(results) >= top_k:
                break
    
        # Adaptive fallback: if nothing cleared the threshold, return the closest
        # matches below it so callers never silently get zero results.
        if not results and min_score > 0:
            return find_similar(query, top_k=top_k, exclude=exclude, min_score=0.0)
    
        return results
Behavior3/5

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

No annotations provided, so description carries burden. It discloses output includes 'why', but no side-effect, auth, or safety info. Adequate but not rich.

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?

Two sentences plus example, front-loaded, no wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given tool simplicity (2 params, output schema exists), description covers purpose and parameters adequately. No missing elements for this complexity level.

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?

Adds significant meaning beyond schema: explains 'current_stack' expects comma-separated server names and 'new_context' is development context. Schema coverage 0% but description fully compensates.

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 it recommends what to add next given a current stack and new context. It distinguishes from siblings by focusing on incremental additions for mid-project.

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

Usage Guidelines4/5

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

Implied when-to-use: mid-project with a stack and new context. No explicit when-not or alternatives, but the context is clear.

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/yahiaklk/mcpilot'

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