McpServerConfig
Base classes
| Name |
Children |
Inherits |
BaseModel pydantic.main !!! abstract "Usage Documentation" |
|
|
⋔ Inheritance diagram
graph TD
107846716994384["config.McpServerConfig"]
107846697802608["main.BaseModel"]
137699722799616["builtins.object"]
107846697802608 --> 107846716994384
137699722799616 --> 107846697802608
🛈 DocStrings
Bases: BaseModel
An MCP server passed to the agent on session setup (stdio or HTTP).
Source code in src/acptui/config.py
| class McpServerConfig(BaseModel):
"""An MCP server passed to the agent on session setup (stdio or HTTP)."""
model_config = ConfigDict(extra="forbid")
name: str
command: str | None = None
"""Program of a stdio server (resolved on ``PATH``; ACP requires an absolute path)."""
args: list[str] = Field(default_factory=list)
env: dict[str, str] = Field(default_factory=dict)
url: str | None = None
"""URL of an HTTP server."""
headers: dict[str, str] = Field(default_factory=dict)
@model_validator(mode="after")
def _check_target(self) -> McpServerConfig:
if bool(self.command) == bool(self.url):
msg = f"MCP server {self.name!r} needs exactly one of `command` and `url`"
raise ValueError(msg)
return self
def to_schema(self) -> McpServerStdio | McpServerHttp:
"""The ACP model (``${VAR}`` is expanded in env and header values)."""
if self.url is not None:
headers = [HttpHeader(name=k, value=expand_env(v)) for k, v in self.headers.items()]
return McpServerHttp(name=self.name, url=self.url, headers=headers)
command = self.command or ""
resolved = shutil.which(command) or str(Path(command).expanduser().resolve())
env = [EnvVariable(name=k, value=expand_env(v)) for k, v in self.env.items()]
return McpServerStdio(name=self.name, command=resolved, args=self.args, env=env)
|
command
class-attribute
instance-attribute
command: str | None = None
Program of a stdio server (resolved on PATH; ACP requires an absolute path).
url
class-attribute
instance-attribute
to_schema
to_schema() -> McpServerStdio | McpServerHttp
The ACP model (${VAR} is expanded in env and header values).
Source code in src/acptui/config.py
| def to_schema(self) -> McpServerStdio | McpServerHttp:
"""The ACP model (``${VAR}`` is expanded in env and header values)."""
if self.url is not None:
headers = [HttpHeader(name=k, value=expand_env(v)) for k, v in self.headers.items()]
return McpServerHttp(name=self.name, url=self.url, headers=headers)
command = self.command or ""
resolved = shutil.which(command) or str(Path(command).expanduser().resolve())
env = [EnvVariable(name=k, value=expand_env(v)) for k, v in self.env.items()]
return McpServerStdio(name=self.name, command=resolved, args=self.args, env=env)
|
:fa-brands-github: Show source on GitHub