Launch Week 3: Five days of launches

MCP Servers

Overview

The Confident AI SDK exposes every MCP Server method on the platform. This page documents how to call these methods in all supported languages. See the introduction to install the SDK and set your API key.

Methods

List MCP Servers

Lists the MCP servers registered in your Confident AI project one page at a time, ordered by name. Credentials are never included here — neither the static headers nor the OAuth config — so retrieve a server by id to see its configuration.

from confident_ai import ConfidentAI

client = ConfidentAI()

result = client.mcp_servers.list(page=1, page_size=25)

For async mode, call a_list and await it as shown below:

result = await client.mcp_servers.a_list(...)

Parameters

ParameterTypeDescription
pageOptional[int]The page to return. Defaults to 1.
page_sizeOptional[int]The number of results per page, at most 100. Defaults to 25.

Returns

This method returns an object of type McpServerList.

Create MCP Server

Registers one of your MCP servers with the project and returns its id. Registering does not connect — call the connect route to verify the server and discover its tools.

from confident_ai import ConfidentAI
from confident_ai.mcp_servers import McpServerAuthConfig
from confident_ai.mcp_servers import McpServerAuthType
from confident_ai.mcp_servers import McpServerTransport

client = ConfidentAI()

result = client.mcp_servers.create(
    name="Internal Tools",
    transport=McpServerTransport.STDIO,
    description="Internal engineering tools",
    url="https://mcp.internal.example.com/sse",
    headers={"Authorization": "Bearer YOUR-TOKEN"},
    auth_type=McpServerAuthType.HEADERS,
    auth_config=McpServerAuthConfig(
        tenant_id="72f988bf-86f1-41af-91ab-2d7cd011db47",
        client_id="9a1b2c3d-4e5f-6a7b-8c9d-0e1f2a3b4c5d",
        client_secret="abc123~ExampleClientSecretValue",
        scope="api://internal-tools/.default"
    ),
    command="npx",
    args=["-y", "@modelcontextprotocol/server-filesystem"],
)

For async mode, call a_create and await it as shown below:

result = await client.mcp_servers.a_create(...)

Parameters

ParameterTypeDescription
namestrRequired. The name of the MCP server, unique within the project.
transportMcpServerTransportRequired. See McpServerTransport.
descriptionOptional[str]What the MCP server is for. Send null to leave it unset.
urlOptional[str]The URL of the server. Required when transport is HTTP, and cleared otherwise.
headersOptional[Dict[str, str]]Static headers sent with every request. Only used when authType is HEADERS, and cleared otherwise. This map is stored as a whole rather than merged, so send every header you want to keep.
auth_typeOptional[McpServerAuthType]See McpServerAuthType.
auth_configOptional[McpServerAuthConfig]The credentials for a non-HEADERS auth type. Send null to clear them. See McpServerAuthConfig.
commandOptional[str]The command that launches the server. Required when transport is STDIO, and cleared otherwise.
argsOptional[List[str]]The arguments passed to command. STDIO transport only. This list is stored as a whole rather than appended to.

Returns

This method returns an object of type McpServerRef.

Get MCP Server

Retrieves an MCP server by id, with its full configuration and the tools its last successful connection discovered. The stored OAuth client secret is not returned: authConfig.clientSecretPreview masks it instead.

from confident_ai import ConfidentAI

client = ConfidentAI()

result = client.mcp_servers.get(mcp_server_id="<MCP-SERVER-ID>")

For async mode, call a_get and await it as shown below:

result = await client.mcp_servers.a_get(...)

Parameters

ParameterTypeDescription
mcp_server_idstrRequired. The id of the MCP server.

Returns

This method returns an object of type McpServer.

Update MCP Server

Updates an MCP server and returns it. Only the fields you send change, and the merged result must be valid — switching transport needs that transport's required field in the same call. Any successful update resets connected to false, so connect again afterwards.

from confident_ai import ConfidentAI
from confident_ai.mcp_servers import McpServerAuthConfig
from confident_ai.mcp_servers import McpServerAuthType
from confident_ai.mcp_servers import McpServerTransport

client = ConfidentAI()

result = client.mcp_servers.update(
    mcp_server_id="<MCP-SERVER-ID>",
    name="Internal Tools",
    transport=McpServerTransport.STDIO,
    description="Internal engineering tools",
    url="https://mcp.internal.example.com/sse",
    headers={"Authorization": "Bearer YOUR-TOKEN"},
    auth_type=McpServerAuthType.HEADERS,
    auth_config=McpServerAuthConfig(
        tenant_id="72f988bf-86f1-41af-91ab-2d7cd011db47",
        client_id="9a1b2c3d-4e5f-6a7b-8c9d-0e1f2a3b4c5d",
        client_secret="abc123~ExampleClientSecretValue",
        scope="api://internal-tools/.default"
    ),
    command="npx",
    args=["-y", "@modelcontextprotocol/server-filesystem"],
)

For async mode, call a_update and await it as shown below:

result = await client.mcp_servers.a_update(...)

Parameters

ParameterTypeDescription
mcp_server_idstrRequired. The id of the MCP server.
nameOptional[str]The name of the MCP server, unique within the project.
transportOptional[McpServerTransport]See McpServerTransport.
descriptionOptional[str]What the MCP server is for. Send null to leave it unset.
urlOptional[str]The URL of the server. Required when transport is HTTP, and cleared otherwise.
headersOptional[Dict[str, str]]Static headers sent with every request. Only used when authType is HEADERS, and cleared otherwise. This map is stored as a whole rather than merged, so send every header you want to keep.
auth_typeOptional[McpServerAuthType]See McpServerAuthType.
auth_configOptional[McpServerAuthConfig]The credentials for a non-HEADERS auth type. Send null to clear them. See McpServerAuthConfig.
commandOptional[str]The command that launches the server. Required when transport is STDIO, and cleared otherwise.
argsOptional[List[str]]The arguments passed to command. STDIO transport only. This list is stored as a whole rather than appended to.

Returns

This method returns an object of type McpServer.

Delete MCP Server

Permanently deletes an MCP server from your project. This cannot be undone, and evaluations and AI connections that used the server stop using it.

from confident_ai import ConfidentAI

client = ConfidentAI()

result = client.mcp_servers.delete(mcp_server_id="<MCP-SERVER-ID>")

For async mode, call a_delete and await it as shown below:

result = await client.mcp_servers.a_delete(...)

Parameters

ParameterTypeDescription
mcp_server_idstrRequired. The id of the MCP server.

Returns

This method returns an object of type McpServerRef.

Connect MCP Server

Connects to the MCP server, lists the tools it exposes, and replaces its stored connected and availableTools with the result. This reaches out to your own server and can take a few seconds. A server that fails to connect is not an error: the response is still 200 with connected false and error set, so read connected for the verdict.

from confident_ai import ConfidentAI

client = ConfidentAI()

result = client.mcp_servers.connect(mcp_server_id="<MCP-SERVER-ID>")

For async mode, call a_connect and await it as shown below:

result = await client.mcp_servers.a_connect(...)

Parameters

ParameterTypeDescription
mcp_server_idstrRequired. The id of the MCP server.

Returns

This method returns an object of type McpServerConnection.

Types

McpServer

An MCP server registered with your project: how Confident AI reaches it, how it authenticates, and the tools the last connection found. The stored OAuth client secret is never returned — authConfig.clientSecretPreview masks it.

class McpServer:
    id: str
    name: str
    description: Optional[str]
    transport: McpServerTransport
    connected: bool
    url: Optional[str]
    headers: Optional[Dict[str, str]]
    auth_type: McpServerAuthType = Field(alias="authType")
    auth_config: Optional[McpServerMaskedAuthConfig] = Field(alias="authConfig")
    command: Optional[str]
    args: List[str]
    available_tools: Optional[List[McpServerTool]] = Field(alias="availableTools")

idstrRequired

The id of the MCP server, generated by Confident AI.

Example: "<MCP-SERVER-ID>"

namestrRequired

The name of the MCP server.

Example: "Internal Tools"

descriptionOptional[str]Required

What the MCP server is for.

Example: "Internal engineering tools"

transportMcpServerTransportRequired

connectedboolRequired

Whether the last connection attempt succeeded. Set by the connect route, and reset to false by any update.

Example: true

urlOptional[str]Required

The URL of the server. Only set when transport is HTTP.

Example: "https://mcp.internal.example.com/sse"

headersOptional[Dict[str, str]]Required

The static headers sent with every request, returned as stored. Only set when authType is HEADERS.

Example: {"Authorization":"Bearer YOUR-TOKEN"}

auth_typeMcpServerAuthTypeRequired

auth_configOptional[McpServerMaskedAuthConfig]Required

The stored credentials with the OAuth client secret masked, or null when authType is HEADERS.

See McpServerMaskedAuthConfig.

commandOptional[str]Required

The command that launches the server. Only set when transport is STDIO.

Example: "npx"

argsList[str]Required

The arguments passed to command. Empty unless transport is STDIO.

Example: ["-y","@modelcontextprotocol/server-filesystem"]

available_toolsOptional[List[McpServerTool]]Required

The tools discovered by the last successful connection, or null when the server has never connected. An update does not clear them, so treat them as stale whenever connected is false.

See McpServerTool.

McpServerAuthConfig

Credentials for a non-HEADERS auth type. Unlike headers, these fields merge into what is stored, so send only the ones you are changing. Unknown keys are ignored, which is what lets you send back an object you read from the API without stripping its clientSecretPreview first.

class McpServerAuthConfig:
    tenant_id: Optional[str] = Field(default=None, alias="tenantId")
    client_id: Optional[str] = Field(default=None, alias="clientId")
    client_secret: Optional[str] = Field(default=None, alias="clientSecret")
    scope: Optional[str] = None

tenant_idOptional[str]

The Azure AD directory (tenant) id. Required when authType is AZURE_AD.

Example: "72f988bf-86f1-41af-91ab-2d7cd011db47"

client_idOptional[str]

The OAuth client id. Required when authType is AZURE_AD or OAUTH_CLIENT_CREDENTIALS.

Example: "9a1b2c3d-4e5f-6a7b-8c9d-0e1f2a3b4c5d"

client_secretOptional[str]

The OAuth client secret. Write-only: it is never returned, and clientSecretPreview comes back in its place. Omit this field to leave the stored secret exactly as it is, or send a new value to replace it. Changing authType discards the stored secret, so a new one must be sent in the same call.

Example: "abc123~ExampleClientSecretValue"

scopeOptional[str]

The OAuth scope to request. Required when authType is AZURE_AD.

Example: "api://internal-tools/.default"

McpServerAuthType

How Confident AI authenticates to the server. HEADERS sends the static headers map, OAUTH_CLIENT_CREDENTIALS and AZURE_AD fetch a token from authConfig before every call. HTTP transport only; a STDIO server is always HEADERS.

class McpServerAuthType(Enum):
    HEADERS = "HEADERS"
    OAUTH_CLIENT_CREDENTIALS = "OAUTH_CLIENT_CREDENTIALS"
    AZURE_AD = "AZURE_AD"

HEADERS · OAUTH_CLIENT_CREDENTIALS · AZURE_AD

McpServerConnection

The outcome of a connection attempt, which also becomes the server's stored connected and availableTools.

class McpServerConnection:
    connected: bool
    available_tools: List[McpServerTool] = Field(alias="availableTools")
    error: Optional[str]

connectedboolRequired

Whether Confident AI completed a handshake with the server. A failed attempt is reported here rather than as an error status, so read this field for the verdict.

Example: true

available_toolsList[McpServerTool]Required

The tools the server exposes. Empty when the attempt failed.

See McpServerTool.

errorOptional[str]Required

Why the attempt failed, as your server or the network reported it. Null when connected is true.

Example: "MCP connection timed out"

McpServerList

One page of MCP servers, with the total across all pages.

class McpServerList:
    mcp_servers: List[McpServerSummary] = Field(alias="mcpServers")
    total_mcp_servers: int = Field(alias="totalMcpServers")
    page: int
    page_size: int = Field(alias="pageSize")

mcp_serversList[McpServerSummary]Required

The MCP servers for the current page, ordered by name.

See McpServerSummary.

total_mcp_serversintRequired

The total number of MCP servers in this project.

Example: 3

pageintRequired

The page this response covers.

Example: 1

page_sizeintRequired

The number of MCP servers per page.

Example: 25

McpServerMaskedAuthConfig

The stored credentials with the secret removed: clientSecret never leaves Confident AI, and a masked clientSecretPreview stands in for it.

class McpServerMaskedAuthConfig:
    tenant_id: Optional[str] = Field(default=None, alias="tenantId")
    client_id: Optional[str] = Field(default=None, alias="clientId")
    scope: Optional[str] = None
    client_secret_preview: Optional[str] = Field(default=None, alias="clientSecretPreview")

tenant_idOptional[str]

The Azure AD directory (tenant) id, as stored.

Example: "72f988bf-86f1-41af-91ab-2d7cd011db47"

client_idOptional[str]

The OAuth client id, as stored.

Example: "9a1b2c3d-4e5f-6a7b-8c9d-0e1f2a3b4c5d"

scopeOptional[str]

The OAuth scope requested, as stored.

Example: "api://internal-tools/.default"

client_secret_previewOptional[str]

A mask of the stored OAuth client secret — bullets followed by its last six characters — so you can tell which secret is stored without reading it. This is not a credential and sending it back sets nothing: to leave the stored secret alone omit clientSecret from your update, and to change it send the new secret in clientSecret.

Example: "••••••••Xk3mZq"

McpServerRef

A reference to an MCP server by its id.

class McpServerRef:
    id: str

idstrRequired

The id of the MCP server, generated by Confident AI.

Example: "<MCP-SERVER-ID>"

McpServerSummary

An MCP server as it appears in a list: enough to pick one, without its configuration or credentials.

class McpServerSummary:
    id: str
    name: str
    description: Optional[str]
    transport: McpServerTransport
    url: Optional[str]
    connected: bool

idstrRequired

The id of the MCP server, generated by Confident AI.

Example: "<MCP-SERVER-ID>"

namestrRequired

The name of the MCP server.

Example: "Internal Tools"

descriptionOptional[str]Required

What the MCP server is for.

Example: "Internal engineering tools"

transportMcpServerTransportRequired

urlOptional[str]Required

The URL of the server. Only set when transport is HTTP.

Example: "https://mcp.internal.example.com/sse"

connectedboolRequired

Whether the last connection attempt succeeded.

Example: true

McpServerTool

A tool an MCP server exposes, as the last connection saw it.

class McpServerTool:
    name: str
    description: Optional[str]
    input_schema: Dict[str, Any] = Field(alias="inputSchema")
    annotations: Optional[Dict[str, Any]]

namestrRequired

The name of the tool, as the server reports it.

Example: "search_issues"

descriptionOptional[str]Required

What the tool does, or null when the server describes it.

Example: "Search issues in a repository"

input_schemaDict[str, Any]Required

The JSON Schema describing the tool's arguments.

Example: {"type":"object"}

annotationsOptional[Dict[str, Any]]Required

Extra hints the server attaches to the tool, or null when it attaches none.

Example: {"readOnlyHint":true}

McpServerTransport

How Confident AI reaches the server. HTTP requires url and is the only transport that authenticates; STDIO requires command and launches the server as a local process.

class McpServerTransport(Enum):
    STDIO = "STDIO"
    HTTP = "HTTP"

STDIO · HTTP

Building a production pipeline?Design a scalable API workflow for evals, datasets, traces, and promptsTalk to an engineer

Last updated on

Built byConfident AI