createMcpServer()
This method manages MCP server configuration or actor-level MCP connectivity.
Usage
The following example shows a basic usage of the backend client from @wacht/nextjs/server.
import { wachtClient } from '@wacht/nextjs/server';export async function example() { const client = await wachtClient(); const request: CreateMcpServerRequest = { name: 'Internal MCP', transport: 'sse', endpoint_url: 'https://mcp.example.com', }; return client.ai.createMcpServer(request);}Signature
function createMcpServer( request: CreateMcpServerRequest, client?: WachtClient,): Promise<McpServerCreateResponse>Parameters
›request: CreateMcpServerRequest;
request: CreateMcpServerRequest;Request payload object sent to the backend API.
›name?: string | undefined;
name?: string | undefined;Display name for the target resource.
›transport?: string | undefined;
transport?: string | undefined;transport value used by this request.
›endpoint_url?: string | undefined;
endpoint_url?: string | undefined;endpoint url value used by this request.
Return value
›id?: string | undefined;
id?: string | undefined;MCP server id.
›name?: string | undefined;
name?: string | undefined;MCP server display name.
›transport?: string | undefined;
transport?: string | undefined;MCP transport mode (for example `sse`).
›endpoint_url?: string | undefined;
endpoint_url?: string | undefined;MCP endpoint URL.
Examples
AI usage pattern
import { wachtClient } from '@wacht/nextjs/server';export async function provisionMcp(actorId: string) { const client = await wachtClient(); const server = await client.ai.createMcpServer({ name: 'Internal MCP', transport: 'sse', endpoint_url: 'https://mcp.example.com', }); const connected = await client.ai.connectActorMcpServer(actorId, server.id); return { server, connected };}