Skip to content

Manage Model Context Protocol (MCP) server connections within a workspace — add new servers, connect or disconnect them, and handle OAuth authentication flows.

GET /api/v1/workspaces/{workspaceID}/mcp

NameInTypeRequiredDescription
workspaceIDpathstringYesThe workspace identifier
{
"filesystem": {
"status": "connected"
},
"github": {
"status": "needs_auth"
},
"weather": {
"status": "failed",
"error": "Connection refused"
},
"internal-docs": {
"status": "disabled"
}
}
const status = await client.agent.mcp.getStatus({
workspaceID: "ws_01HXYZ..."
});

POST /api/v1/workspaces/{workspaceID}/mcp

Dynamically register a new MCP server. The config field accepts either a local command-based configuration or a remote URL-based configuration.

NameInTypeRequiredDescription
workspaceIDpathstringYesThe workspace identifier
NameTypeRequiredDescription
namestringYesUnique name for the MCP server
configobjectYesServer configuration. Either a local config (McpLocalConfig) or a remote config (McpRemoteConfig)

Local config (McpLocalConfig)

FieldTypeRequiredDescription
typestringYesMust be "local"
commandarray (string)YesCommand and arguments to run the MCP server
environmentobject (string → string)NoEnvironment variables to set when running the server
enabledbooleanNoEnable or disable the MCP server on startup
timeoutintegerNoTimeout in ms for MCP server requests. Defaults to 5000 (5 seconds) if not specified. Must be greater than 0.

Remote config (McpRemoteConfig)

FieldTypeRequiredDescription
typestringYesMust be "remote"
urlstringYesURL of the remote MCP server
enabledbooleanNoEnable or disable the MCP server on startup
headersobject (string → string)NoHeaders to send with the request
oauthobject | booleanNoOAuth configuration (McpOAuthConfig) or false to disable OAuth auto-detection
timeoutintegerNoTimeout in ms for MCP server requests. Defaults to 5000 (5 seconds) if not specified. Must be greater than 0.

OAuth config (McpOAuthConfig)

FieldTypeRequiredDescription
clientIdstringNoOAuth client ID. If not provided, dynamic client registration (RFC 7591) will be attempted.
clientSecretstringNoOAuth client secret (if required by the authorization server)
scopestringNoOAuth scopes to request during authorization
{
"github": {
"status": "needs_auth"
}
}
// Local (stdio) MCP server
await client.agent.mcp.addServer({
workspaceID: "ws_01HXYZ...",
data: {
name: "filesystem",
config: {
type: "local",
command: ["npx", "-y", "@modelcontextprotocol/server-filesystem", "/data"],
enabled: true,
timeout: 10000
}
}
});
// Remote MCP server
await client.agent.mcp.addServer({
workspaceID: "ws_01HXYZ...",
data: {
name: "github",
config: {
type: "remote",
url: "https://mcp.example.com/github",
enabled: true,
headers: {
"X-Api-Key": "secret-key"
},
oauth: {
scope: "read:user repo"
}
}
}
});

POST /api/v1/workspaces/{workspaceID}/mcp/{name}/auth

Begin the OAuth flow for an MCP server. The returned authorizationUrl should be opened in a browser to grant access.

NameInTypeRequiredDescription
workspaceIDpathstringYesThe workspace identifier
namepathstringYesThe MCP server name
{
"authorizationUrl": "https://auth.example.com/oauth/authorize?response_type=code&client_id=demo&redirect_uri=https%3A%2F%2Fapp.example.com%2Fcallback&scope=read%3Auser&state=abc123"
}
const result = await client.agent.mcp.startOAuth({
workspaceID: "ws_01HXYZ...",
name: "github"
});
// Open result.authorizationUrl in the user's browser

POST /api/v1/workspaces/{workspaceID}/mcp/{name}/auth/authenticate

Start the OAuth flow and wait for the callback to complete (the platform opens the browser and captures the redirect).

NameInTypeRequiredDescription
workspaceIDpathstringYesThe workspace identifier
namepathstringYesThe MCP server name
{
"status": "connected"
}
const status = await client.agent.mcp.authenticateOAuth({
workspaceID: "ws_01HXYZ...",
name: "github"
});

POST /api/v1/workspaces/{workspaceID}/mcp/{name}/auth/callback

Complete OAuth authentication for an MCP server by providing the authorization code received from the OAuth provider’s redirect.

NameInTypeRequiredDescription
workspaceIDpathstringYesThe workspace identifier
namepathstringYesThe MCP server name
NameTypeRequiredDescription
codestringYesAuthorization code from OAuth callback
{
"status": "connected"
}
const status = await client.agent.mcp.completeOAuth({
workspaceID: "ws_01HXYZ...",
name: "github",
data: {
code: "auth_code_from_redirect"
}
});

POST /api/v1/workspaces/{workspaceID}/mcp/{name}/connect

Open a live connection to a previously registered MCP server. Servers that require authentication will return a needs_auth status if the OAuth flow has not been completed.

NameInTypeRequiredDescription
workspaceIDpathstringYesThe workspace identifier
namepathstringYesThe MCP server name
true
const connected = await client.agent.mcp.connect({
workspaceID: "ws_01HXYZ...",
name: "github"
});

POST /api/v1/workspaces/{workspaceID}/mcp/{name}/disconnect

Close an active MCP server connection. The server configuration is preserved and can be reconnected later.

NameInTypeRequiredDescription
namepathstringYesname path parameter
workspaceIDpathstringYesworkspaceID path parameter
true
await client.agent.mcp.disconnect({
workspaceID: "ws_01HXYZ...",
name: "github"
});

DELETE /api/v1/workspaces/{workspaceID}/mcp/{name}/auth

Delete stored OAuth credentials for an MCP server. The server remains registered, but it will need to be re-authenticated before connecting.

NameInTypeRequiredDescription
workspaceIDpathstringYesThe workspace identifier
namepathstringYesThe MCP server name
{
"success": true
}
await client.agent.mcp.removeOAuth({
workspaceID: "ws_01HXYZ...",
name: "github"
});

The MCPStatus type is a tagged union. Every status object includes a status field whose string value identifies the variant:

Status valueAdditional fieldsMeaning
"connected"The server is connected and ready to use
"disabled"The server is registered but disabled
"failed"error (string)The last connection attempt failed
"needs_auth"The server requires OAuth authentication
"needs_client_registration"error (string)Dynamic client registration must be performed first