@sk-labs/copilot-kit 3.0.5 → 3.0.6

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.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  const { program } = require('commander');
4
- const { init, update, status } = require('../lib/commands');
4
+ const { init, update, status, mcp } = require('../lib/commands');
5
5
  const pkg = require('../package.json');
6
6
 
7
7
  program
@@ -28,8 +28,18 @@ program
28
28
 
29
29
  program
30
30
  .command('status')
31
- .description('Check installation status')
32
- .option('-p, --path <path>', 'Project directory', '.')
33
- .action(status);
31
+ .description('Check Copilot Kit status')
32
+ .option('-p, --path <path>', 'Path to project root', '.')
33
+ .action((options) => {
34
+ status(options);
35
+ });
36
+
37
+ program
38
+ .command('mcp [action] [target]')
39
+ .description('Manage MCP servers (install, list)')
40
+ .option('-p, --path <path>', 'Path to project root', '.')
41
+ .action((action, target, options) => {
42
+ mcp({ ...options, action, target });
43
+ });
34
44
 
35
- program.parse();
45
+ program.parse(process.argv); // Changed to pass process.argv
package/lib/commands.js CHANGED
@@ -9,6 +9,35 @@ const readline = require('readline');
9
9
  const GITHUB_REPO = 'sk-labs/copilot-kit';
10
10
  const GITHUB_API = 'https://api.github.com';
11
11
 
12
+ const McpManager = require('../mcp-manager');
13
+
14
+ async function mcp(options) {
15
+ const manager = new McpManager(options.path);
16
+ const action = options.action; // 'install' | 'list'
17
+ const target = options.target; // server name
18
+
19
+ console.log(chalk.bold.blue('\nšŸ”Œ Copilot Kit MCP Manager\n'));
20
+
21
+ if (action === 'list') {
22
+ manager.list();
23
+ return;
24
+ }
25
+
26
+ if (action === 'install') {
27
+ if (!target) {
28
+ console.error(chalk.red('āŒ Error: Missing server name. Usage: copilot-kit mcp install <server>'));
29
+ process.exit(1);
30
+ }
31
+ // Separate extra args if passed (basic mechanism, might need commander parsing enhancement later)
32
+ // For now, allow simple install
33
+ const success = manager.install(target);
34
+ if (!success) process.exit(1);
35
+ return;
36
+ }
37
+
38
+ console.log(chalk.yellow('Usage: copilot-kit mcp [install <server> | list]'));
39
+ }
40
+
12
41
  async function init(options) {
13
42
  const targetPath = path.resolve(options.path || '.');
14
43
  const githubPath = path.join(targetPath, '.github');
@@ -396,4 +425,4 @@ function mergeSettings(existing, newSettings) {
396
425
  return merged;
397
426
  }
398
427
 
399
- module.exports = { init, update, status };
428
+ module.exports = { init, update, status, mcp };
package/mcp-manager.js ADDED
@@ -0,0 +1,163 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const { execSync } = require('child_process');
4
+
5
+ // Registry of known/safe MCP servers
6
+ const MCP_Registry = {
7
+ 'postgres': {
8
+ name: 'PostgreSQL MCP',
9
+ package: '@modelcontextprotocol/server-postgres',
10
+ config: {
11
+ command: 'npx',
12
+ args: ['-y', '@modelcontextprotocol/server-postgres', 'postgresql://localhost/mydb']
13
+ }
14
+ },
15
+ 'filesystem': {
16
+ name: 'Filesystem MCP',
17
+ package: '@modelcontextprotocol/server-filesystem',
18
+ config: {
19
+ command: 'npx',
20
+ args: ['-y', '@modelcontextprotocol/server-filesystem', '.']
21
+ }
22
+ },
23
+ 'github': {
24
+ name: 'GitHub MCP',
25
+ package: '@modelcontextprotocol/server-github',
26
+ config: {
27
+ command: 'npx',
28
+ args: ['-y', '@modelcontextprotocol/server-github'],
29
+ env: {
30
+ "GITHUB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>"
31
+ }
32
+ }
33
+ },
34
+ 'sqlite': {
35
+ name: 'SQLite MCP',
36
+ package: '@modelcontextprotocol/server-sqlite',
37
+ config: {
38
+ command: 'npx',
39
+ args: ['-y', '@modelcontextprotocol/server-sqlite', '--file', 'db.sqlite']
40
+ }
41
+ },
42
+ 'playwright': {
43
+ name: 'Playwright MCP',
44
+ package: '@modelcontextprotocol/server-playwright',
45
+ config: {
46
+ command: 'npx',
47
+ args: ['-y', '@modelcontextprotocol/server-playwright']
48
+ }
49
+ }
50
+ };
51
+
52
+ class McpManager {
53
+ constructor(cwd = process.cwd()) {
54
+ this.cwd = cwd;
55
+ this.vscodeDir = path.join(cwd, '.vscode');
56
+ this.settingsFile = path.join(this.vscodeDir, 'settings.json');
57
+ }
58
+
59
+ ensureVscodeDir() {
60
+ if (!fs.existsSync(this.vscodeDir)) {
61
+ fs.mkdirSync(this.vscodeDir, { recursive: true });
62
+ }
63
+ }
64
+
65
+ getSettings() {
66
+ if (fs.existsSync(this.settingsFile)) {
67
+ try {
68
+ // Strip comments if any (simple regex, not perfect but usually sufficient for VS Code JSON)
69
+ const content = fs.readFileSync(this.settingsFile, 'utf8').replace(/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm, '$1');
70
+ return JSON.parse(content);
71
+ } catch (e) {
72
+ console.warn("Warning: Could not parse settings.json. Starting fresh.");
73
+ return {};
74
+ }
75
+ }
76
+ return {};
77
+ }
78
+
79
+ saveSettings(settings) {
80
+ this.ensureVscodeDir();
81
+ fs.writeFileSync(this.settingsFile, JSON.stringify(settings, null, 2));
82
+ console.log(`āœ… Updated .vscode/settings.json`);
83
+ }
84
+
85
+ /**
86
+ * Installs an MCP server.
87
+ * @param {string} serverRef - Either a short name (postgres) or a full package name (@modelcontextprotocol/server-postgres)
88
+ * @param {string[]} extraArgs - Optional extra args for the server
89
+ */
90
+ install(serverRef, extraArgs = []) {
91
+ console.log(`šŸ¤– Agent requesting MCP: ${serverRef}...`);
92
+
93
+ let serverConfig = null;
94
+ let packageName = serverRef;
95
+ let shortName = serverRef;
96
+
97
+ // 1. Check Registry for "Short Names" (Optimization/Convenience)
98
+ if (MCP_Registry[serverRef]) {
99
+ console.log(`✨ Identified known tool: ${MCP_Registry[serverRef].name}`);
100
+ serverConfig = { ...MCP_Registry[serverRef].config }; // clone
101
+ packageName = MCP_Registry[serverRef].package;
102
+ } else {
103
+ // 2. Dynamic Installation (The "Open Mode")
104
+ console.log(`šŸŒ Unknown tool name. Treating as direct NPM package: ${serverRef}`);
105
+
106
+ // Basic Safety Check: Official Scope Preference
107
+ const isOfficial = serverRef.startsWith('@modelcontextprotocol/');
108
+ if (!isOfficial) {
109
+ console.warn(`āš ļø WARNING: You are installing a community package '${serverRef}'. Ensure it is safe.`);
110
+ }
111
+
112
+ // Construct default config for unknown package
113
+ // Assumption: standard MCP servers run as "npx -y <package> studio" or similar,
114
+ // but usually just running the binary via npx is the entry point.
115
+ serverConfig = {
116
+ command: 'npx',
117
+ args: ['-y', serverRef, ...extraArgs]
118
+ };
119
+
120
+ // Generate a clean key name from package (e.g. @modelcontextprotocol/server-postgres -> postgres)
121
+ const parts = serverRef.split('/');
122
+ shortName = parts[parts.length - 1].replace('server-', '');
123
+ }
124
+
125
+ // Merge extra args if provided (and not already merged for dynamic)
126
+ if (MCP_Registry[serverRef] && extraArgs.length > 0) {
127
+ serverConfig.args = [...serverConfig.args, ...extraArgs];
128
+ }
129
+
130
+ console.log(`šŸ“¦ Configuration: ${serverConfig.command} ${serverConfig.args.join(' ')}`);
131
+
132
+ // Update VS Code Settings
133
+ const settings = this.getSettings();
134
+
135
+ // Initialize mcpServers object if missing
136
+ if (!settings['github.copilot.advanced.mcpServers']) {
137
+ settings['github.copilot.advanced.mcpServers'] = {};
138
+ }
139
+
140
+ // Prevent overwriting if exists? Or Update? Agent implies intent, so Update.
141
+ settings['github.copilot.advanced.mcpServers'][shortName] = serverConfig;
142
+
143
+ this.saveSettings(settings);
144
+
145
+ console.log(`āœ… INSTALLED: ${shortName}`);
146
+ console.log(`šŸ’” Copilot can now use this tool.`);
147
+
148
+ return true;
149
+ }
150
+
151
+ list() {
152
+ console.log("\nSuggested MCP Servers (Shortcuts):");
153
+ console.log("==================================");
154
+ for (const [key, val] of Object.entries(MCP_Registry)) {
155
+ console.log(`- ${key}: ${val.name} (${val.package})`);
156
+ }
157
+ console.log("\nšŸ’” You can also install ANY package by name:");
158
+ console.log(" $ copilot-kit mcp install @modelcontextprotocol/server-foobar");
159
+ console.log("\n");
160
+ }
161
+ }
162
+
163
+ module.exports = McpManager;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sk-labs/copilot-kit",
3
- "version": "3.0.5",
3
+ "version": "3.0.6",
4
4
  "description": "CLI tool to install Custom Agents, Skills & Prompt Workflows for GitHub Copilot",
5
5
  "main": "index.js",
6
6
  "bin": {