Skip to main content
Glama

search_astrbot_config_paths

Search AstrBot configuration files to find specific key paths and values, returning structured results without large data payloads for efficient configuration management.

Instructions

Search AstrBot config and return only matched key paths (no big values).

Modes:

  • key only: provide key_query

  • key + value: provide key_query and value_query (matches leaf values of primitive types)

Returns:

  • results: [{path, path_pointer, path_dot, type}, ...]

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
conf_idYes
system_configYes
key_queryYes
value_queryYes
case_sensitiveYes
max_resultsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main asynchronous handler function that implements the core logic of searching for key paths in AstrBot configuration files.
    async def search_astrbot_config_paths(
        *,
        conf_id: str | None = None,
        system_config: bool = False,
        key_query: str,
        value_query: str | None = None,
        case_sensitive: bool = False,
        max_results: int = 50,
    ) -> Dict[str, Any]:
        """
        Search AstrBot config and return only matched key paths (no big values).
    
        Modes:
          - key only: provide key_query
          - key + value: provide key_query and value_query (matches leaf values of primitive types)
    
        Returns:
          - results: [{path, path_pointer, path_dot, type}, ...]
        """
        client = AstrBotClient.from_env()
    
        if system_config and conf_id:
            return {"status": "error", "message": "Do not pass conf_id when system_config=true"}
        if not system_config and not conf_id:
            return {"status": "error", "message": "conf_id is required unless system_config=true"}
        if not isinstance(key_query, str) or not key_query.strip():
            return {"status": "error", "message": "key_query must be a non-empty string"}
        if value_query is not None and (not isinstance(value_query, str) or not value_query.strip()):
            return {"status": "error", "message": "value_query must be a non-empty string or null"}
        if max_results <= 0:
            return {"status": "error", "message": "max_results must be > 0"}
    
        try:
            api_result = await client.get_abconf(conf_id=conf_id, system_config=system_config)
        except Exception as e:
            return {
                "status": "error",
                "message": _astrbot_connect_hint(client),
                "base_url": client.base_url,
                "detail": _httpx_error_detail(e),
            }
    
        status = api_result.get("status")
        if status != "ok":
            return {"status": status, "message": api_result.get("message"), "raw": api_result}
    
        config = (api_result.get("data") or {}).get("config")
        if not isinstance(config, dict):
            return {"status": "error", "message": "AstrBot returned invalid config payload", "raw": api_result}
    
        results: List[Dict[str, Any]] = []
        _walk_find(
            config,
            [],
            key_query=key_query.strip(),
            value_query=value_query.strip() if isinstance(value_query, str) else None,
            case_sensitive=case_sensitive,
            max_results=max_results,
            results=results,
        )
    
        return {
            "conf_id": conf_id,
            "system_config": system_config,
            "key_query": key_query,
            "value_query": value_query,
            "case_sensitive": case_sensitive,
            "max_results": max_results,
            "count": len(results),
            "results": results,
        }
  • Registers the search_astrbot_config_paths tool with the FastMCP server.
    server.tool(astrbot_tools.search_astrbot_config_paths, name="search_astrbot_config_paths")
  • Imports and re-exports the search_astrbot_config_paths function for use in server registration.
    from .config_search_tool import search_astrbot_config_paths
  • Recursive helper function that traverses the JSON config object to find matching keys and optionally values.
    def _walk_find(
        node: Any,
        path: List[JsonPathSegment],
        *,
        key_query: str,
        value_query: str | None,
        case_sensitive: bool,
        max_results: int,
        results: List[Dict[str, Any]],
    ) -> None:
        if len(results) >= max_results:
            return
    
        if isinstance(node, dict):
            for k, v in node.items():
                if len(results) >= max_results:
                    return
                if not isinstance(k, str):
                    continue
    
                key_ok = _match_text(k, key_query, case_sensitive=case_sensitive)
                value_ok = True
                if value_query is not None:
                    text = _value_to_text(v)
                    value_ok = text is not None and _match_text(
                        text, value_query, case_sensitive=case_sensitive
                    )
    
                if key_ok and value_ok:
                    full_path = path + [k]
                    results.append(
                        {
                            "path": full_path,
                            "path_pointer": _to_pointer(full_path),
                            "path_dot": _to_dot(full_path),
                            "type": _type_name(v),
                        }
                    )
    
                _walk_find(
                    v,
                    path + [k],
                    key_query=key_query,
                    value_query=value_query,
                    case_sensitive=case_sensitive,
                    max_results=max_results,
                    results=results,
                )
            return
    
        if isinstance(node, list):
            for i, v in enumerate(node):
                if len(results) >= max_results:
                    return
                _walk_find(
                    v,
                    path + [i],
                    key_query=key_query,
                    value_query=value_query,
                    case_sensitive=case_sensitive,
                    max_results=max_results,
                    results=results,
                )
            return
  • Docstring describing the tool's input parameters, modes, and output format, serving as the schema documentation.
    """
    Search AstrBot config and return only matched key paths (no big values).
    
    Modes:
      - key only: provide key_query
      - key + value: provide key_query and value_query (matches leaf values of primitive types)
    
    Returns:
      - results: [{path, path_pointer, path_dot, type}, ...]
    """
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the tool returns only matched key paths (no big values) and describes return format, which is helpful. However, it doesn't address important behavioral aspects like whether this is a read-only operation, potential performance impacts, rate limits, authentication needs, or error conditions.

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 efficiently structured with clear sections (purpose, modes, returns). Every sentence earns its place, with no redundant information. The front-loaded purpose statement is followed by necessary details in bullet format.

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

Completeness3/5

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

Given 6 parameters with 0% schema coverage and no annotations, the description provides some context but has significant gaps. While it explains the tool's purpose and return format (and an output schema exists), it doesn't adequately cover parameter semantics or behavioral aspects needed for a search tool with multiple configuration options.

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%, so the description must compensate for all 6 undocumented parameters. While it explains the purpose of key_query and value_query in the 'Modes' section, it doesn't address the semantics of conf_id, system_config, case_sensitive, or max_results parameters. This leaves significant gaps in parameter understanding.

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 AstrBot config and returns matched key paths without big values, specifying the verb 'search' and resource 'AstrBot config'. It distinguishes from siblings like 'inspect_astrbot_config' by focusing on searching rather than inspecting, but doesn't explicitly differentiate from all siblings like 'list_astrbot_config_files'.

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 provides implied usage through 'Modes' section, explaining when to use key-only vs. key+value queries. However, it doesn't explicitly state when to use this tool versus alternatives like 'inspect_astrbot_config' or 'list_astrbot_config_files', nor does it mention prerequisites or exclusions.

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/xunxiing/astrbotmcp'

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