Skip to main content
Glama

validate_config

Validate MCP server configuration files to check for existence, JSON format correctness, and required server fields, returning detailed results.

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 decorated with @mcp.tool(name="validate_config"). Validates the MCP configuration file by checking existence, JSON parsing, Pydantic model validation, and server command presence. Returns validation status, issues, and details.
    @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 model MCPConfig used by validate_config to parse and validate the entire MCP configuration structure, containing mcpServers dictionary.
    class MCPConfig(BaseModel): """mcp.json設定ファイルの構造を表すモデル。 Attributes: mcpServers: サーバー名をキーとし、ServerConfigを値とする辞書 """ mcpServers: Dict[str, ServerConfig] = Field(default_factory=dict)
  • Pydantic model ServerConfig used within MCPConfig for individual server validation in validate_config, defining command, args, and env.
    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
  • The @mcp.tool decorator registers the validate_config function as an MCP tool.
    @mcp.tool(name="validate_config")

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