Skip to content

Commit f08471f

Browse files
feat: use hack method for coder mcp server
1 parent d368522 commit f08471f

File tree

3 files changed

+37
-14
lines changed

3 files changed

+37
-14
lines changed

registry/coder-labs/modules/copilot-cli/README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,10 @@ This module works with multiple GitHub authentication methods in priority order:
207207
208208
## Task Reporting
209209

210-
When `report_tasks = true` (default), this module automatically configures the **Coder MCP server** for task reporting integration:
210+
When `report_tasks = true` (default), this module automatically configures and starts the **Coder MCP server** for task reporting integration:
211+
212+
- **Automatic Configuration**: The Coder MCP server is added to the MCP configuration automatically
211213

212-
- **Automatic Integration**: The Coder MCP server is added to the MCP configuration automatically
213214
- **Task Status Updates**: Copilot CLI can report task progress to the Coder UI
214215
- **No Manual Setup**: Works out-of-the-box with Coder's task reporting system
215216
- **Custom MCP Compatible**: If you provide custom `mcp_config`, the Coder MCP server is added alongside your custom servers
@@ -222,6 +223,14 @@ The Coder MCP server enables Copilot CLI to:
222223

223224
To disable task reporting, set `report_tasks = false`.
224225

226+
### MCP Server Configuration
227+
228+
This module automatically configures MCP servers by:
229+
230+
1. **Writing MCP Configuration**: Creates `~/.copilot/mcp-config.json` with the correct format
231+
2. **Wrapper Script**: Creates `/tmp/coder-mcp-server.sh` that sets environment variables and runs `coder exp mcp server`
232+
3. **Merging Custom Servers**: Adds any custom MCP servers you provide via the `mcp_config` variable
233+
225234
## Troubleshooting
226235

227236
If you encounter any issues, check the log files in the `~/.copilot-module` directory within your workspace for detailed information.

registry/coder-labs/modules/copilot-cli/main.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,6 @@ describe("copilot-cli module", async () => {
271271
);
272272
expect(statusSlugEnv).toBeDefined();
273273

274-
// System prompt is now handled via .github/copilot-instructions.md file creation
275-
// during install, not via environment variables
276274
});
277275

278276
it("works with full configuration", async () => {

registry/coder-labs/modules/copilot-cli/scripts/install.sh

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,22 +131,38 @@ setup_mcp_config() {
131131
setup_coder_mcp_server() {
132132
local mcp_config_file="$1"
133133

134+
local coder_mcp_wrapper_script
135+
coder_mcp_wrapper_script=$(
136+
cat << EOF
137+
#!/usr/bin/env bash
138+
set -e
139+
140+
# --- Set environment variables ---
141+
export CODER_MCP_APP_STATUS_SLUG="${ARG_MCP_APP_STATUS_SLUG}"
142+
export CODER_MCP_AI_AGENTAPI_URL="http://localhost:3284"
143+
export CODER_AGENT_URL="\${CODER_AGENT_URL}"
144+
export CODER_AGENT_TOKEN="\${CODER_AGENT_TOKEN}"
145+
146+
# --- Launch the MCP server ---
147+
exec coder exp mcp server
148+
EOF
149+
)
150+
echo "$coder_mcp_wrapper_script" > "/tmp/coder-mcp-server.sh"
151+
chmod +x /tmp/coder-mcp-server.sh
152+
134153
local coder_mcp_config
135154
coder_mcp_config=$(
136155
cat << EOF
137156
{
138157
"mcpServers": {
139158
"coder": {
140-
"type": "local",
141-
"command": "coder",
142-
"args": ["exp", "mcp", "server"],
143-
"tools": ["*"],
144-
"env": {
145-
"CODER_MCP_APP_STATUS_SLUG": "${ARG_MCP_APP_STATUS_SLUG}",
146-
"CODER_MCP_AI_AGENTAPI_URL": "http://localhost:3284",
147-
"CODER_AGENT_URL": "${CODER_AGENT_URL}",
148-
"CODER_AGENT_TOKEN": "${CODER_AGENT_TOKEN}"
149-
}
159+
"command": "/tmp/coder-mcp-server.sh",
160+
"args": [],
161+
"description": "Report ALL tasks and statuses (in progress, done, failed) you are working on.",
162+
"name": "Coder",
163+
"timeout": 3000,
164+
"type": "stdio",
165+
"trust": true
150166
}
151167
}
152168
}

0 commit comments

Comments
 (0)