copilot-agents-mcp 0.0.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,162 +1,113 @@
1
1
  <p align="center">
2
- <img src="assets/logo.svg" width="128" alt="copilot-agents-mcp">
2
+ <img src="https://raw.githubusercontent.com/daniel-saezv/copilot-agents-mcp/main/assets/logo.svg" width="128" alt="copilot-agents-mcp">
3
3
  </p>
4
4
 
5
5
  # copilot-agents-mcp
6
6
 
7
- `copilot-agents-mcp` is a local Model Context Protocol (MCP) server for launching and managing GitHub Copilot cloud agent tasks.
8
- It runs on your machine over stdio or local HTTP. Version 0.0.1 requires Node.js 26 or later.
7
+ Local [Model Context Protocol](https://modelcontextprotocol.io/) server for launching and managing GitHub Copilot **cloud agent** tasks. It speaks MCP over **stdio only** and runs on your machine (Node.js **26+**).
9
8
 
10
9
  ```mermaid
11
10
  flowchart LR
12
11
  C[MCP client] -->|stdio| M[copilot-agents-mcp]
13
12
  M -->|GitHub App device flow or PAT| A[GitHub authentication]
14
- M -->|GitHub Copilot cloud agent tasks API| G[GitHub]
13
+ M -->|Agent tasks API| G[GitHub]
15
14
  M --> N[Local state and watcher]
16
- N -->|system notification and optional POST| U[Notification receiver]
15
+ N -->|optional POST webhook| W[Your receiver]
17
16
  ```
18
17
 
19
- ## Install
18
+ ## Requirements
20
19
 
21
- The package is not published to npm. Run it directly from this repository:
22
-
23
- ```bash
24
- npx -y github:daniel-saezv/copilot-agents-mcp
25
- ```
26
-
27
- The default server uses stdio. To use local HTTP, run:
28
-
29
- ```bash
30
- npx -y github:daniel-saezv/copilot-agents-mcp --http --port 3333
31
- ```
32
-
33
- The HTTP endpoint is `http://127.0.0.1:3333/mcp`.
20
+ - **Node.js 26** or later (`engines.node` in `package.json`).
21
+ - GitHub credentials: GitHub App **login** (preferred) or `GITHUB_PERSONAL_ACCESS_TOKEN`.
34
22
 
35
23
  ## Authentication
36
24
 
37
- Use one of these credential modes:
38
-
39
- - **Personal access token.** Set `GITHUB_PERSONAL_ACCESS_TOKEN` in the MCP process environment.
40
- - **GitHub App.** Run `npx -y github:daniel-saezv/copilot-agents-mcp login`, complete the device flow, and leave `GITHUB_PERSONAL_ACCESS_TOKEN` unset.
41
-
42
- Check the active credential with:
43
-
44
25
  ```bash
26
+ npx -y github:daniel-saezv/copilot-agents-mcp login
45
27
  npx -y github:daniel-saezv/copilot-agents-mcp auth status
46
28
  ```
47
29
 
48
- See [authentication](docs/authentication.md) and [permissions](docs/permissions.md).
49
-
50
- ## Configure your MCP client
30
+ Complete the device flow in the browser. `auth status` shows the active credential without printing tokens, then **local diagnostics** (no network, never reading notify secret values): state file and lock directory writability (non-writable → exit code 1); webhook env set yes/no only (both unset → info: optional; exactly one set → warning); `DBUS_SESSION_BUS_ADDRESS` yes/no plus an info line on Linux when unset. Optional webhook and notify warnings do not change the exit code. Alternatively set `GITHUB_PERSONAL_ACCESS_TOKEN` in the MCP server process environment (never commit tokens in project config).
51
31
 
52
- Every example below has two variants:
32
+ Optional: `COPILOT_AGENTS_GITHUB_APP_CLIENT_ID`, `COPILOT_AGENTS_GITHUB_API_BASE_URL` (GitHub Enterprise).
53
33
 
54
- - PAT: keep the `env` block and do not run `login`.
55
- - GitHub App: run `login`, then remove the `env` block.
34
+ ## Environment variables
56
35
 
57
- The command is the same in each client. Replace `github_pat_...` with a token that has the required permissions.
36
+ | Variable | Purpose |
37
+ | --- | --- |
38
+ | `GITHUB_PERSONAL_ACCESS_TOKEN` | PAT; takes precedence over keyring session |
39
+ | `COPILOT_AGENTS_NOTIFY_URL` | Webhook URL; watcher POSTs JSON when a task finishes |
40
+ | `COPILOT_AGENTS_NOTIFY_AUTHORIZATION` | Literal `Authorization` header on the notify POST: `Bearer <routine-key>` (not the webhook URL) |
41
+ | `COPILOT_AGENTS_STATE_PATH` | Isolated state file (default `~/.copilot-agents-mcp/state.json`) |
42
+ | `COPILOT_AGENTS_LOG` | Optional watcher log file |
43
+ | `COPILOT_AGENTS_GITHUB_API_BASE_URL` | Enterprise API base |
44
+ | `DBUS_SESSION_BUS_ADDRESS` | On headless Linux, points the OS keyring (`secret-service`) at the session bus (e.g. `unix:path=/tmp/xdg-runtime-box/bus` on a Grok Bot box). If unset and login fails, use `GITHUB_PERSONAL_ACCESS_TOKEN` instead |
58
45
 
59
- ### Visual Studio Code
46
+ Watcher poll interval and task freshness are **fixed internally** (15s poll, 60s freshness).
60
47
 
61
- Create `.vscode/mcp.json`:
48
+ ## Tools
62
49
 
63
- ```json
64
- {
65
- "servers": {
66
- "copilot-agents": {
67
- "type": "stdio",
68
- "command": "npx",
69
- "args": ["-y", "github:daniel-saezv/copilot-agents-mcp"],
70
- "env": {
71
- "GITHUB_PERSONAL_ACCESS_TOKEN": "github_pat_..."
72
- }
73
- }
74
- }
75
- }
76
- ```
50
+ <!-- START AUTOMATED TOOLS -->
51
+ | Tool | Read-only | Description |
52
+ | --- | --- | --- |
53
+ | `create_agent_task` | no | Launch a GitHub Copilot cloud agent with repo, prompt, and model; use list_copilot_models to discover IDs. Returns status, delivery, follow_up, and next_step. May fail for authentication, repository access or policy, invalid input, or an unavailable model; previously rejected models skip the API and list accepted models observed so far. Returns immediately with task_id. Pass owner=<your agent name> unless this server runs a single agent. Follow next_step. |
54
+ | `get_agent_task` | yes | Read one task's result by task_id; optional repo overrides the saved repository and verbose adds details. Returns status, terminal, summary, delivery, and available PR/session links. Cached results may include stale and warnings after a refresh failure. Check authentication or task/repository access on errors. Use list_agent_tasks for scheduled checks, never call this in a loop. |
55
+ | `list_agent_tasks` | yes | Check locally tracked tasks in one scheduled call, filtered by owner, task_ids, status, or repo. Returns compact rows (limit defaults to 20, maximum 50), counts across all matches, all_terminal, next_step, and next_check_after while pending. Stop checks when all_terminal is true. Refresh failures return stale rows and warnings; pending tasks require authentication. Owner is a label, not a security boundary; this is not a GitHub-wide task search. |
56
+ | `steer_agent_task` | no | [Experimental] Undocumented internal GitHub endpoint that can change without notice. Send content to task_id when continuing or redirecting a task with an open pull request. Each call consumes credits and is not idempotent; the agent applies it after its current tool call. Returns task_id, accepted, and the pre-steer session_count, then watches the new turn when notifications are configured. Errors explain missing authentication, repository, or an absent/closed pull request. |
57
+ | `abort_agent_task` | no | [Experimental] Undocumented internal GitHub endpoint that can change without notice. Request cancellation of task_id via the internal steer endpoint; not verified against live GitHub. Use only to stop work, not to read status. Returns accepted, status, and terminal; accepted=false with reason when already finished. Acceptance does not mean cancellation has completed. Check authentication and task access on errors. |
58
+ | `list_copilot_models` | yes | Discover model IDs before create_agent_task. Reads /agents/swe/models and returns source metadata plus models with ID, name, vendor, preview, token prices or billing multiplier, and optional promotion/policy. No parameters. Availability remains subject to repository policy. Errors explain missing authentication, upstream access/network failures, or an invalid upstream response. |
59
+ <!-- END AUTOMATED TOOLS -->
77
60
 
78
- For GitHub App authentication, run `login` once and use this variant:
61
+ After `create_agent_task`, end your turn. The server returns `follow_up` and `next_step`: either wake on a webhook or schedule `list_agent_tasks` (not before `check_after`).
79
62
 
80
- ```json
81
- {
82
- "servers": {
83
- "copilot-agents": {
84
- "type": "stdio",
85
- "command": "npx",
86
- "args": ["-y", "github:daniel-saezv/copilot-agents-mcp"]
87
- }
88
- }
89
- }
90
- ```
63
+ Version **0.2.0** preserves the six tool names, inputs, and JSON text responses from 0.1.0. Every tool now advertises an output schema and returns matching `structuredContent`. See [tool contracts and error codes](docs/tools.md).
91
64
 
92
- ### Claude Desktop
65
+ ## Client setup
93
66
 
94
- Add this server to `claude_desktop_config.json`:
67
+ Run the same stdio command everywhere:
95
68
 
96
69
  ```json
97
70
  {
98
- "mcpServers": {
99
- "copilot-agents": {
100
- "command": "npx",
101
- "args": ["-y", "github:daniel-saezv/copilot-agents-mcp"],
102
- "env": {
103
- "GITHUB_PERSONAL_ACCESS_TOKEN": "github_pat_..."
104
- }
105
- }
106
- }
71
+ "command": "npx",
72
+ "args": ["-y", "github:daniel-saezv/copilot-agents-mcp"]
107
73
  }
108
74
  ```
109
75
 
110
- For GitHub App authentication, run `login` once and use this variant:
76
+ ### (a) Grok Bot
111
77
 
112
- ```json
113
- {
114
- "mcpServers": {
115
- "copilot-agents": {
116
- "command": "npx",
117
- "args": ["-y", "github:daniel-saezv/copilot-agents-mcp"]
118
- }
119
- }
120
- }
121
- ```
78
+ 1. Add a **local stdio MCP server** with the command and args above.
79
+ 2. Optional: set `COPILOT_AGENTS_STATE_PATH` in the server environment so this bot does not share state with other agents.
80
+ 3. On headless Linux, set `DBUS_SESSION_BUS_ADDRESS` (for example `unix:path=/tmp/xdg-runtime-box/bus`) so GitHub App `login` can use the keyring; otherwise set `GITHUB_PERSONAL_ACCESS_TOKEN` in the server env.
81
+ 4. **Webhook routine (recommended):** Create a **Routine** with a **Webhook** trigger in the Grok Bot UI. The **human who owns the routine** configures the MCP server’s masked secret fields; the bot cannot read those values itself. Set `COPILOT_AGENTS_NOTIFY_URL` to the routine’s **webhook URL** from the panel (`https://…`).
82
+ 5. Set `COPILOT_AGENTS_NOTIFY_AUTHORIZATION` to the literal string `Bearer <routine-key>`: the word `Bearer` exactly once, one space, then the routine’s **Authorization key** from the panel. The server sends this value verbatim as the HTTP `Authorization` header. Do **not** paste the webhook URL here—that belongs only in `COPILOT_AGENTS_NOTIFY_URL`.
83
+ 6. When a Copilot task reaches a terminal state, the background watcher POSTs JSON to the routine; the bot can wake and call `get_agent_task` once. Without the webhook, follow the `check_later` text in `next_step`.
122
84
 
123
- ### Claude Code
85
+ ### (b) Claude Code and Claude Desktop
124
86
 
125
- For a PAT, register the local stdio server:
87
+ **Claude Code:**
126
88
 
127
89
  ```bash
128
- claude mcp add --transport stdio copilot-agents \
129
- -e GITHUB_PERSONAL_ACCESS_TOKEN=github_pat_... \
130
- -- npx -y github:daniel-saezv/copilot-agents-mcp
90
+ claude mcp add --transport stdio copilot-agents -- npx -y github:daniel-saezv/copilot-agents-mcp
131
91
  ```
132
92
 
133
- For GitHub App authentication, run the server `login` command first. Then register it without `-e`:
93
+ For a PAT: add `-e GITHUB_PERSONAL_ACCESS_TOKEN=…` (stored in your private `~/.claude.json`).
134
94
 
135
- ```bash
136
- npx -y github:daniel-saezv/copilot-agents-mcp login
137
- claude mcp add --transport stdio copilot-agents \
138
- -- npx -y github:daniel-saezv/copilot-agents-mcp
139
- ```
140
-
141
- ### Cursor
142
-
143
- Create `.cursor/mcp.json`:
95
+ **Claude Desktop:** user-level `claude_desktop_config.json`:
144
96
 
145
97
  ```json
146
98
  {
147
99
  "mcpServers": {
148
100
  "copilot-agents": {
149
101
  "command": "npx",
150
- "args": ["-y", "github:daniel-saezv/copilot-agents-mcp"],
151
- "env": {
152
- "GITHUB_PERSONAL_ACCESS_TOKEN": "github_pat_..."
153
- }
102
+ "args": ["-y", "github:daniel-saezv/copilot-agents-mcp"]
154
103
  }
155
104
  }
156
105
  }
157
106
  ```
158
107
 
159
- For GitHub App authentication, run `login` once and use this variant:
108
+ ### (c) Cursor
109
+
110
+ `~/.cursor/mcp.json` (global) or project `.cursor/mcp.json` (no secrets in committed project files):
160
111
 
161
112
  ```json
162
113
  {
@@ -169,69 +120,55 @@ For GitHub App authentication, run `login` once and use this variant:
169
120
  }
170
121
  ```
171
122
 
172
- ### Grok Bot
123
+ ### (d) Generic `npx` / any MCP client
173
124
 
174
- Configure Grok Bot as a local MCP server over stdio with:
125
+ Point stdio transport at `npx -y github:daniel-saezv/copilot-agents-mcp`. Pass auth and notification env vars in the client’s server environment.
175
126
 
176
- ```json
177
- {
178
- "mcpServers": {
179
- "copilot-agents": {
180
- "command": "npx",
181
- "args": ["-y", "github:daniel-saezv/copilot-agents-mcp"],
182
- "env": {
183
- "GITHUB_PERSONAL_ACCESS_TOKEN": "github_pat_..."
184
- }
185
- }
186
- }
187
- }
127
+ ## Watch tasks
128
+
129
+ ```bash
130
+ npx -y github:daniel-saezv/copilot-agents-mcp watch
188
131
  ```
189
132
 
190
- For GitHub App authentication, run `login` once and use this variant:
133
+ `create_agent_task` also starts a detached watcher when an eligible owner webhook or `COPILOT_AGENTS_NOTIFY_URL` is configured. The watcher polls pending tasks, updates local state under a directory lock, and records completion delivery.
191
134
 
192
- ```json
193
- {
194
- "mcpServers": {
195
- "copilot-agents": {
196
- "command": "npx",
197
- "args": ["-y", "github:daniel-saezv/copilot-agents-mcp"]
198
- }
199
- }
200
- }
135
+ Several agents can share one server; pass a stable `owner` on create and filter with `list_agent_tasks` (labeling convention, not a security boundary).
136
+
137
+ ## Optional per-client webhooks
138
+
139
+ A webhook is the **RECOMMENDED** completion path. Clients that can receive webhooks should register one from the start with `webhook register`. `check_later` is the supported fallback: end the turn, schedule a check at `check_after` if possible, never poll in a loop. Webhook registration is local CLI configuration, not an MCP tool:
140
+
141
+ ```bash
142
+ copilot-agents-mcp webhook register --owner client-1
143
+ copilot-agents-mcp webhook list
144
+ copilot-agents-mcp auth status
145
+ copilot-agents-mcp webhook remove --owner client-1
201
146
  ```
202
147
 
203
- ## Tools
148
+ Registration reads the URL and complete `Authorization` header value through hidden terminal prompts. Alternatively, supply private input files with `--url-file /path/to/url-file --auth-file /path/to/auth-file`. Never put either secret in argv, environment variables for this command, or chat. Keep input files private and remove them when no longer needed.
204
149
 
205
- <!-- START AUTOMATED TOOLS -->
206
- | Tool | Toolset | Read-only | Description |
207
- | --- | --- | --- | --- |
208
- | `create_agent_task` | copilot_tasks | no | Launch a GitHub Copilot cloud agent task. The model is sent unchanged. If the model was already rejected, the tool skips the API call and lists accepted models observed so far. |
209
- | `get_agent_task` | copilot_tasks | yes | Read a GitHub Copilot agent task once. |
210
- | `steer_agent_task` | copilot_tasks | no | [Experimental] Undocumented internal GitHub endpoint that can change without notice. Each steer consumes credits. The agent applies the instruction after its current tool call finishes. Send an instruction to a task with an open pull request. |
211
- | `abort_agent_task` | copilot_tasks | no | [Experimental] Undocumented internal GitHub endpoint that can change without notice. Send {type: "abort"} to the steer endpoint, as VS Code does in tasksClient.ts, to stop the task. This has not been verified against GitHub. |
212
- | `get_agent_task_events` | copilot_tasks | yes | [Experimental] Undocumented internal GitHub endpoint that can change without notice. Read one page of task events (read-only). |
213
- | `list_copilot_models` | copilot_models | yes | Read /agents/swe/models and return the ID, name, vendor, preview flag, token prices or multiplier, and promotion when present. |
214
- <!-- END AUTOMATED TOOLS -->
150
+ Use the same `owner` when calling `create_agent_task`. Owners are exact, case-sensitive routing labels, **not authentication**: any local process with state access can register any owner. All clients and the watcher must share `COPILOT_AGENTS_STATE_PATH` (default `~/.copilot-agents-mcp/state.json`).
215
151
 
216
- See [the tool reference](docs/tools.md) for all input and output fields.
152
+ For an owner without a registration, only the creation response adds: “No webhook: using check_later. Recommended: configure one with `webhook register`.” It never blocks creation or repeats on status checks.
217
153
 
218
- ## Watch tasks
154
+ The registry stores the URL, registration time, and key file path in locked local state; the Authorization value lives separately in a mode `0600` file named `sha256(owner)` beside that state. `webhook list` shows only owner, URL host, key path, and registration time. `auth status` reports owner, host, and key presence/permissions, never the URL path/query or Authorization value.
219
155
 
220
- `create_agent_task` starts a detached watcher. You can also start it directly:
156
+ Only tasks created **after** registration route to that owner. Other tasks retain the existing global `COPILOT_AGENTS_NOTIFY_URL` / `COPILOT_AGENTS_NOTIFY_AUTHORIZATION` fallback. Failed owner delivery does not forward secrets or task data to the global endpoint. Re-registration applies only to subsequent tasks.
221
157
 
222
- ```bash
223
- npx -y github:daniel-saezv/copilot-agents-mcp watch
224
- ```
158
+ Owner endpoints must use public HTTPS. Registration and delivery validate every resolved IP, blocking local/private, CGNAT, link-local, metadata, unspecified, multicast, and broadcast destinations, including IPv4-mapped IPv6. Delivery pins a validated address while retaining the original TLS hostname, preventing DNS rebinding; redirects fail. `COPILOT_AGENTS_NOTIFY_ALLOWED_HOSTS` optionally narrows allowed hostnames (comma-separated); it never permits blocked IPs. Unset means any public HTTPS host.
225
159
 
226
- The watcher polls pending tasks, stores local state, and sends completion notifications. See [notifications](docs/notifications.md).
160
+ Owner and global POST bodies contain only `task_id`, `state`, `repo`, and `pr_url` (nullable), with a stable `Idempotency-Key: <task_id>:<status>` per task and terminal status. Receivers should deduplicate this key and call `get_agent_task` for details. Delivery records remain in local state; inspect `get_agent_task.delivery` and use scheduled checks if delivery fails.
227
161
 
228
- ## Release
162
+ If the receiver uses a private CA, set `NODE_EXTRA_CA_CERTS=/path/to/ca.pem` before starting the server/watcher process that sends webhooks. Setting it only on the receiver does not configure the sender's trust.
229
163
 
230
- Push a tag `vMAJOR.MINOR.PATCH`. The release workflow checks that the tag (without the leading `v`) matches `version` in `package.json`, then runs typecheck, lint, tests, build, and a package smoke test on Node 26 before publishing to npm with `--provenance --access public`.
164
+ ### Example client: Grok Bot routine
231
165
 
232
- The first publish (0.0.1) needs the `NPM_TOKEN` repository secret: [Trusted Publishing](https://docs.npmjs.com/trusted-publishers/) requires the package to already exist on npm. The workflow tries OIDC first and falls back to `NPM_TOKEN` when that fails. After 0.0.1 is on npm, add this repo and workflow as a trusted publisher on [npmjs.com](https://www.npmjs.com/), then remove the `NPM_TOKEN` secret so later releases use OIDC only.
166
+ 1. Each bot creates its own webhook-trigger routine.
167
+ 2. The owner copies that routine's URL and complete Authorization value into the hidden prompts of `copilot-agents-mcp webhook register --owner <botName>`. Never paste either into chat.
168
+ 3. Have that bot launch a tiny task with `owner: "<botName>"`, such as a one-line documentation correction.
169
+ 4. Verify end-to-end that its routine receives the terminal notice and calls `get_agent_task` once for the result. Confirm another bot's routine is not triggered. No release or merge is needed.
233
170
 
234
- ## Test and build
171
+ ## Develop
235
172
 
236
173
  ```bash
237
174
  bash scripts/setup
@@ -239,11 +176,10 @@ npm test
239
176
  npm run typecheck
240
177
  npm run lint
241
178
  npm run build
242
- node scripts/pack-smoke.mjs
243
179
  ```
244
180
 
245
- Agent development instructions remain in [AGENTS.md](AGENTS.md).
181
+ See [AGENTS.md](AGENTS.md) for agent maintenance notes.
246
182
 
247
183
  ## License
248
184
 
249
- [MIT](LICENSE)
185
+ [MIT](LICENSE)