Module: RubynCode::MCP::Config
- Defined in:
- lib/rubyn_code/mcp/config.rb
Overview
Parses MCP server configuration from .rubyn-code/mcp.json in the project directory.
Expected JSON format:
{
"mcpServers": {
"server-name": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": { "GITHUB_TOKEN": "${GITHUB_TOKEN}" }
}
}
}
Constant Summary collapse
- CONFIG_FILENAME =
'.rubyn-code/mcp.json'- ENV_VAR_PATTERN =
/\$\{([^}]+)\}/
Class Method Summary collapse
-
.load(project_path) ⇒ Array<Hash>
Reads and parses the MCP server configuration for a project.
Class Method Details
.load(project_path) ⇒ Array<Hash>
Reads and parses the MCP server configuration for a project.
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rubyn_code/mcp/config.rb', line 29 def load(project_path) config_path = File.join(project_path, CONFIG_FILENAME) return [] unless File.exist?(config_path) data = JSON.parse(File.read(config_path)) parse_servers(data['mcpServers'] || {}) rescue JSON::ParserError => e warn "[MCP::Config] Failed to parse #{config_path}: #{e.}" [] rescue SystemCallError => e warn "[MCP::Config] Could not read #{config_path}: #{e.}" [] end |