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 +88 -152
- package/dist/cli.js +166 -98
- package/dist/compact.js +23 -0
- package/dist/delivery.js +17 -0
- package/dist/errors.js +163 -63
- package/dist/follow-up.js +47 -0
- package/dist/github-hosts.js +61 -0
- package/dist/github.js +39 -59
- package/dist/notify.js +40 -96
- package/dist/selection.js +16 -112
- package/dist/server.js +442 -160
- package/dist/state.js +20 -2
- package/dist/status-local.js +79 -0
- package/dist/swe-models.js +49 -28
- package/dist/task-present.js +78 -0
- package/dist/task-status.js +124 -0
- package/dist/task-urls.js +24 -0
- package/dist/tasks.js +227 -0
- package/dist/time-format.js +3 -0
- package/dist/watch.js +36 -18
- package/dist/webhook-http.js +159 -0
- package/dist/webhooks.js +102 -0
- package/package.json +14 -2
- package/dist/http.js +0 -77
package/dist/http.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { createServer } from "node:http";
|
|
2
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
-
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
4
|
-
import { selectionFromHttp } from "./selection.js";
|
|
5
|
-
import { buildServer } from "./server.js";
|
|
6
|
-
export async function startHttpServer(options) {
|
|
7
|
-
const server = createServer((req, res) => {
|
|
8
|
-
void handle(req, res, options.selection, options.deps);
|
|
9
|
-
});
|
|
10
|
-
await new Promise((resolve, reject) => {
|
|
11
|
-
server.once("error", reject);
|
|
12
|
-
server.listen(options.port, "127.0.0.1", () => {
|
|
13
|
-
server.off("error", reject);
|
|
14
|
-
resolve();
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
const address = server.address();
|
|
18
|
-
if (!address || typeof address === "string")
|
|
19
|
-
throw new Error("Could not open the HTTP port.");
|
|
20
|
-
return {
|
|
21
|
-
url: `http://${address.address}:${address.port}/mcp`,
|
|
22
|
-
host: address.address,
|
|
23
|
-
close: () => new Promise((resolve, reject) => server.close((error) => (error ? reject(error) : resolve()))),
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
async function handle(req, res, base, deps) {
|
|
27
|
-
if (req.method !== "POST" && req.method !== "GET" && req.method !== "DELETE") {
|
|
28
|
-
res.writeHead(405, { "content-type": "text/plain; charset=utf-8" });
|
|
29
|
-
res.end("Method not allowed.");
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
let selection;
|
|
33
|
-
try {
|
|
34
|
-
selection = selectionFromHttp(req.url ?? "/", headersOf(req), base);
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
const message = error instanceof Error ? error.message : "Invalid request.";
|
|
38
|
-
res.writeHead(400, { "content-type": "text/plain; charset=utf-8" });
|
|
39
|
-
res.end(message);
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
let mcp;
|
|
43
|
-
try {
|
|
44
|
-
mcp = buildServer(selection, deps);
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
const message = error instanceof Error ? error.message : "Invalid request.";
|
|
48
|
-
res.writeHead(400, { "content-type": "text/plain; charset=utf-8" });
|
|
49
|
-
res.end(message);
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: undefined });
|
|
53
|
-
res.on("close", () => {
|
|
54
|
-
void transport.close();
|
|
55
|
-
void mcp.close();
|
|
56
|
-
});
|
|
57
|
-
try {
|
|
58
|
-
await mcp.connect(transport);
|
|
59
|
-
await transport.handleRequest(req, res);
|
|
60
|
-
}
|
|
61
|
-
catch {
|
|
62
|
-
if (!res.headersSent) {
|
|
63
|
-
res.writeHead(500, { "content-type": "text/plain; charset=utf-8" });
|
|
64
|
-
res.end("MCP server error.");
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
function headersOf(req) {
|
|
69
|
-
const headers = new Headers();
|
|
70
|
-
for (const [key, value] of Object.entries(req.headers)) {
|
|
71
|
-
if (typeof value === "string")
|
|
72
|
-
headers.set(key, value);
|
|
73
|
-
else if (Array.isArray(value))
|
|
74
|
-
headers.set(key, value.join(", "));
|
|
75
|
-
}
|
|
76
|
-
return headers;
|
|
77
|
-
}
|