API
Copy
import { HTTPClient } from "@director.run/sdk";
import { StdioClient } from "@director.run/sdk";
import { ProxyServer } from "@director.run/sdk";
import { serveOverSSE, serveOverStdio, serveOverStreamable } from "@director.run/sdk";
const proxy = new ProxyServer({
id: "my-proxy",
servers: [
new StdioClient({
name: "stdio-server",
command: "npx",
args: ["-y", "@director.run/cli", "http2stdio", "http://example.com/sse"],
}),
new HTTPClient({
name: "http-server",
// supports SSE & Streamable
url: "http://example.com/mcp",
}),
],
});
// Connect to the servers
await proxy.connectTargets();
// Helper methods to serve the proxy
await serveOverStreamable(proxy, 3673);
await serveOverSSE(proxy, 3674);
await serveOverStdio(proxy);
// Connect over Streamable or SSE
const httpClient = await HTTPClient.createAndConnectToHTTP(
"http://localhost:3673/mcp",
);
// Connect over Stdio
const stdioClient = await StdioClient.createAndConnectToStdio(
"server-command",
["server-args"],
);
// List the tools via HTTP client
console.log(await httpClient.listTools());
// List the tools via Stdio client
console.log(await stdioClient.listTools());