Skip to main content
Glama
r3-yamauchi

MCP Configuration Editor

by r3-yamauchi

update_server

Update specific fields in existing MCP server configurations, such as command, arguments, or environment variables, for AWS Q Developer and Claude Desktop.

Instructions

既存のMCPサーバー設定を更新する。

指定されたフィールドのみが更新されます。

Args:
    name: 更新するサーバーの名前
    command: 新しいコマンド(オプション)
    args: 新しい引数リスト(オプション)
    env: 追加/更新する環境変数(オプション)
    replace_env: Trueの場合、環境変数を完全に置き換える(デフォルト: False)

Returns:
    Dict[str, Any]: 成功メッセージと更新されたサーバー情報、またはエラー情報

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
commandNo
argsNo
envNo
replace_envNo

Implementation Reference

  • The main handler function for the 'update_server' tool. It loads the current MCP configuration, checks if the server exists, updates the specified fields (command, args, env with merge or replace option), saves the updated configuration with backup, and returns success or error details.
    @mcp.tool(name="update_server")
    async def update_server(
        name: str,
        command: Optional[str] = None,
        args: Optional[list[str]] = None,
        env: Optional[Dict[str, str]] = None,
        replace_env: bool = False,
    ) -> Dict[str, Any]:
        """既存のMCPサーバー設定を更新する。
    
        指定されたフィールドのみが更新されます。
    
        Args:
            name: 更新するサーバーの名前
            command: 新しいコマンド(オプション)
            args: 新しい引数リスト(オプション)
            env: 追加/更新する環境変数(オプション)
            replace_env: Trueの場合、環境変数を完全に置き換える(デフォルト: False)
    
        Returns:
            Dict[str, Any]: 成功メッセージと更新されたサーバー情報、またはエラー情報
        """
        config = load_config()
    
        if name not in config.mcpServers:
            # サーバーが見つからない場合はエラーを返す
            logger.warning(f"Attempted to update non-existent server: {name}")
            return {"error": f"Server '{name}' not found", "available_servers": list(config.mcpServers.keys())}
    
        server = config.mcpServers[name]
    
        # 指定されたフィールドを更新
        if command is not None:
            server.command = command
    
        if args is not None:
            server.args = args
    
        if env is not None:
            if replace_env or server.env is None:
                # 環境変数を完全に置き換える、または初回設定
                server.env = env
            else:
                # 既存の環境変数にマージ
                server.env.update(env)
    
        # 変更を保存
        try:
            save_config(config)
            logger.info(f"Successfully updated server: {name}")
            return {
                "message": f"Server '{name}' updated successfully",
                "server": {"name": name, "command": server.command, "args": server.args, "env": server.env},
            }
        except Exception as e:
            logger.error(f"Failed to save configuration after updating server {name}: {e}")
            return {"error": f"Failed to save configuration: {str(e)}", "hint": "Check file permissions and disk space"}
  • Pydantic schema/model for individual MCP server configuration (command, args, env). Used for validating and structuring the server data that update_server modifies.
    class ServerConfig(BaseModel):
        """MCPサーバーの設定を表すモデル。
    
        Attributes:
            command: 実行するコマンド(例: "python", "uvx", "node")
            args: コマンドライン引数のリスト
            env: 環境変数の辞書(オプション)
        """
    
        command: str
        args: list[str] = Field(default_factory=list)
        env: Optional[Dict[str, str]] = None
  • Pydantic schema/model for the overall MCP configuration file structure, containing a dictionary of server names to ServerConfig instances. Loaded and updated by the update_server handler.
    class MCPConfig(BaseModel):
        """mcp.json設定ファイルの構造を表すモデル。
    
        Attributes:
            mcpServers: サーバー名をキーとし、ServerConfigを値とする辞書
        """
    
        mcpServers: Dict[str, ServerConfig] = Field(default_factory=dict)
  • Helper function called by update_server to persist changes to the configuration file, including optional backup and atomic write.
    def save_config(config: MCPConfig, create_backup_file: bool = True) -> None:
        """MCP設定をディスクに保存する。
    
        必要に応じて親ディレクトリを作成し、設定をJSON形式で保存します。
        Noneの値は除外され、読みやすいように2スペースでインデントされます。
    
        Args:
            config: 保存するMCP設定
            create_backup_file: 保存前にバックアップを作成するかどうか
    
        Raises:
            Exception: 保存に失敗した場合
        """
        try:
            # バックアップを作成
            if create_backup_file and CONFIG_PATH.exists():
                try:
                    create_backup()
                except Exception as e:
                    logger.warning(f"Failed to create backup, continuing with save: {e}")
    
            # 親ディレクトリが存在しない場合は作成
            CONFIG_PATH.parent.mkdir(parents=True, exist_ok=True)
    
            # 一時ファイルに書き込んでからアトミックに置き換え
            temp_path = CONFIG_PATH.with_suffix(".tmp")
            with open(temp_path, "w") as f:
                json.dump(config.model_dump(exclude_none=True), f, indent=2)
                f.write("\n")  # 最後に改行を追加
    
            # アトミックに置き換え
            temp_path.replace(CONFIG_PATH)
            logger.info(f"Configuration saved successfully to {CONFIG_PATH}")
        except Exception as e:
            logger.error(f"Failed to save configuration: {e}")
            raise
  • Helper function used by update_server to load the current configuration from file, with error handling and fallback to empty config.
    def load_config() -> MCPConfig:
        """現在のMCP設定を読み込む。
    
        設定ファイルが存在しない場合や読み込みエラーが発生した場合は、
        空の設定を返します。
    
        Returns:
            MCPConfig: 読み込まれた設定、またはデフォルトの空設定
        """
        if not CONFIG_PATH.exists():
            # 設定ファイルが存在しない場合は空の設定を返す
            logger.info(f"Configuration file not found at {CONFIG_PATH}")
            return MCPConfig()
    
        try:
            with open(CONFIG_PATH, "r") as f:
                data = json.load(f)
            config = MCPConfig(**data)
            logger.debug(f"Loaded configuration with {len(config.mcpServers)} servers")
            return config
        except json.JSONDecodeError as e:
            logger.error(f"Failed to parse JSON configuration: {e}")
            # エラーが発生した場合も空の設定を返す(既存の設定を破壊しない)
            return MCPConfig()
        except ValidationError as e:
            logger.error(f"Configuration validation failed: {e}")
            return MCPConfig()
        except Exception as e:
            logger.error(f"Unexpected error loading configuration: {e}")
            return MCPConfig()
Behavior3/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 adds some context: it specifies that only provided fields are updated (partial updates) and explains the 'replace_env' parameter's effect. However, it lacks details on permissions, side effects, error handling, or rate limits, which are important for a mutation tool. The description doesn't contradict annotations (none exist).

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

Conciseness4/5

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

The description is well-structured and appropriately sized. It starts with the core purpose, adds a key behavioral note (partial updates), then details parameters and return values in labeled sections. Every sentence earns its place, though the return statement could be more concise. It's front-loaded with the main action.

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 the tool's complexity (mutation with 5 parameters), lack of annotations, and no output schema, the description is moderately complete. It covers parameters well and hints at behavior, but misses critical context like error conditions, idempotency, or response structure details. For a mutation tool, this leaves gaps an agent would need to infer.

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?

Schema description coverage is 0%, so the description must compensate fully. It successfully does so by listing all 5 parameters with clear explanations: 'name' identifies the server, 'command' and 'args' are optional new values, 'env' adds/updates environment variables, and 'replace_env' controls full replacement vs. merge. This adds essential meaning beyond the bare schema.

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: '既存のMCPサーバー設定を更新する' (update existing MCP server settings). It specifies the verb (update) and resource (MCP server settings), making the function unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'add_server' or 'remove_server' beyond the 'update' action.

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. It doesn't mention prerequisites (e.g., server must exist), compare to 'add_server' for creation or 'remove_server' for deletion, or specify scenarios where updating is appropriate versus other operations. Usage is implied but not explicitly stated.

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/r3-yamauchi/mcp-conf-mcp-server'

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