Skip to content

Commit a62146f

Browse files
feat: enhance task reporting integration and support for GitHub token in Copilot CLI
1 parent 3737c1a commit a62146f

File tree

4 files changed

+155
-5
lines changed

4 files changed

+155
-5
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,23 @@ This module works with multiple GitHub authentication methods in priority order:
177177

178178
> **Note**: OAuth tokens work best with Copilot CLI. Personal Access Tokens may have limited functionality.
179179
180+
## Task Reporting
181+
182+
When `report_tasks = true` (default), this module automatically configures the **Coder MCP server** for task reporting integration:
183+
184+
- **Automatic Integration**: The Coder MCP server is added to the MCP configuration automatically
185+
- **Task Status Updates**: Copilot CLI can report task progress to the Coder UI
186+
- **No Manual Setup**: Works out-of-the-box with Coder's task reporting system
187+
- **Custom MCP Compatible**: If you provide custom `mcp_config`, the Coder MCP server is added alongside your custom servers
188+
189+
The Coder MCP server enables Copilot CLI to:
190+
191+
- Report task status (working, complete, failure)
192+
- Send progress updates to the Coder dashboard
193+
- Integrate with Coder's AI task workflow system
194+
195+
To disable task reporting, set `report_tasks = false`.
196+
180197
## Troubleshooting
181198

182199
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: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,4 +287,29 @@ describe("copilot-cli module", async () => {
287287
expect(statusSlugEnv.name).toBe("CODER_MCP_APP_STATUS_SLUG");
288288
expect(statusSlugEnv.value).toBe("copilot-cli");
289289
});
290+
291+
it("supports github_token variable", async () => {
292+
const tokenVars = {
293+
...requiredVars,
294+
github_token: "test_github_token_123",
295+
};
296+
297+
const state = await runTerraformApply(moduleDir, tokenVars);
298+
299+
const statusSlugEnv = findResourceInstance(
300+
state,
301+
"coder_env",
302+
"mcp_app_status_slug",
303+
);
304+
expect(statusSlugEnv).toBeDefined();
305+
306+
const githubTokenEnv = findResourceInstance(
307+
state,
308+
"coder_env",
309+
"github_token",
310+
);
311+
expect(githubTokenEnv).toBeDefined();
312+
expect(githubTokenEnv.name).toBe("GITHUB_TOKEN");
313+
expect(githubTokenEnv.value).toBe("test_github_token_123");
314+
});
290315
});

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

Lines changed: 96 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,111 @@ setup_copilot_configurations() {
8383

8484
if [ -n "$ARG_MCP_CONFIG" ]; then
8585
echo "Configuring custom MCP servers..."
86-
echo "$ARG_MCP_CONFIG" > "$module_path/mcp_config.json"
86+
if command_exists jq; then
87+
echo "$ARG_MCP_CONFIG" | jq '
88+
.mcpServers = (.mcpServers // {}) |
89+
if .mcpServers.github == null then
90+
.mcpServers.github = {"command": "@github/copilot-mcp-github"}
91+
else . end |
92+
if "'"$ARG_REPORT_TASKS"'" == "true" then
93+
.mcpServers.coder = {
94+
"command": "coder",
95+
"args": ["exp", "mcp", "server"],
96+
"type": "stdio",
97+
"env": {
98+
"CODER_MCP_APP_STATUS_SLUG": "'"$ARG_MCP_APP_STATUS_SLUG"'",
99+
"CODER_MCP_AI_AGENTAPI_URL": "http://localhost:3284"
100+
}
101+
}
102+
else . end
103+
' > "$module_path/mcp_config.json"
104+
elif command_exists node; then
105+
node -e "
106+
const config = JSON.parse(\`$ARG_MCP_CONFIG\`);
107+
config.mcpServers = config.mcpServers || {};
108+
109+
if (!config.mcpServers.github) {
110+
config.mcpServers.github = {
111+
command: '@github/copilot-mcp-github'
112+
};
113+
}
114+
115+
if ('$ARG_REPORT_TASKS' === 'true') {
116+
config.mcpServers.coder = {
117+
command: 'coder',
118+
args: ['exp', 'mcp', 'server'],
119+
type: 'stdio',
120+
env: {
121+
CODER_MCP_APP_STATUS_SLUG: '$ARG_MCP_APP_STATUS_SLUG',
122+
CODER_MCP_AI_AGENTAPI_URL: 'http://localhost:3284'
123+
}
124+
};
125+
}
126+
127+
console.log(JSON.stringify(config, null, 2));
128+
" > "$module_path/mcp_config.json"
129+
else
130+
if [ "$ARG_REPORT_TASKS" = "true" ]; then
131+
echo "$ARG_MCP_CONFIG" | sed 's/}$//' > "$module_path/mcp_config.json"
132+
cat >> "$module_path/mcp_config.json" << EOF
133+
"github": {
134+
"command": "@github/copilot-mcp-github"
135+
},
136+
"coder": {
137+
"command": "coder",
138+
"args": ["exp", "mcp", "server"],
139+
"type": "stdio",
140+
"env": {
141+
"CODER_MCP_APP_STATUS_SLUG": "$ARG_MCP_APP_STATUS_SLUG",
142+
"CODER_MCP_AI_AGENTAPI_URL": "http://localhost:3284"
143+
}
144+
}
145+
}
146+
}
147+
EOF
148+
else
149+
echo "$ARG_MCP_CONFIG" | sed 's/}$//' > "$module_path/mcp_config.json"
150+
cat >> "$module_path/mcp_config.json" << EOF
151+
"github": {
152+
"command": "@github/copilot-mcp-github"
153+
}
154+
}
155+
}
156+
EOF
157+
fi
158+
fi
87159
else
88-
cat > "$module_path/mcp_config.json" << 'EOF'
160+
if [ "$ARG_REPORT_TASKS" = "true" ]; then
161+
echo "Configuring default MCP servers with Coder task reporting..."
162+
cat > "$module_path/mcp_config.json" << EOF
89163
{
90164
"mcpServers": {
91165
"github": {
92166
"command": "@github/copilot-mcp-github"
167+
},
168+
"coder": {
169+
"command": "coder",
170+
"args": ["exp", "mcp", "server"],
171+
"type": "stdio",
172+
"env": {
173+
"CODER_MCP_APP_STATUS_SLUG": "$ARG_MCP_APP_STATUS_SLUG",
174+
"CODER_MCP_AI_AGENTAPI_URL": "http://localhost:3284"
175+
}
93176
}
94177
}
95178
}
96179
EOF
180+
else
181+
cat > "$module_path/mcp_config.json" << 'EOF'
182+
{
183+
"mcpServers": {
184+
"github": {
185+
"command": "@github/copilot-mcp-github"
186+
}
187+
}
188+
}
189+
EOF
190+
fi
97191
fi
98192

99193
setup_copilot_config

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,26 @@ start_agentapi() {
123123

124124
build_copilot_args
125125

126+
local mcp_args=()
127+
local module_path="$HOME/.copilot-module"
128+
129+
if [ -f "$module_path/mcp_config.json" ]; then
130+
mcp_args+=(--mcp-config "$module_path/mcp_config.json")
131+
fi
132+
126133
if [ ${#COPILOT_ARGS[@]} -gt 0 ]; then
127134
echo "Copilot arguments: ${COPILOT_ARGS[*]}"
128-
agentapi server --type claude --term-width 120 --term-height 40 -- copilot "${COPILOT_ARGS[@]}"
135+
if [ ${#mcp_args[@]} -gt 0 ]; then
136+
agentapi server --type claude --term-width 120 --term-height 40 "${mcp_args[@]}" -- copilot "${COPILOT_ARGS[@]}"
137+
else
138+
agentapi server --type claude --term-width 120 --term-height 40 -- copilot "${COPILOT_ARGS[@]}"
139+
fi
129140
else
130-
echo "Starting Copilot CLI in interactive mode"
131-
agentapi server --type claude --term-width 120 --term-height 40 -- copilot
141+
if [ ${#mcp_args[@]} -gt 0 ]; then
142+
agentapi server --type claude --term-width 120 --term-height 40 "${mcp_args[@]}" -- copilot
143+
else
144+
agentapi server --type claude --term-width 120 --term-height 40 -- copilot
145+
fi
132146
fi
133147
}
134148

0 commit comments

Comments
 (0)