Skip to main content
MCP (Model Context Protocol) servers extend agents with tools and external context.

Configuring MCP servers

The HTTP config endpoints let you store/retrieve MCP server configs by directory + name.
// Create MCP config
await sdk.setMcpConfig(
  {
    directory: "/workspace",
    mcpName: "github",
  },
  {
    type: "remote",
    url: "https://example.com/mcp",
  },
);

// Create a session using the configured MCP servers
const session = await sdk.createSession({
  agent: "claude",
  sessionInit: {
    cwd: "/workspace",
  },
});

await session.prompt([
  { type: "text", text: "Use available MCP servers to help with this task." },
]);

// List MCP configs
const config = await sdk.getMcpConfig({
  directory: "/workspace",
  mcpName: "github",
});

console.log(config.type);

// Delete MCP config
await sdk.deleteMcpConfig({
  directory: "/workspace",
  mcpName: "github",
});

Config fields

Local server

FieldDescription
typelocal
commandexecutable path
argsarray of CLI args
envenvironment variable map
cwdworking directory
enabledenable/disable server
timeoutMstimeout override

Remote server

FieldDescription
typeremote
urlMCP server URL
transporthttp or sse
headersstatic headers map
bearerTokenEnvVarenv var name to inject in auth header
envHeadersheader name to env var map
oauthoptional OAuth config object
enabledenable/disable server
timeoutMstimeout override

Custom MCP servers

To bundle and upload your own MCP server into the sandbox, see Custom Tools.