Skip to main content
Glama
r3-yamauchi

MCP Configuration Editor

by r3-yamauchi

list_servers

Display all configured MCP servers and their configuration file paths for AWS Q Developer and Claude Desktop.

Instructions

設定されている全てのMCPサーバーをリスト表示する。

Returns:
    Dict[str, Any]: サーバーのリストと設定ファイルのパスを含む辞書
        - servers: 各サーバーの設定情報のリスト
        - config_path: 設定ファイルのパス

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'list_servers' tool. Decorated with @mcp.tool(name="list_servers"), it loads the MCP configuration using load_config() and returns a dictionary containing the list of servers and the config file path.
    @mcp.tool(name="list_servers")
    async def list_servers() -> Dict[str, Any]:
        """設定されている全てのMCPサーバーをリスト表示する。
    
        Returns:
            Dict[str, Any]: サーバーのリストと設定ファイルのパスを含む辞書
                - servers: 各サーバーの設定情報のリスト
                - config_path: 設定ファイルのパス
        """
        config = load_config()
    
        # 各サーバーの情報をリスト化
        servers = []
        for name, server_config in config.mcpServers.items():
            servers.append(
                {"name": name, "command": server_config.command, "args": server_config.args, "env": server_config.env}
            )
    
        return {"servers": servers, "config_path": str(CONFIG_PATH)}
  • Pydantic model defining the structure of the MCP configuration file, used by list_servers to parse and validate the config data.
    class MCPConfig(BaseModel):
        """mcp.json設定ファイルの構造を表すモデル。
    
        Attributes:
            mcpServers: サーバー名をキーとし、ServerConfigを値とする辞書
        """
    
        mcpServers: Dict[str, ServerConfig] = Field(default_factory=dict)
  • Pydantic model for individual server configurations, used within MCPConfig for validation in list_servers.
    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
  • Helper function to load and validate the MCP configuration file, called by list_servers.
    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()

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