Skip to main content
Glama

validate_config

Check MCP configuration files for existence, JSON validity, and required server fields to identify issues before deployment.

Instructions

現在のMCP設定ファイルを検証する。

設定ファイルの存在、JSON形式の妥当性、各サーバー設定の 必須フィールドをチェックします。 Returns: Dict[str, Any]: 検証結果を含む辞書 - valid: 検証が成功したかどうか - servers_count: サーバー数 - servers: サーバー名のリスト - issues: 見つかった問題のリスト(ある場合) - error: エラーメッセージ(ある場合)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'validate_config' tool. It checks if the config file exists, parses JSON, validates using Pydantic MCPConfig model, checks for issues like empty commands, and returns validation results including validity status, server count, list, and any issues or errors.
    @mcp.tool(name="validate_config") async def validate_config() -> Dict[str, Any]: """現在のMCP設定ファイルを検証する。 設定ファイルの存在、JSON形式の妥当性、各サーバー設定の 必須フィールドをチェックします。 Returns: Dict[str, Any]: 検証結果を含む辞書 - valid: 検証が成功したかどうか - servers_count: サーバー数 - servers: サーバー名のリスト - issues: 見つかった問題のリスト(ある場合) - error: エラーメッセージ(ある場合) """ if not CONFIG_PATH.exists(): # 設定ファイルが存在しない場合 return { "valid": False, "error": f"Configuration file not found at {CONFIG_PATH}", "hint": "Use add_server to create initial configuration", } try: # JSONファイルを読み込んでパース with open(CONFIG_PATH, "r") as f: data = json.load(f) # Pydanticモデルで検証 config = MCPConfig(**data) # 各サーバー設定の検証 issues = [] for name, server in config.mcpServers.items(): if not server.command: issues.append(f"Server '{name}' has empty command") return { "valid": len(issues) == 0, "servers_count": len(config.mcpServers), "servers": list(config.mcpServers.keys()), "issues": issues if issues else None, } except json.JSONDecodeError as e: # JSONパースエラー return {"valid": False, "error": f"Invalid JSON: {str(e)}"} except Exception as e: # その他の検証エラー return {"valid": False, "error": f"Validation error: {str(e)}"}
  • Pydantic models (ServerConfig and MCPConfig) that define the schema for MCP server configurations. Used by the validate_config tool for input validation of the configuration file contents.
    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 class MCPConfig(BaseModel): """mcp.json設定ファイルの構造を表すモデル。 Attributes: mcpServers: サーバー名をキーとし、ServerConfigを値とする辞書 """ mcpServers: Dict[str, ServerConfig] = Field(default_factory=dict)

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