feat: move cursor and kiro to use vscode-desktop-core mcp
This commit is contained in:
parent
1fc998cdff
commit
c7890ebae4
@ -81,26 +81,34 @@ describe("cursor", async () => {
|
|||||||
|
|
||||||
it("writes ~/.cursor/mcp.json when var.mcp provided", async () => {
|
it("writes ~/.cursor/mcp.json when var.mcp provided", async () => {
|
||||||
const id = await runContainer("alpine");
|
const id = await runContainer("alpine");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const mcp = JSON.stringify({
|
const mcp = JSON.stringify({
|
||||||
servers: { demo: { url: "http://localhost:1234" } },
|
servers: { demo: { url: "http://localhost:1234" } },
|
||||||
});
|
});
|
||||||
|
|
||||||
const state = await runTerraformApply(import.meta.dir, {
|
const state = await runTerraformApply(import.meta.dir, {
|
||||||
agent_id: "foo",
|
agent_id: "foo",
|
||||||
mcp,
|
mcp,
|
||||||
});
|
});
|
||||||
|
|
||||||
const script = findResourceInstance(
|
const script = findResourceInstance(
|
||||||
state,
|
state,
|
||||||
"coder_script",
|
"coder_script",
|
||||||
"cursor_mcp",
|
"vscode-desktop-mcp", // from "vscode-desktop-core" module
|
||||||
).script;
|
).script;
|
||||||
|
|
||||||
const resp = await execContainer(id, ["sh", "-c", script]);
|
const resp = await execContainer(id, ["sh", "-c", script]);
|
||||||
if (resp.exitCode !== 0) {
|
if (resp.exitCode !== 0) {
|
||||||
console.log(resp.stdout);
|
console.log(resp.stdout);
|
||||||
console.log(resp.stderr);
|
console.log(resp.stderr);
|
||||||
}
|
}
|
||||||
expect(resp.exitCode).toBe(0);
|
expect(resp.exitCode).toBe(0);
|
||||||
const content = await readFileContainer(id, "/root/.cursor/mcp.json");
|
|
||||||
|
const content = await readFileContainer(
|
||||||
|
id,
|
||||||
|
"/root/.cursor/mcp.json",
|
||||||
|
);
|
||||||
expect(content).toBe(mcp);
|
expect(content).toBe(mcp);
|
||||||
} finally {
|
} finally {
|
||||||
await removeContainer(id);
|
await removeContainer(id);
|
||||||
|
|||||||
@ -52,18 +52,13 @@ variable "display_name" {
|
|||||||
|
|
||||||
variable "mcp" {
|
variable "mcp" {
|
||||||
type = string
|
type = string
|
||||||
description = "JSON-encoded string to configure MCP servers for Cursor. When set, writes ~/.cursor/mcp.json."
|
description = "JSON-encoded string to configure MCP servers for Cursor. When set, writes $HOME/.cursor/mcp.json."
|
||||||
default = null
|
default = null
|
||||||
}
|
}
|
||||||
|
|
||||||
data "coder_workspace" "me" {}
|
data "coder_workspace" "me" {}
|
||||||
|
|
||||||
data "coder_workspace_owner" "me" {}
|
data "coder_workspace_owner" "me" {}
|
||||||
|
|
||||||
locals {
|
|
||||||
mcp_b64 = var.mcp != null ? base64encode(var.mcp) : null
|
|
||||||
}
|
|
||||||
|
|
||||||
module "vscode-desktop-core" {
|
module "vscode-desktop-core" {
|
||||||
source = "git::https://github.com/coder/registry.git//registry/coder/modules/vscode-desktop-core?ref=phorcys/vscode-desktop-core-mcp"
|
source = "git::https://github.com/coder/registry.git//registry/coder/modules/vscode-desktop-core?ref=phorcys/vscode-desktop-core-mcp"
|
||||||
|
|
||||||
@ -77,28 +72,12 @@ module "vscode-desktop-core" {
|
|||||||
|
|
||||||
folder = var.folder
|
folder = var.folder
|
||||||
open_recent = var.open_recent
|
open_recent = var.open_recent
|
||||||
# TODO: set mcp_config instead of coder_script
|
mcp_config = var.mcp != null ? jsondecode(var.mcp) : null # turn MCP JSON string into map(any) for vscode-desktop-core module
|
||||||
|
|
||||||
protocol = "cursor"
|
protocol = "cursor"
|
||||||
config_folder = "$HOME/.cursor"
|
config_folder = "$HOME/.cursor"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "coder_script" "cursor_mcp" {
|
|
||||||
count = var.mcp != null ? 1 : 0
|
|
||||||
agent_id = var.agent_id
|
|
||||||
display_name = "Cursor MCP"
|
|
||||||
icon = "/icon/cursor.svg"
|
|
||||||
run_on_start = true
|
|
||||||
start_blocks_login = false
|
|
||||||
script = <<-EOT
|
|
||||||
#!/bin/sh
|
|
||||||
set -eu
|
|
||||||
mkdir -p "$HOME/.cursor"
|
|
||||||
echo -n "${local.mcp_b64}" | base64 -d > "$HOME/.cursor/mcp.json"
|
|
||||||
chmod 600 "$HOME/.cursor/mcp.json"
|
|
||||||
EOT
|
|
||||||
}
|
|
||||||
|
|
||||||
output "cursor_url" {
|
output "cursor_url" {
|
||||||
value = module.vscode-desktop-core.ide_uri
|
value = module.vscode-desktop-core.ide_uri
|
||||||
description = "Cursor IDE Desktop URL."
|
description = "Cursor IDE Desktop URL."
|
||||||
|
|||||||
@ -60,25 +60,30 @@ describe("kiro", async () => {
|
|||||||
|
|
||||||
it("writes ~/.kiro/settings/mcp.json when var.mcp provided", async () => {
|
it("writes ~/.kiro/settings/mcp.json when var.mcp provided", async () => {
|
||||||
const id = await runContainer("alpine");
|
const id = await runContainer("alpine");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const mcp = JSON.stringify({
|
const mcp = JSON.stringify({
|
||||||
servers: { demo: { url: "http://localhost:1234" } },
|
servers: { demo: { url: "http://localhost:1234" } },
|
||||||
});
|
});
|
||||||
|
|
||||||
const state = await runTerraformApply(import.meta.dir, {
|
const state = await runTerraformApply(import.meta.dir, {
|
||||||
agent_id: "foo",
|
agent_id: "foo",
|
||||||
mcp,
|
mcp,
|
||||||
});
|
});
|
||||||
|
|
||||||
const script = findResourceInstance(
|
const script = findResourceInstance(
|
||||||
state,
|
state,
|
||||||
"coder_script",
|
"coder_script",
|
||||||
"kiro_mcp",
|
"vscode-desktop-mcp", // from "vscode-desktop-core" module
|
||||||
).script;
|
).script;
|
||||||
|
|
||||||
const resp = await execContainer(id, ["sh", "-c", script]);
|
const resp = await execContainer(id, ["sh", "-c", script]);
|
||||||
if (resp.exitCode !== 0) {
|
if (resp.exitCode !== 0) {
|
||||||
console.log(resp.stdout);
|
console.log(resp.stdout);
|
||||||
console.log(resp.stderr);
|
console.log(resp.stderr);
|
||||||
}
|
}
|
||||||
expect(resp.exitCode).toBe(0);
|
expect(resp.exitCode).toBe(0);
|
||||||
|
|
||||||
const content = await readFileContainer(
|
const content = await readFileContainer(
|
||||||
id,
|
id,
|
||||||
"/root/.kiro/settings/mcp.json",
|
"/root/.kiro/settings/mcp.json",
|
||||||
|
|||||||
@ -40,17 +40,13 @@ variable "group" {
|
|||||||
|
|
||||||
variable "mcp" {
|
variable "mcp" {
|
||||||
type = string
|
type = string
|
||||||
description = "JSON-encoded string to configure MCP servers for Kiro. When set, writes ~/.kiro/settings/mcp.json."
|
description = "JSON-encoded string to configure MCP servers for Kiro. When set, writes $HOME/.kiro/settings/mcp.json."
|
||||||
default = null
|
default = null
|
||||||
}
|
}
|
||||||
|
|
||||||
data "coder_workspace" "me" {}
|
data "coder_workspace" "me" {}
|
||||||
data "coder_workspace_owner" "me" {}
|
data "coder_workspace_owner" "me" {}
|
||||||
|
|
||||||
locals {
|
|
||||||
mcp_b64 = var.mcp != null ? base64encode(var.mcp) : null
|
|
||||||
}
|
|
||||||
|
|
||||||
module "vscode-desktop-core" {
|
module "vscode-desktop-core" {
|
||||||
source = "git::https://github.com/coder/registry.git//registry/coder/modules/vscode-desktop-core?ref=phorcys/vscode-desktop-core-mcp"
|
source = "git::https://github.com/coder/registry.git//registry/coder/modules/vscode-desktop-core?ref=phorcys/vscode-desktop-core-mcp"
|
||||||
|
|
||||||
@ -64,28 +60,12 @@ module "vscode-desktop-core" {
|
|||||||
|
|
||||||
folder = var.folder
|
folder = var.folder
|
||||||
open_recent = var.open_recent
|
open_recent = var.open_recent
|
||||||
# TODO: set mcp_config instead of coder_script
|
mcp_config = var.mcp != null ? jsondecode(var.mcp) : null # turn MCP JSON string into map(any) for vscode-desktop-core module
|
||||||
|
|
||||||
protocol = "kiro"
|
protocol = "kiro"
|
||||||
config_folder = "$HOME/.kiro"
|
config_folder = "$HOME/.kiro"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "coder_script" "kiro_mcp" {
|
|
||||||
count = var.mcp != null ? 1 : 0
|
|
||||||
agent_id = var.agent_id
|
|
||||||
display_name = "Kiro MCP"
|
|
||||||
icon = "/icon/kiro.svg"
|
|
||||||
run_on_start = true
|
|
||||||
start_blocks_login = false
|
|
||||||
script = <<-EOT
|
|
||||||
#!/bin/sh
|
|
||||||
set -eu
|
|
||||||
mkdir -p "$HOME/.kiro/settings"
|
|
||||||
echo -n "${local.mcp_b64}" | base64 -d > "$HOME/.kiro/settings/mcp.json"
|
|
||||||
chmod 600 "$HOME/.kiro/settings/mcp.json"
|
|
||||||
EOT
|
|
||||||
}
|
|
||||||
|
|
||||||
output "kiro_url" {
|
output "kiro_url" {
|
||||||
value = module.vscode-desktop-core.ide_uri
|
value = module.vscode-desktop-core.ide_uri
|
||||||
description = "Kiro IDE URL."
|
description = "Kiro IDE URL."
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user