Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 29 additions & 4 deletions packages/cli/src/zed-integration/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,22 +265,47 @@ export const envVariableSchema = z.object({
value: z.string(),
});

export const mcpServerSchema = z.object({
args: z.array(z.string()),
command: z.string(),
env: z.array(envVariableSchema),
export const httpHeaderSchema = z.object({
name: z.string(),
value: z.string(),
});

export const mcpServerSchema = z.union([
z.object({
headers: z.array(httpHeaderSchema),
name: z.string(),
type: z.literal('http'),
url: z.string(),
}),
z.object({
headers: z.array(httpHeaderSchema),
name: z.string(),
type: z.literal('sse'),
url: z.string(),
}),
z.object({
args: z.array(z.string()),
command: z.string(),
env: z.array(envVariableSchema),
name: z.string(),
}),
]);

export const promptCapabilitiesSchema = z.object({
audio: z.boolean().optional(),
embeddedContext: z.boolean().optional(),
image: z.boolean().optional(),
});

export const mcpCapabilitiesSchema = z.object({
http: z.boolean().optional(),
sse: z.boolean().optional(),
});

export const agentCapabilitiesSchema = z.object({
loadSession: z.boolean().optional(),
promptCapabilities: promptCapabilitiesSchema.optional(),
mcpCapabilities: mcpCapabilitiesSchema.optional(),
});

export const authMethodSchema = z.object({
Expand Down
48 changes: 43 additions & 5 deletions packages/cli/src/zed-integration/zedIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ class GeminiAgent {
audio: true,
embeddedContext: true,
},
mcpCapabilities: {
http: true,
sse: true,
},
},
};
}
Expand Down Expand Up @@ -175,12 +179,46 @@ class GeminiAgent {
): Promise<Config> {
const mergedMcpServers = { ...this.settings.merged.mcpServers };

for (const { command, args, env: rawEnv, name } of mcpServers) {
const env: Record<string, string> = {};
for (const { name: envName, value } of rawEnv) {
env[envName] = value;
for (const mcpServer of mcpServers) {
if (!('type' in mcpServer)) {
const env: Record<string, string> = {};
for (const envVar of mcpServer.env) {
env[envVar.name] = envVar.value;
}
mergedMcpServers[mcpServer.name] = new MCPServerConfig(
mcpServer.command,
mcpServer.args,
env,
cwd,
);
} else {
const headers: Record<string, string> = {};
for (const header of mcpServer.headers) {
headers[header.name] = header.value;
}

let sseUrl: string | undefined;
let httpUrl: string | undefined;

if (mcpServer.type === 'sse') {
sseUrl = mcpServer.url;
} else if (mcpServer.type === 'http') {
httpUrl = mcpServer.url;
} else {
const unreachable: never = mcpServer;
throw new Error(`Unexpected MCP server type: ${unreachable}`);
}

mergedMcpServers[mcpServer.name] = new MCPServerConfig(
undefined,
undefined,
undefined,
undefined,
sseUrl,
httpUrl,
headers,
);
}
mergedMcpServers[name] = new MCPServerConfig(command, args, env, cwd);
}

const settings = { ...this.settings.merged, mcpServers: mergedMcpServers };
Expand Down