Skip to main content

commands.mcp_servers_config

MCP servers config command for the Agent Runtimes CLI.

This module provides the mcp-servers-config command that displays MCP servers configured in the user's ~/.datalayer/mcp.json file. It can be used directly by other libraries or through the CLI.

Usage as library: ```python from agent_runtimes.commands.mcp_servers_config import ( list_mcp_servers_config, get_mcp_servers_config, OutputFormat, )

# Get servers as list of dicts
servers = get_mcp_servers_config()
for server in servers:
print(f"{server['id']}: {server['command']}")

# Print formatted output
list_mcp_servers_config(output=OutputFormat.table)
```

OutputFormat Objects

class OutputFormat(str, Enum)

Output format options.

get_mcp_servers_config

def get_mcp_servers_config() -> dict[str, Any]

Get MCP servers from the user's config file.

Returns:

Dictionary containing:

  • config_path: Path to the config file
  • exists: Whether the config file exists
  • servers: List of server dictionaries with keys:
  • id: Server ID
  • command: Command to start the server
  • args: Arguments for the command
  • env: Environment variables for the server

list_mcp_servers_config

def list_mcp_servers_config(
output: OutputFormat = OutputFormat.table) -> dict[str, Any]

List MCP servers from the user's config file.

This is the core logic of the mcp-servers-config command, usable by other libraries.

Arguments:

  • output - Output format (table or json). Controls how results are printed.

Returns:

Dictionary containing config path and servers.