Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

programs.mcp.enable

Whether to enable mcp.

Type: boolean

Default:

false

Example:

true

Declared by:

programs.mcp.servers

MCP server configurations written to $XDG_CONFIG_HOME/mcp/mcp.json.

Each server is either a local (stdio) server via command or a remote (HTTP/SSE) server via url.

Besides declared options, arbitrary MCP fields are allowed.

Type: attribute set of (open submodule of (JSON value))

Default:

{ }

Example:

{
  everything = {
    command = "npx";
    args = [ "-y" "@modelcontextprotocol/server-everything" ];
  };
  context7 = {
    url = "https://mcp.context7.com/mcp";
    headers.CONTEXT7_API_KEY = "{env:CONTEXT7_API_KEY}";
  };
  codeberg = {
    command = "/path/to/forgejo-mcp";
    args = [ "transport" "stdio" "--url" "https://codeberg.org" ];
    env.FORGEJO_ACCESS_TOKEN.file = "/run/secrets/codeberg_token";
  };
}

Declared by:

programs.mcp.servers.<name>.enabled

Whether this MCP server is enabled.

If this option and disabled are both set, they must satisfy enabled == !disabled.

Type: null or boolean

Default:

null

Declared by:

programs.mcp.servers.<name>.args

Arguments passed to command. Only valid for local servers.

Type: list of string

Default:

[ ]

Example:

[
  "-y"
  "@modelcontextprotocol/server-everything"
]

Declared by:

programs.mcp.servers.<name>.command

Executable for a local (stdio) MCP server. Mutually exclusive with url.

Type: null or string

Default:

null

Example:

"npx"

Declared by:

programs.mcp.servers.<name>.env

Environment variables set when spawning the MCP server. Each value is either a literal string or a file reference ({ file = "/path"; }).

File references behave differently depending on the consumer:

  • Clients that understand the {file:…} syntax (e.g. opencode) receive the path as a substitution token.
  • Other clients receive a generated wrapper script that reads the secret at startup instead.

Only valid for local servers.

Type: attribute set of (string or (submodule))

Default:

{ }

Example:

{
  API_BASE_URL = "https://api.example.com";
  FORGEJO_ACCESS_TOKEN.file = "/run/secrets/forgejo_token";
}

Declared by:

programs.mcp.servers.<name>.headers

HTTP headers for requests to a remote MCP server. Only valid for remote servers.

Type: attribute set of string

Default:

{ }

Example:

{ MY_API_KEY = "{env:MY_API_KEY}"; }

Declared by:

programs.mcp.servers.<name>.url

HTTP(S) endpoint for a remote (SSE/HTTP) MCP server. Mutually exclusive with command.

Type: null or string

Default:

null

Example:

"https://mcp.context7.com/mcp"

Declared by: