🛠️ Update various documentation, scripts, and configuration templates to enhance clarity, functionality, and maintainability across the project
This commit is contained in:
63
install/mcp/copilot-cli-filesystem-wrapper.mjs
Normal file
63
install/mcp/copilot-cli-filesystem-wrapper.mjs
Normal file
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { spawn } from "node:child_process";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
function resolveWorkspaceDir() {
|
||||
const workspaceDir = process.env.COPILOT_MCP_FILESYSTEM_ROOT
|
||||
? path.resolve(process.env.COPILOT_MCP_FILESYSTEM_ROOT)
|
||||
: process.cwd();
|
||||
|
||||
if (!fs.existsSync(workspaceDir)) {
|
||||
throw new Error(`Filesystem MCP workspace does not exist: ${workspaceDir}`);
|
||||
}
|
||||
|
||||
if (!fs.statSync(workspaceDir).isDirectory()) {
|
||||
throw new Error(`Filesystem MCP workspace is not a directory: ${workspaceDir}`);
|
||||
}
|
||||
|
||||
return workspaceDir;
|
||||
}
|
||||
|
||||
function main() {
|
||||
const workspaceDir = resolveWorkspaceDir();
|
||||
const dockerArgs = [
|
||||
"run",
|
||||
"-i",
|
||||
"--rm",
|
||||
"--mount",
|
||||
`type=bind,src=${workspaceDir},dst=/projects/workspace`,
|
||||
"mcp/filesystem",
|
||||
"/projects/workspace",
|
||||
];
|
||||
|
||||
const child = spawn("docker", dockerArgs, {
|
||||
stdio: "inherit",
|
||||
windowsHide: true,
|
||||
});
|
||||
|
||||
child.on("error", (error) => {
|
||||
console.error(`Failed to start Docker for the filesystem MCP server: ${error.message}`);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"]) {
|
||||
process.on(signal, () => {
|
||||
if (!child.killed) {
|
||||
child.kill(signal);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
child.on("exit", (code, signal) => {
|
||||
if (signal) {
|
||||
console.error(`Filesystem MCP server exited with signal ${signal}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
process.exit(code ?? 0);
|
||||
});
|
||||
}
|
||||
|
||||
main();
|
||||
Reference in New Issue
Block a user