@@ -81,115 +81,6 @@ setup_copilot_configurations() {
8181 mkdir -p " $module_path "
8282 mkdir -p " $HOME /.config"
8383
84- if [ -n " $ARG_MCP_CONFIG " ]; then
85- echo " Configuring custom MCP servers..."
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
159- else
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
163- {
164- "mcpServers": {
165- "github": {
166- "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- }
176- }
177- }
178- }
179- 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
191- fi
192-
19384 setup_copilot_config
19485
19586 echo " $ARG_WORKDIR " > " $module_path /trusted_directories"
@@ -199,8 +90,123 @@ setup_copilot_config() {
19990 local config_file=" $HOME /.config/copilot.json"
20091
20192 if [ -n " $ARG_COPILOT_CONFIG " ]; then
202- echo " Setting up Copilot configuration..."
203- echo " $ARG_COPILOT_CONFIG " > " $config_file "
93+ echo " Setting up Copilot configuration with MCP servers..."
94+
95+ if [ -n " $ARG_MCP_CONFIG " ]; then
96+ echo " Merging custom MCP servers into Copilot configuration..."
97+ if command_exists jq; then
98+ local merged_config
99+ merged_config=$( echo " $ARG_COPILOT_CONFIG " | jq --argjson mcp_config " $ARG_MCP_CONFIG " '
100+ . + {
101+ mcpServers: ($mcp_config.mcpServers // {}) |
102+ if .github == null then
103+ .github = {"command": "@github/copilot-mcp-github"}
104+ else . end |
105+ if "' " $ARG_REPORT_TASKS " ' " == "true" then
106+ .coder = {
107+ "command": "coder",
108+ "args": ["exp", "mcp", "server"],
109+ "type": "stdio",
110+ "env": {
111+ "CODER_MCP_APP_STATUS_SLUG": "' " $ARG_MCP_APP_STATUS_SLUG " ' ",
112+ "CODER_MCP_AI_AGENTAPI_URL": "http://localhost:3284"
113+ }
114+ }
115+ else . end
116+ }
117+ ' )
118+ echo " $merged_config " > " $config_file "
119+ elif command_exists node; then
120+ node -e "
121+ const copilotConfig = JSON.parse(\` $ARG_COPILOT_CONFIG \` );
122+ const mcpConfig = JSON.parse(\` $ARG_MCP_CONFIG \` );
123+
124+ copilotConfig.mcpServers = mcpConfig.mcpServers || {};
125+
126+ if (!copilotConfig.mcpServers.github) {
127+ copilotConfig.mcpServers.github = {
128+ command: '@github/copilot-mcp-github'
129+ };
130+ }
131+
132+ if ('$ARG_REPORT_TASKS ' === 'true') {
133+ copilotConfig.mcpServers.coder = {
134+ command: 'coder',
135+ args: ['exp', 'mcp', 'server'],
136+ type: 'stdio',
137+ env: {
138+ CODER_MCP_APP_STATUS_SLUG: '$ARG_MCP_APP_STATUS_SLUG ',
139+ CODER_MCP_AI_AGENTAPI_URL: 'http://localhost:3284'
140+ }
141+ };
142+ }
143+
144+ console.log(JSON.stringify(copilotConfig, null, 2));
145+ " > " $config_file "
146+ else
147+ echo " $ARG_COPILOT_CONFIG " > " $config_file "
148+ fi
149+ else
150+ if [ " $ARG_REPORT_TASKS " = " true" ]; then
151+ echo " Adding default MCP servers with Coder task reporting..."
152+ if command_exists jq; then
153+ echo " $ARG_COPILOT_CONFIG " | jq ' . + {
154+ mcpServers: {
155+ "github": {
156+ "command": "@github/copilot-mcp-github"
157+ },
158+ "coder": {
159+ "command": "coder",
160+ "args": ["exp", "mcp", "server"],
161+ "type": "stdio",
162+ "env": {
163+ "CODER_MCP_APP_STATUS_SLUG": "' " $ARG_MCP_APP_STATUS_SLUG " ' ",
164+ "CODER_MCP_AI_AGENTAPI_URL": "http://localhost:3284"
165+ }
166+ }
167+ }
168+ }' > " $config_file "
169+ elif command_exists node; then
170+ node -e "
171+ const config = JSON.parse(\` $ARG_COPILOT_CONFIG \` );
172+ config.mcpServers = {
173+ github: { command: '@github/copilot-mcp-github' },
174+ coder: {
175+ command: 'coder',
176+ args: ['exp', 'mcp', 'server'],
177+ type: 'stdio',
178+ env: {
179+ CODER_MCP_APP_STATUS_SLUG: '$ARG_MCP_APP_STATUS_SLUG ',
180+ CODER_MCP_AI_AGENTAPI_URL: 'http://localhost:3284'
181+ }
182+ }
183+ };
184+ console.log(JSON.stringify(config, null, 2));
185+ " > " $config_file "
186+ else
187+ echo " $ARG_COPILOT_CONFIG " > " $config_file "
188+ fi
189+ else
190+ echo " Adding default GitHub MCP server..."
191+ if command_exists jq; then
192+ echo " $ARG_COPILOT_CONFIG " | jq ' . + {
193+ mcpServers: {
194+ "github": {
195+ "command": "@github/copilot-mcp-github"
196+ }
197+ }
198+ }' > " $config_file "
199+ elif command_exists node; then
200+ node -e "
201+ const config = JSON.parse(\` $ARG_COPILOT_CONFIG \` );
202+ config.mcpServers = { github: { command: '@github/copilot-mcp-github' } };
203+ console.log(JSON.stringify(config, null, 2));
204+ " > " $config_file "
205+ else
206+ echo " $ARG_COPILOT_CONFIG " > " $config_file "
207+ fi
208+ fi
209+ fi
204210 else
205211 echo " ERROR: No Copilot configuration provided"
206212 exit 1
0 commit comments