refactor: replace agent-control MCP with labels system and Paseo MCP

This commit is contained in:
Mohamed Boudra
2026-01-29 11:31:15 +07:00
parent dfda6daeed
commit c015fdbef1
40 changed files with 171 additions and 797 deletions
@@ -1,78 +0,0 @@
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
import { z } from "zod";
async function main() {
// The bearer token is the base64-encoded credentials
const bearerToken = Buffer.from("mo:bo").toString("base64");
const transport = new StdioClientTransport({
command: "codex",
args: ["mcp-server"],
env: {
...process.env,
// Set the bearer token env var
PASEO_AGENT_CONTROL_TOKEN: bearerToken
},
});
const client = new Client(
{ name: "test-client", version: "1.0.0" },
{ capabilities: { elicitation: {} } }
);
// Listen for events
client.setNotificationHandler(
z.object({
method: z.literal("codex/event"),
params: z.object({ msg: z.any() }),
}).passthrough(),
(data) => {
const event = (data.params as { msg: unknown }).msg as { type?: string };
if (event.type === "mcp_startup_update" || event.type === "mcp_startup_complete") {
process.stdout.write("MCP Event: " + JSON.stringify(event, null, 2) + "\n");
}
}
);
await client.connect(transport);
// Use correct route (/mcp/agents) and bearer token env var
process.stdout.write("\n=== Testing HTTP MCP server with correct route and bearer token ===\n\n");
try {
const result = await client.callTool({
name: "codex",
arguments: {
prompt: "List all the MCP tools you have available. Just list them, don't use any.",
sandbox: "danger-full-access",
"approval-policy": "never",
config: {
mcp_servers: {
"agent-control": {
url: "http://localhost:6767/mcp/agents",
bearer_token_env_var: "PASEO_AGENT_CONTROL_TOKEN"
}
}
}
}
}, undefined, { timeout: 60000 });
process.stdout.write("\n=== RESULT ===\n");
const content = (result as { content: { text?: string }[] }).content;
for (const item of content) {
if (item.text) {
process.stdout.write(item.text + "\n");
}
}
} catch (error) {
process.stderr.write("Error: " + String(error) + "\n");
}
await client.close();
}
main().catch((error) => {
process.stderr.write(String(error) + "\n");
process.exitCode = 1;
});
@@ -1,81 +0,0 @@
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
import { z } from "zod";
async function main() {
const transport = new StdioClientTransport({
command: "codex",
args: ["mcp-server"],
env: {
...process.env,
// Try passing credentials via env var that Codex might read
AGENT_CONTROL_AUTH: "mo:bo"
},
});
const client = new Client(
{ name: "test-client", version: "1.0.0" },
{ capabilities: { elicitation: {} } }
);
// Listen for events
client.setNotificationHandler(
z.object({
method: z.literal("codex/event"),
params: z.object({ msg: z.any() }),
}).passthrough(),
(data) => {
const event = (data.params as { msg: unknown }).msg as { type?: string };
if (event.type === "mcp_startup_update" || event.type === "mcp_startup_complete") {
process.stdout.write("MCP Event: " + JSON.stringify(event, null, 2) + "\n");
}
}
);
await client.connect(transport);
// Try passing MCP server config via the config parameter with headers
process.stdout.write("\n=== Testing HTTP MCP server with basic auth in config ===\n\n");
try {
// Create base64 encoded credentials
const credentials = Buffer.from("mo:bo").toString("base64");
const result = await client.callTool({
name: "codex",
arguments: {
prompt: "List all the MCP tools you have available. Just list them, don't use any.",
sandbox: "danger-full-access",
"approval-policy": "never",
config: {
mcp_servers: {
"agent-control": {
url: "http://localhost:6767/mcp/agent-control",
// Try various ways to pass auth
headers: {
"Authorization": `Basic ${credentials}`
}
}
}
}
}
}, undefined, { timeout: 60000 });
process.stdout.write("\n=== RESULT ===\n");
const content = (result as { content: { text?: string }[] }).content;
for (const item of content) {
if (item.text) {
process.stdout.write(item.text + "\n");
}
}
} catch (error) {
process.stderr.write("Error: " + String(error) + "\n");
}
await client.close();
}
main().catch((error) => {
process.stderr.write(String(error) + "\n");
process.exitCode = 1;
});
@@ -1,78 +0,0 @@
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
import { z } from "zod";
async function main() {
// Create base64 encoded credentials
const credentials = Buffer.from("mo:bo").toString("base64");
const transport = new StdioClientTransport({
command: "codex",
args: ["mcp-server"],
env: {
...process.env,
// Set the bearer token env var that we will reference
AGENT_CONTROL_TOKEN: `Basic ${credentials}`
},
});
const client = new Client(
{ name: "test-client", version: "1.0.0" },
{ capabilities: { elicitation: {} } }
);
// Listen for events
client.setNotificationHandler(
z.object({
method: z.literal("codex/event"),
params: z.object({ msg: z.any() }),
}).passthrough(),
(data) => {
const event = (data.params as { msg: unknown }).msg as { type?: string };
if (event.type === "mcp_startup_update" || event.type === "mcp_startup_complete") {
process.stdout.write("MCP Event: " + JSON.stringify(event, null, 2) + "\n");
}
}
);
await client.connect(transport);
// Try passing MCP server config with bearer_token_env_var
process.stdout.write("\n=== Testing HTTP MCP server with bearer_token_env_var ===\n\n");
try {
const result = await client.callTool({
name: "codex",
arguments: {
prompt: "List all the MCP tools you have available. Just list them, don't use any.",
sandbox: "danger-full-access",
"approval-policy": "never",
config: {
mcp_servers: {
"agent-control": {
url: "http://localhost:6767/mcp/agent-control",
bearer_token_env_var: "AGENT_CONTROL_TOKEN"
}
}
}
}
}, undefined, { timeout: 60000 });
process.stdout.write("\n=== RESULT ===\n");
const content = (result as { content: { text?: string }[] }).content;
for (const item of content) {
if (item.text) {
process.stdout.write(item.text + "\n");
}
}
} catch (error) {
process.stderr.write("Error: " + String(error) + "\n");
}
await client.close();
}
main().catch((error) => {
process.stderr.write(String(error) + "\n");
process.exitCode = 1;
});
@@ -1,78 +0,0 @@
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
import { z } from "zod";
async function main() {
// The basic auth header
const basicAuth = `Basic ${Buffer.from("mo:bo").toString("base64")}`;
const transport = new StdioClientTransport({
command: "codex",
args: ["mcp-server"],
env: {
...process.env,
},
});
const client = new Client(
{ name: "test-client", version: "1.0.0" },
{ capabilities: { elicitation: {} } }
);
// Listen for events
client.setNotificationHandler(
z.object({
method: z.literal("codex/event"),
params: z.object({ msg: z.any() }),
}).passthrough(),
(data) => {
const event = (data.params as { msg: unknown }).msg as { type?: string };
if (event.type === "mcp_startup_update" || event.type === "mcp_startup_complete") {
process.stdout.write("MCP Event: " + JSON.stringify(event, null, 2) + "\n");
}
}
);
await client.connect(transport);
// Test using http_headers with Authorization
process.stdout.write("\n=== Testing HTTP MCP server with http_headers and Authorization ===\n\n");
try {
const result = await client.callTool({
name: "codex",
arguments: {
prompt: "List all the MCP tools you have available. Just list them, don't use any.",
sandbox: "danger-full-access",
"approval-policy": "never",
config: {
mcp_servers: {
"agent-control": {
url: "http://localhost:6767/mcp/agents",
http_headers: {
Authorization: basicAuth
}
}
}
}
}
}, undefined, { timeout: 60000 });
process.stdout.write("\n=== RESULT ===\n");
const content = (result as { content: { text?: string }[] }).content;
for (const item of content) {
if (item.text) {
process.stdout.write(item.text + "\n");
}
}
} catch (error) {
process.stderr.write("Error: " + String(error) + "\n");
}
await client.close();
}
main().catch((error) => {
process.stderr.write(String(error) + "\n");
process.exitCode = 1;
});
@@ -1,71 +0,0 @@
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
import { z } from "zod";
async function main() {
const transport = new StdioClientTransport({
command: "codex",
args: ["mcp-server"],
env: { ...process.env },
});
const client = new Client(
{ name: "test-client", version: "1.0.0" },
{ capabilities: { elicitation: {} } }
);
// Listen for events
client.setNotificationHandler(
z.object({
method: z.literal("codex/event"),
params: z.object({ msg: z.any() }),
}).passthrough(),
(data) => {
const event = (data.params as { msg: unknown }).msg as { type?: string };
if (event.type === "mcp_startup_update" || event.type === "mcp_startup_complete") {
process.stdout.write("MCP Event: " + JSON.stringify(event, null, 2) + "\n");
}
}
);
await client.connect(transport);
// Try passing MCP server config via the config parameter with HTTP URL
process.stdout.write("\n=== Testing HTTP MCP server config (agent-control style) ===\n\n");
try {
const result = await client.callTool({
name: "codex",
arguments: {
prompt: "List all the MCP tools you have available. Just list them, don't use any.",
sandbox: "danger-full-access",
"approval-policy": "never",
config: {
mcp_servers: {
"agent-control": {
url: "http://localhost:6767/mcp/agent-control",
type: "http"
}
}
}
}
}, undefined, { timeout: 60000 });
process.stdout.write("\n=== RESULT ===\n");
const content = (result as { content: { text?: string }[] }).content;
for (const item of content) {
if (item.text) {
process.stdout.write(item.text + "\n");
}
}
} catch (error) {
process.stderr.write("Error: " + String(error) + "\n");
}
await client.close();
}
main().catch((error) => {
process.stderr.write(String(error) + "\n");
process.exitCode = 1;
});
@@ -1,27 +0,0 @@
// Quick script to verify buildCodexMcpConfig includes MCP servers
import { buildPaseoDaemonConfigFromEnv } from "../src/server/config.js";
const config = buildPaseoDaemonConfigFromEnv();
process.stdout.write("=== agentControlMcp config ===\n");
process.stdout.write(JSON.stringify(config.agentControlMcp, null, 2) + "\n");
// Simulate what buildCodexMcpConfig does
const mcpServers: Record<string, unknown> = {};
if (config.agentControlMcp) {
const agentControlUrl = config.agentControlMcp.url;
mcpServers["agent-control"] = {
url: agentControlUrl,
...(config.agentControlMcp.headers ? { http_headers: config.agentControlMcp.headers } : {}),
};
}
mcpServers["playwright"] = {
command: "npx",
args: ["@playwright/mcp", "--headless", "--isolated"],
};
process.stdout.write("\n=== Built MCP servers config ===\n");
process.stdout.write(JSON.stringify(mcpServers, null, 2) + "\n");