Skip to main content
Glama

recommend_config

Run a tuner to evaluate and rank chunking strategies for your RAG corpus, returning recommendations based on your use case and content.

Instructions

Run tuner and return ranked Recommendation (uses dummy embeddings by default).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes
use_caseNorag_qa
content_typeNo
strategiesNo
max_docsNo
top_kNo
embedding_modelNo

Implementation Reference

  • Core implementation of recommend_config: validates path/strategies, creates embedding function, ingests docs, builds AutoTuner, calls tuner.recommend(), and returns ranked Recommendation.
    def recommend_config_impl(
        path: str,
        use_case: str,
        *,
        content_type: str | None = None,
        strategies: list[str] | None = None,
        max_docs: int = 20,
        top_k: int = 5,
        embedding_model: str | None = None,
    ) -> dict:
        p = require_under_base(path)
        if not p.exists():
            raise ValueError("path does not exist")
        if strategies is not None:
            _validate_strategies(strategies)
        embed = (
            LiteLLMEmbeddingFunction(embedding_model) if embedding_model else DummyEmbeddingFunction()
        )
        fi = FileIngestor(root=p.parent if p.is_file() else p)
        docs = fi.ingest_path(p) if p.is_file() else fi.ingest_dir(p)
        docs = docs[:max_docs]
        uc = cast(UseCase, use_case)
        tuner = AutoTuner(
            build_full_registry(),
            Evaluator(embed, top_k=top_k),
            ScoreCalculator(uc),
        )
        strat_names = strategies or ["fixed_tokens", "recursive_character"]
        rec = tuner.recommend(
            docs,
            uc,
            strategies=strat_names,
            max_docs=max_docs,
            baseline=True,
            content_type=content_type,
        )
        return rec.model_dump()
  • MCP tool registration as a FastMCP @tool decorator: wraps recommend_config_impl with semaphore protection and logging.
    @mcp.tool()
    def recommend_config(
        path: str,
        use_case: str = "rag_qa",
        content_type: str | None = None,
        strategies: list[str] | None = None,
        max_docs: int = 20,
        top_k: int = 5,
        embedding_model: str | None = None,
    ) -> dict:
        """Run tuner and return ranked ``Recommendation`` (uses dummy embeddings by default)."""
        t0 = time.perf_counter()
        with _eval_sem:
            try:
                out = recommend_config_impl(
                    path,
                    use_case,
                    content_type=content_type,
                    strategies=strategies,
                    max_docs=max_docs,
                    top_k=top_k,
                    embedding_model=embedding_model,
                )
                _log_tool("recommend_config", t0, True)
                return out
            except Exception:
                _log_tool("recommend_config", t0, False)
                raise
  • register_tools() function registers all MCP tools on the FastMCP instance via decorator pattern.
    def register_tools(mcp: object) -> None:
        from mcp.server.fastmcp import FastMCP
    
        if not isinstance(mcp, FastMCP):
            raise TypeError("Expected FastMCP instance")
    
        @mcp.tool()
        def list_strategies(content_type: str | None = None) -> list[dict]:
            """List registered chunking strategies, optionally filtered by content type."""
            t0 = time.perf_counter()
            try:
                out = list_strategies_impl(content_type)
                _log_tool("list_strategies", t0, True)
                return out
            except Exception:
                _log_tool("list_strategies", t0, False)
                raise
    
        @mcp.tool()
        def preview_chunks(
            text: str,
            strategy_name: str,
            config: dict | None = None,
        ) -> list[dict]:
            """Chunk inline text with one strategy + params (no embeddings)."""
            t0 = time.perf_counter()
            try:
                out = preview_chunks_impl(text, strategy_name, config or {})
                _log_tool("preview_chunks", t0, True)
                return out
            except Exception:
                _log_tool("preview_chunks", t0, False)
                raise
    
        @mcp.tool()
        def evaluate_chunking(
            path: str,
            use_case: str = "rag_qa",
            content_type: str | None = None,
            strategies: list[str] | None = None,
            max_docs: int = 20,
            top_k: int = 5,
            dry_run: bool = False,
            embedding_model: str | None = None,
        ) -> dict:
            """Dry-run cost estimate or full evaluation (``DummyEmbeddingFunction`` if no model)."""
            t0 = time.perf_counter()
            with _eval_sem:
                try:
                    out = evaluate_chunking_impl(
                        path,
                        use_case,
                        content_type=content_type,
                        strategies=strategies,
                        max_docs=max_docs,
                        top_k=top_k,
                        dry_run=dry_run,
                        embedding_model=embedding_model,
                    )
                    _log_tool("evaluate_chunking", t0, True)
                    return out
                except Exception:
                    _log_tool("evaluate_chunking", t0, False)
                    raise
    
        @mcp.tool()
        def recommend_config(
            path: str,
            use_case: str = "rag_qa",
            content_type: str | None = None,
            strategies: list[str] | None = None,
            max_docs: int = 20,
            top_k: int = 5,
            embedding_model: str | None = None,
        ) -> dict:
            """Run tuner and return ranked ``Recommendation`` (uses dummy embeddings by default)."""
            t0 = time.perf_counter()
            with _eval_sem:
                try:
                    out = recommend_config_impl(
                        path,
                        use_case,
                        content_type=content_type,
                        strategies=strategies,
                        max_docs=max_docs,
                        top_k=top_k,
                        embedding_model=embedding_model,
                    )
                    _log_tool("recommend_config", t0, True)
                    return out
                except Exception:
                    _log_tool("recommend_config", t0, False)
                    raise
  • Pydantic request body model for the /recommend_config HTTP endpoint (path, use_case, content_type, strategies, max_docs, top_k, embedding_model).
    class RecommendConfigBody(BaseModel):
        path: str
        use_case: str = "rag_qa"
        content_type: str | None = None
        strategies: list[str] | None = None
        max_docs: int = 20
        top_k: int = 5
        embedding_model: str | None = None
  • FastAPI HTTP POST endpoint at /recommend_config, delegates to recommend_config_impl.
    @router.post("/recommend_config")
    def recommend_config(body: RecommendConfigBody) -> dict:
        try:
            return recommend_config_impl(
                body.path,
                body.use_case,
                content_type=body.content_type,
                strategies=body.strategies,
                max_docs=body.max_docs,
                top_k=body.top_k,
                embedding_model=body.embedding_model,
            )
        except ValueError as e:
            raise HTTPException(status_code=400, detail=str(e)) from e
Behavior3/5

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

The disclosure of dummy embeddings by default is a valuable behavioral trait. With no annotations provided, the description partially fills the gap but lacks details on other behaviors, such as whether the tuner is destructive, requires authentication, or has rate limits.

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 a single sentence with no superfluous words. It front-loads the primary action ('Run tuner') and adds a key default behavior concisely.

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

Completeness2/5

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

With 7 parameters, no schema coverage, no output schema, and no annotations, the description is too terse. It fails to cover return format, error conditions, or parameter interactions, leaving agents underinformed for a complex tuning tool.

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

Parameters2/5

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

Schema description coverage is 0%, yet the description does not explain any parameter beyond the schema. For instance, nothing clarifies the role of 'path', 'use_case', or 'strategies'. The description adds no semantic value for parameters.

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 tool runs a tuner and returns ranked recommendations. It mentions dummy embeddings by default, which distinguishes this config-tuning tool from siblings like evaluate_chunking, list_strategies, and preview_chunks.

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 via 'run tuner' and default embeddings, but it does not specify when to use this tool vs alternatives, nor does it provide exclusion criteria or prerequisites.

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/shantanu-deshmukh/chunktuner'

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