Skip to main content
Glama

export_config

Export the complete MCP server configuration to JSON format for backup, sharing, or migration purposes.

Instructions

MCP設定全体をJSON形式でエクスポートする。

現在の設定を表示や別の場所へのコピー用に取得します。 Returns: Dict[str, Any]: 設定全体と設定ファイルパスを含む辞書 - config: 現在の設定の完全な内容 - config_path: 設定ファイルのパス

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'export_config' tool. It is decorated with @mcp.tool(name="export_config"), loads the MCP configuration using load_config(), and returns the config as a JSON-serializable dictionary along with the configuration file path.
    @mcp.tool(name="export_config") async def export_config() -> Dict[str, Any]: """MCP設定全体をJSON形式でエクスポートする。 現在の設定を表示や別の場所へのコピー用に取得します。 Returns: Dict[str, Any]: 設定全体と設定ファイルパスを含む辞書 - config: 現在の設定の完全な内容 - config_path: 設定ファイルのパス """ config = load_config() return {"config": config.model_dump(exclude_none=True), "config_path": str(CONFIG_PATH)}
  • Pydantic schema/model for the MCP configuration structure, which defines the output format used by export_config.
    class MCPConfig(BaseModel): """mcp.json設定ファイルの構造を表すモデル。 Attributes: mcpServers: サーバー名をキーとし、ServerConfigを値とする辞書 """ mcpServers: Dict[str, ServerConfig] = Field(default_factory=dict)
  • Pydantic schema/model for individual server configurations within the MCP config.
    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 the MCP configuration from the JSON file into a validated MCPConfig model instance, used by export_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()

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