Skip to main content
Glama

set_default_server

Change the default server to a specified server for routing requests to the scientific agent network.

Instructions

切换默认服务器

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
serverYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Actual implementation of the set_default_server tool. It validates the server alias exists in config, updates the 'default_server' field, and persists via save_config(). Decorated with @mcp.tool() inside register_tools().
    @mcp.tool()
    def set_default_server(server: str) -> str:
        """切换默认服务器"""
        alias = server.strip()
        if not alias:
            return "❌ 缺少必填参数: server"
    
        config = load_config()
        if alias not in config.get("servers", {}):
            available = ", ".join(config.get("servers", {}).keys()) or "无"
            return f'❌ 服务器别名 "{alias}" 不存在。可用服务器: {available}'
    
        config["default_server"] = alias
        save_config(config)
        return f"✅ 默认服务器已切换为: {alias}"
  • register_tools function which contains the @mcp.tool() decorator that registers set_default_server as an MCP tool.
    def register_tools(mcp: FastMCP) -> None:
        """注册所有 OpenAaaS MCP Tools"""
  • load_config() - reads configuration from ~/.openaaas-mcp-adapter/config.json, handles migration from legacy format, and returns the config dict that set_default_server modifies.
    def load_config() -> dict[str, Any]:
        """加载配置文件,若不存在或格式错误则返回默认配置"""
        config_path = get_config_path()
        if not config_path.exists():
            return _deep_copy(DEFAULT_CONFIG)
    
        try:
            with open(config_path, "r", encoding="utf-8") as f:
                raw = f.read()
        except OSError as e:
            raise RuntimeError(f"无法读取配置文件: {e}")
    
        try:
            parsed = json.loads(raw)
        except json.JSONDecodeError:
            raise RuntimeError("配置文件 JSON 格式错误,请检查 ~/.openaaas-mcp-adapter/config.json")
    
        if not isinstance(parsed, dict):
            raise RuntimeError("配置文件格式错误:期望 JSON 对象")
    
        # 兼容旧格式(单服务器)
        if "servers" not in parsed and "server_url" in parsed:
            parsed = {
                "servers": {
                    "default": {
                        "server_url": parsed.get("server_url", "https://api.open-aaas.com"),
                        "api_key": parsed.get("api_key", ""),
                        "client_id": parsed.get("client_id", ""),
                        "name": parsed.get("name", ""),
                    }
                },
                "default_server": parsed.get("default_server", "default"),
            }
            save_config(parsed)
    
        if "servers" not in parsed:
            parsed["servers"] = _deep_copy(DEFAULT_CONFIG["servers"])
        if "default_server" not in parsed:
            parsed["default_server"] = "default"
    
        return parsed
  • save_config() - atomically writes the updated config dict to disk, used by set_default_server to persist the new default_server value.
    def save_config(config: dict[str, Any]) -> None:
        """原子写入配置文件"""
        config_path = get_config_path()
        config_path.parent.mkdir(parents=True, exist_ok=True)
        tmp_path = config_path.with_suffix(f".tmp.{os.getpid()}")
    
        try:
            with open(tmp_path, "w", encoding="utf-8") as f:
                json.dump(config, f, ensure_ascii=False, indent=2)
                f.flush()
                os.fsync(f.fileno())
            tmp_path.replace(config_path)
        except OSError as e:
            try:
                tmp_path.unlink(missing_ok=True)
            except OSError:
                pass
            raise RuntimeError(f"无法保存配置文件: {e}")
  • DEFAULT_CONFIG defines the expected config shape including 'servers' dict and 'default_server' key that set_default_server modifies.
    DEFAULT_CONFIG: dict[str, Any] = {
        "servers": {
            "default": {
                "server_url": "https://api.open-aaas.com",
                "api_key": "",
                "client_id": "",
                "name": "",
            }
        },
        "default_server": "default",
    }
Behavior2/5

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

No annotations provided; description does not disclose behavioral details such as whether the change is persistent, immediate, or requires specific permissions. The mutation nature is implied but not elaborated.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence with no extraneous text, but it lacks necessary detail, making it under-informative for an agent. Conciseness should not come at the cost of clarity.

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?

Given the tool's simplicity (1 parameter, output schema present), the description still fails to explain the outcome, side effects, or relationship to sibling tools like list_servers. It is incomplete for effective use.

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

Parameters1/5

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

Schema description coverage is 0%, and the description does not explain what the 'server' parameter expects (e.g., name, URL, ID). No enums or constraints are provided, leaving the agent without guidance on valid values.

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 action (switch) and the target resource (default server), distinguishing it from sibling tools like set_server_url which sets URL, and list_servers which lists servers.

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?

No guidance on when to use this tool versus alternatives like set_server_url or remove_server. No context about prerequisites or when not to use it.

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/Wolido/OpenAaaS'

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