Skip to content

Add Copilot setup workflow for automated environment provisioning#70

Merged
TheRealSeber merged 5 commits intomasterfrom
copilot/automate-copilot-setup
Dec 3, 2025
Merged

Add Copilot setup workflow for automated environment provisioning#70
TheRealSeber merged 5 commits intomasterfrom
copilot/automate-copilot-setup

Conversation

Copy link
Contributor

Copilot AI commented Dec 3, 2025

Adds a reusable GitHub Actions workflow to pre-provision the Copilot environment with pnpm, dependencies, and a validated build. Also includes Swagger MCP server setup for backend API integration.

Changes

  • New workflow: .github/workflows/copilot-setup-steps.yml
    • Triggers on workflow_dispatch and changes to the workflow file itself
    • Installs pnpm@10.15.1 (matching packageManager in package.json)
    • Node.js 22 with built-in pnpm caching via actions/setup-node (aligned with Dockerfile)
    • Frozen lockfile install for reproducibility
    • Pre-flight checks: prepare, check, lint (graceful failures to avoid blocking on non-critical issues)
    • Production build with preview server validation using retry logic and proper process cleanup
    • Build artifact caching for faster subsequent runs
    • Clones, installs, and builds Swagger-MCP server from Vizioz/Swagger-MCP to /tmp/swagger-mcp (pinned to commit 41c28344 for reproducibility)

MCP Server Configuration

The workflow pre-builds the Swagger MCP server to /tmp/swagger-mcp. To enable it for the Copilot coding agent:

  1. Go to SettingsCopilotCoding agentMCP servers
  2. Add this JSON configuration:
{
  "mcpServers": {
    "swagger": {
      "type": "stdio",
      "command": "node",
      "args": ["/tmp/swagger-mcp/build/index.js"],
      "env": {
        "SWAGGER_URL": "https://mini-maxit.github.io/backend/master/swagger.yaml"
      }
    }
  }
}
  1. Under Networking, add mini-maxit.github.io to allowed hosts

Key decisions

  • pnpm installed before setup-node since the cache option requires pnpm to exist
  • Preview validation uses 10 retries × 2s instead of hardcoded sleep for reliability
  • Preview server explicitly terminated with trap and kill for proper cleanup
  • || true on check/lint intentional—ensures Copilot can start even with minor issues
  • Swagger-MCP pinned to specific commit SHA for security and reproducibility

Fixes #69

Original prompt

This section details on the original issue you should resolve

<issue_title>Automate Copilot Environment Setup: pre-install pnpm, install deps, cache, and pre-build frontend</issue_title>
<issue_description>## Overview
Create a reusable GitHub Copilot pre-setup workflow for the mini-maxit/frontend repo to provision its environment before the agent starts work. This will speed up build, test, and automated operation cycles by ensuring all necessary tools and dependencies are prepared upfront.

Why?

  • The repo requires pnpm (see package.json, do NOT use npm/yarn).
  • The frontend (Svelte 5 + SvelteKit) requires Node.js ≥ 18 and is typically built using modern Vite.
  • Full install/build cycles are time-consuming. Pre-installation, caching, and pre-building improve reliability and performance for Copilot operations.

Instructions: Add .github/workflows/copilot-setup-steps.yml

Example workflow for mini-maxit/frontend:

name: "Copilot Setup Steps"

on:
  workflow_dispatch:
  push:
    paths:
      - .github/workflows/copilot-setup-steps.yml
  pull_request:
    paths:
      - .github/workflows/copilot-setup-steps.yml

jobs:
  copilot-setup-steps:
    runs-on: ubuntu-latest
    permissions:
      contents: read
    steps:
      - name: Checkout code
        uses: actions/checkout@v5

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: 'pnpm'

      - name: Install pnpm (pinned version)
        run: |
          npm install -g pnpm@10.15.1
          pnpm -v

      - name: Restore pnpm cache
        uses: actions/cache@v3
        with:
          path: ~/.pnpm-store
          key: pnpm-store-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}

      - name: Install dependencies
        run: pnpm install --frozen-lockfile --reporter=ndjson

      - name: Prepare project (sync, typecheck, lint)
        run: |
          pnpm run prepare
          pnpm run check || true
          pnpm run lint || true

      - name: Build production frontend
        run: pnpm run build

      - name: Preview production build
        run: pnpm run preview & sleep 5; curl --fail http://localhost:4173/ || echo 'Preview failed'

      - name: Save build artifacts (optional)
        uses: actions/cache@v3
        with:
          path: dist
          key: build-dist-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}

Benefits of This Workflow

  • Fast Copilot startup: pnpm cache and pre-built frontend prevent wasted cycles.
  • Reproducibility: Exact Node and pnpm version pinned for consistency.
  • Validator checks: Pre-flight typecheck/lint ensure Copilot starts in a valid state.
  • Artifacts & build preview: The build is validated before Copilot runs.
  • Safe caching: Both pnpm-store and dist/ output can be cached for improved speed.

Additional Recommendations

  • Place secrets/API keys in the repo's "copilot" environment as needed.
  • If you need more RAM/CPU, update the runs-on: to a larger runner after configuring it for your repo.
  • If the repo uses Git LFS, add lfs: true in the actions/checkout step.

By following these instructions, you'll ensure every Copilot session starts with a fast, reproducible frontend environment, and is ready for build, test, and automation tasks without manual setup.
</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: TheRealSeber <111927572+TheRealSeber@users.noreply.github.com>
Copilot AI changed the title [WIP] Add workflow for automating Copilot environment setup Add Copilot setup workflow for automated environment provisioning Dec 3, 2025
Copilot AI requested a review from TheRealSeber December 3, 2025 17:37
@TheRealSeber
Copy link
Contributor

@copilot hey copilot I would like to also introduce on the environment an swagger mcp server. here are github repo docs: Skip to content Navigation Menu Vizioz Swagger-MCP Code Issues 4 Pull requests 2 Actions Projects Security Insights Owner avatar Swagger-MCP Public Vizioz/Swagger-MCP t Name Last commit message Last commit date readingdancer readingdancer Updated some libraries and adding some more TODO items. 41c2834 · May 6, 2025 .github Create FUNDING.yml Apr 28, 2025 src Small changes to this PR May 4, 2025 tests Refactored test scripts and documentation Mar 12, 2025 .env.example Initial commit Mar 8, 2025 .gitignore Remove temporary files and update gitignore Mar 9, 2025 LICENSE Create LICENSE Apr 8, 2025 PROMPTS.md Refactored test scripts and documentation Mar 12, 2025 README.md Update README.md Apr 8, 2025 TODO.md Updated some libraries and adding some more TODO items. May 6, 2025 fix-imports.js Initial commit Mar 8, 2025 package-lock.json Updated some libraries and adding some more TODO items. May 6, 2025 package.json Updated some libraries and adding some more TODO items. May 6, 2025 petstore.json Add AI-specific instructions to tool descriptions and improve MCP too… Mar 9, 2025 tsconfig.json Initial commit Mar 8, 2025 Repository files navigation README MIT license Swagger MCP An MCP server that connects to a Swagger specification and helps an AI to build all the required models to generate a MCP server for that service. Features Downloads a Swagger specification and stores it locally for faster reference. Returns a list of all the endpoints and their HTTP Methods and descriptions Returns a list of all the models Returns a model Returns service to connect to the end point Returns MCP function definitions Generates complete MCP tool definitions with full schema information Includes AI-specific instructions in tool descriptions Prerequisites Node.js (v14 or higher) npm or yarn Installation Clone the repository: git clone https://github.com/readingdancer/swagger-mcp.git cd swagger-mcp Install dependencies: npm install Create a .env file based on the .env.example file: cp .env.example .env Update the .env file. Configuration Edit the .env file to configure the application: PORT: The port on which the server will run (default: 3000) NODE_ENV: The environment (development, production, test) LOG_LEVEL: Logging level (info, error, debug) Usage Building the application Build the application: npm run build This will compile the TypeScript code ready to be used as an MCP Server Running as an MCP Server To run as an MCP server for integration with Cursor and other applications: node build/index.js Using the MCP Inspector To run the MCP inspector for debugging: npm run inspector Adding to Cursor To add this MCP server to Cursor: Open Cursor Settings > Features > MCP Click "+ Add New MCP Server" Enter a name for the server (e.g., "Swagger MCP") Select "stdio" as the transport type Enter the command to run the server: node path/to/swagger-mcp/build/index.js and then if needed, add the command line arguments as mentioned above. Click "Add" The Swagger MCP tools will now be available to the Cursor Agent in Composer. Available Swagger MCP Tools The following tools are available through the MCP server: getSwaggerDefinition: Downloads a Swagger definition from a URL listEndpoints: Lists all endpoints from the Swagger definition listEndpointModels: Lists all models used by a specific endpoint generateModelCode: Generates TypeScript code for a model generateEndpointToolCode: Generates TypeScript code for an MCP tool definition Available Swagger MCP Prompts The server also provides MCP prompts that guide AI assistants through common workflows: add-endpoint: A step-by-step guide for adding a new endpoint using the Swagger MCP tools To use a prompt, clients can make a prompts/get request with the prompt name and optional arguments: { "method": "prompts/get", "params": { "name": "add-endpoint", "arguments": { "swaggerUrl": "https://petstore.swagger.io/v2/swagger.json", "endpointPath": "/pets/{id}", "httpMethod": "GET" } } } The prompt will return a series of messages that guide the AI assistant through the exact process required to add a new endpoint. Setting Up Your New Project First ask the agent to get the Swagger file, make sure you give it the URL for the swagger file, or at least a way to find it for you, this will download the file and save it locally with a hashed filename, this filename will automatically be added to a .swagger-mcp settings file in the root of your current solution. Auto generated .swagger-mcp config file SWAGGER_FILENAME = TheFilenameOfTheLocallyStoredSwaggerFile This simple configuration file associates your current project with a specific Swagger API, we may use it to store more details in the future. Once configured, the MCP will be able to find your Swagger definition and associate it with your current solution, reducing the number of API calls needed to get the project and tasks related to the solution you are working on. Improved MCP Tool Code Generator The MCP tool code generator has been enhanced to provide more complete and usable tool definitions: Key Improvements Complete Schema Information: The generator now includes full schema information for all models, including nested objects, directly in the inputSchema. Better Parameter Naming: Parameter names are now more semantic and avoid problematic characters like dots (e.g., taskRequest instead of task.Request). Semantic Tool Names: Tool names are now more descriptive and follow consistent naming conventions based on the HTTP method and resource path. Support for YAML Swagger Files: The generator now supports both JSON and YAML Swagger definition files. Improved Documentation: Generated tool definitions include comprehensive descriptions for all parameters and properties. No External Dependencies: The generated code doesn't require importing external model files, making it more self-contained and easier to use. AI-Specific Instructions: Tool descriptions now include special instructions for AI agents, helping them understand how to use the tools effectively. Example Usage To generate an MCP tool definition for an endpoint: import generateEndpointToolCode from './services/generateEndpointToolCode.js'; const toolCode = await generateEndpointToolCode({ path: '/pets', method: 'POST', swaggerFilePath: './petstore.json', singularizeResourceNames: true }); console.log(toolCode); This will generate a complete MCP tool definition with full schema information for the POST /pets endpoint. License This project is licensed under the MIT License - see the LICENSE file for details. MCP Prompts for AI Assistants To help AI assistants use the Swagger MCP tools effectively, we've created a collection of prompts that guide them through common tasks. These prompts provide step-by-step instructions for processes like adding new endpoints, using generated models, and more. Check out the PROMPTS.md file for the full collection of prompts. Example use case: When asking an AI assistant to add a new endpoint to your project, you can reference the "Adding a New Endpoint" prompt to ensure the assistant follows the correct process in the right order. About MCP wrapper for Swagger/OpenAPI definitions Resources Readme License MIT license Activity Custom properties Stars 106 stars Watchers 1 watching Forks 17 forks Report repository Releases No releases published Sponsor this project buy_me_a_coffee buymeacoffee.com/vizioz Packages No packages published Contributors 2 @readingdancer readingdancer Chris Houston @Maryam593 Maryam593 Maryam Saba Languages TypeScript 97.8% JavaScript 2.2% Footer © 2025 GitHub, Inc. Footer navigation Terms Privacy Security Status Community Docs Contact later this mcp i want to attach to the agent in the repository settings. adjust the setup environmnt so that it points to the https://mini-maxit.github.io/backend/master/swagger.yaml. also do i have to adjust some firewall too? give me how tos et it up later in the repo the mcp so that it goes through io? current setting:
{
"mcpServers": {
"svelte": {
"type": "http",
"url": "https://mcp.svelte.dev/mcp",
"tools": ["*"]
}
}
}

Co-authored-by: TheRealSeber <111927572+TheRealSeber@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 3, 2025

@copilot hey copilot I would like to also introduce on the environment an swagger mcp server. here are github repo docs: Skip to content Navigation Menu Vizioz Swagger-MCP Code Issues 4 Pull requests ...

Added Swagger MCP server setup in commit 1050a33. Changes include:

  1. Workflow update: Added step to clone, install, and build Swagger-MCP from Vizioz/Swagger-MCP to /tmp/swagger-mcp

  2. MCP configuration: Created .github/copilot/mcp.json with both Svelte and Swagger servers:

{
  "mcpServers": {
    "svelte": {
      "type": "http",
      "url": "https://mcp.svelte.dev/mcp",
      "tools": ["*"]
    },
    "swagger": {
      "type": "stdio",
      "command": "node",
      "args": ["/tmp/swagger-mcp/build/index.js"],
      "env": {
        "SWAGGER_URL": "https://mini-maxit.github.io/backend/master/swagger.yaml"
      }
    }
  }
}

Firewall setup: Since mini-maxit.github.io is a GitHub Pages site, you need to add it to the allowed network list:

  1. Go to repo SettingsCopilotPoliciesNetworking
  2. Add mini-maxit.github.io to the allowed hosts

The MCP config file (.github/copilot/mcp.json) is automatically picked up by GitHub Copilot in the repository.

@TheRealSeber
Copy link
Contributor

@copilot are you sure? these are the docs: Skip to main content
GitHub Docs
Home
GitHub Copilot

[GitHub Copilot](https://docs.github.com/en/copilot)/[How-tos](https://docs.github.com/en/copilot/how-tos)/[Use Copilot agents](https://docs.github.com/en/copilot/how-tos/use-copilot-agents)/[Coding agent](https://docs.github.com/en/copilot/how-tos/use-copilot-agents/coding-agent)/

Extending GitHub Copilot coding agent with the Model Context Protocol (MCP)

Learn how to use the Model Context Protocol (MCP) to extend the capabilities of Copilot coding agent.
In this article

Prerequisite

Before setting up an MCP server for Copilot coding agent, read Model Context Protocol (MCP) and GitHub Copilot coding agent to make sure you understand the concepts around MCP servers and Copilot coding agent.
Introduction

As a repository administrator, you can configure MCP servers for use within your repository. You do this using a JSON-formatted configuration that specifies the details of the MCP servers you want to use. You enter the JSON configuration directly into the settings for the repository on GitHub.com.

Organization and enterprise administrators can also configure MCP servers as part of custom agents using the YAML frontmatter. For more information, see Custom agents configuration.

Warning

Once you've configured an MCP server, Copilot will be able to use the tools provided by the server autonomously, and will not ask for your approval before using them.

Note

Copilot coding agent only supports tools provided by MCP servers. It does not support resources or prompts.
Copilot coding agent does not currently support remote MCP servers that leverage OAuth for authentication and authorization.

Adding an MCP configuration to your repository

Repository administrators can configure MCP servers by following these steps:

On GitHub, navigate to the main page of the repository.

Under your repository name, click 

Settings. If you cannot see the "Settings" tab, select the

dropdown menu, then click Settings.

Screenshot of a repository header showing the tabs. The "Settings" tab is highlighted by a dark orange outline.

In the "Code & automation" section of the sidebar, click Copilot then Coding agent.

Add your configuration in the MCP configuration section.

The following sections in this article explain how to write the JSON configuration that you need to enter here.

Click Save.

Your configuration will be validated to ensure proper syntax.

If your MCP server requires a key or secret, add a secret to your Copilot environment. Only secrets with names prefixed with COPILOT_MCP_ will be available to your MCP configuration. See [Setting up a Copilot environment for Copilot coding agent](https://docs.github.com/en/copilot/how-tos/use-copilot-agents/coding-agent/extend-coding-agent-with-mcp#setting-up-a-copilot-environment-for-copilot-coding-agent).

Writing a JSON configuration for MCP servers

You configure MCP servers using a special JSON format. The JSON must contain an mcpServers object, where the key is the name of the MCP server (for example, sentry), and the value is an object with the configuration for that MCP server.
JSON

{
"mcpServers": {
"MCP SERVER 1": {
"command": "VALUE",
"args": [ VALUES ],
...
},
"MCP SERVER 2": {
"command": "VALUE",
"args": [ VALUES ],
...
},
...
}
}

The configuration object can contain the following keys:

Required keys for local and remote MCP servers

tools (string[]): The tools from the MCP server to enable. You may be able to find a list of tools in the server's documentation, or in its code. We strongly recommend that you allowlist specific read-only tools, since the agent will be able to use these tools autonomously and will not ask you for approval first. You can also enable all tools by including * in the array.
type (string): Copilot coding agent accepts "local", "http", or "sse".

Local MCP specific keys

command (string): Required. The command to run to start the MCP server.
args (string[]): Required. The arguments to pass to the command.
env (object): Optional. The environment variables to pass to the server. This object should map the name of the environment variable that should be exposed to your MCP server to either of the following:
    The name of a GitHub Actions secret you have configured, beginning with COPILOT_MCP_.
    A string value.

Remote MCP specific keys

url (string): Required. The MCP server's URL.
headers (object): Optional. The headers to attach to requests to the server. This object should map the name of header keys to either of the following:
    The name of a GitHub Actions secret you have configured, beginning with COPILOT_MCP_ preceded by a $
    A string value

Example configurations
Example: Sentry

The Sentry MCP server gives Copilot authenticated access to exceptions recorded in Sentry.
JavaScript

// If you copy and paste this example, you will need to remove the comments prefixed with //, which are not valid JSON.
{
"mcpServers": {
"sentry": {
"type": "local",
"command": "npx",
// We can use the $SENTRY_HOST environment variable which is passed to
// the server because of the env value below.
"args": ["@sentry/mcp-server@latest", "--host=$SENTRY_HOST"],
"tools": ["get_issue_details", "get_issue_summary"],
"env": {
// We can specify an environment variable value as a string...
"SENTRY_HOST": "https://contoso.sentry.io",
// or refer to a GitHub Actions secret with a name starting with
// COPILOT_MCP_
"SENTRY_ACCESS_TOKEN": "COPILOT_MCP_SENTRY_ACCESS_TOKEN"
}
}
}
}

Example: Notion

The Notion MCP server gives Copilot authenticated access to notes and other content from Notion.
JavaScript

// If you copy and paste this example, you will need to remove the comments prefixed with //, which are not valid JSON.
{
"mcpServers": {
"notionApi": {
"type": "local",
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"-e",
// We can use the $NOTION_API_KEY environment variable which is passed to
// the server because of the env value below.
"OPENAPI_MCP_HEADERS={"Authorization": "Bearer $NOTION_API_KEY", "Notion-Version": "2022-06-28"}",
"mcp/notion"
],
"env": {
// The value of the COPILOT_MCP_NOTION_API_KEY secret will be passed to the
// server command as an environment variable called NOTION_API_KEY
"NOTION_API_KEY": "COPILOT_MCP_NOTION_API_KEY"
},
"tools": ["*"]
}
}
}

Example: Azure

The Azure MCP Server allows Copilot to understand your Azure-specific files and Azure resources within your subscription when making code changes.

To automatically configure your repository with a copilot-setup-steps.yml file to authenticate with Azure, plus secrets for authentication, clone the repository locally then run the Azure Developer CLI's azd coding-agent config command in the root of the repository.

Once you've run the command and merged the created pull request, you can add the MCP configuration to your repository.
JSON

{
"mcpServers": {
"Azure": {
"type": "local",
"command": "npx",
"args": [
"-y",
"@azure/mcp@latest",
"server",
"start"
],
"tools": ["*"]
}
}
}

Example: Cloudflare

The Cloudflare MCP server creates connections between your Cloudflare services, including processing documentation and data analysis.
JSON

{
"mcpServers": {
"cloudflare": {
"type": "sse",
"url": "https://docs.mcp.cloudflare.com/sse",
"tools": ["*"]
}
}
}

Example: Azure DevOps

The Azure DevOps MCP server creates a seamless connection between Copilot and your Azure DevOps services, including work items, pipelines or documentation.

To use the Azure DevOps MCP server with Copilot coding agent, you must update the repository's copilot-setup-steps.yml file to include an Azure login workflow step.

Configure OIDC in a Microsoft Entra application, trusting GitHub. See [Use the Azure Login action with OpenID Connect](https://learn.microsoft.com/en-us/azure/developer/github/connect-from-azure-openid-connect).

Setup access to Azure DevOps organization and projects for the application identity. See [Add organization users and manage access](https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/add-organization-users).

Add a .github/workflows/copilot-setup-steps.yml Actions workflow file in your repository if you do not already have one.

Add an Azure login step to the copilot-setup-steps workflow job.
YAML

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
on:
  workflow_dispatch:
permissions:
  id-token: write
  contents: read
jobs:
  copilot-setup-steps:
    runs-on: ubuntu-latest
    permissions:
      id-token: write
      contents: read
    environment: copilot
    steps:
      - name: Azure login
        uses: azure/login@a457da9ea143d694b1b9c7c869ebb04ebe844ef5
        with:
          client-id: ${{ secrets.AZURE_CLIENT_ID }}
          tenant-id: ${{ secrets.AZURE_TENANT_ID }}
          allow-no-subscriptions: true

This configuration ensures the azure/login action is executed when Copilot coding agent runs.

In your repository’s Copilot environment, add secrets for your AZURE_CLIENT_ID and AZURE_TENANT_ID.

Configure the Azure DevOps MCP server by adding an ado object to your MCP configuration with defined tools you want Copilot coding agent to use.

JSON

{
"mcpServers": {
"ado": {
"type": "local",
"command": "npx",
"args": ["-y", "@azure-devops/mcp", "", "-a", "azcli"],
"tools": ["wit_get_work_item", "wit_get_work_items_batch_by_ids", ...]
}
}
}

Reusing your MCP configuration from Visual Studio Code

If you have already configured MCP servers in VS Code, you can leverage a similar configuration for Copilot coding agent.

Depending on how VS Code is configured, you may be able to find your MCP settings in your repository's .vscode/mcp.json file, or in your machine's private settings.json file.

To adapt the configuration for Copilot coding agent, you will need to:

Add a tools key for each MCP server, specifying which tools will be available to Copilot.
If you've configured inputs, switch to using env directly.
If you've configured an envFile, switch to using env directly.
Update any references to inputs in your args configuration to refer to environment variables from env instead.

For more information on MCP in VS Code, see the VS Code docs.
Setting up a Copilot environment for Copilot coding agent

Some MCP servers will require keys or secrets. To leverage those servers in Copilot coding agent, you can add secrets to an environment for Copilot. This ensures the secrets are properly recognized and passed to the applicable MCP server that you have configured.

You must be a repository administrator to configure a Copilot environment for your repository.

On GitHub, navigate to the main page of the repository.

Under your repository name, click 

Settings. If you cannot see the "Settings" tab, select the

dropdown menu, then click Settings.

Screenshot of a repository header showing the tabs. The "Settings" tab is highlighted by a dark orange outline.

In the left sidebar, click Environments.

Click New environment.

Call the new environment copilot and click Configure environment.

Under "Environment secrets", click Add environment secret.

Give the secret a name beginning COPILOT_MCP_, add the secret value, then click Add secret.

Validating your MCP configuration

Once you've set up your MCP configuration, you should test it to make sure it is set up correctly.

Create an issue in the repository, then assign it to Copilot.
Wait a few seconds, and Copilot will leave an 👀 reaction on the issue.
Wait a few more seconds, and Copilot will create a pull request, which will appear in the issue's timeline.
Click the created pull request in the timeline, and wait until a "Copilot started work" timeline event appears.
Click View session to open the Copilot coding agent logs.
Click the ellipsis button (...) at the top right of the log viewer, then click Copilot in the sidebar.
Click the Start MCP Servers step to expand the logs.
If your MCP servers have been started successfully, you will see their tools listed at the bottom of the logs.

If your MCP servers require any dependencies that are not installed on the GitHub Actions runner by default, such as uv and pipx, or that need special setup steps, you may need to create a copilot-setup-steps.yml Actions workflow file to install them. For more information, see Customizing the development environment for GitHub Copilot coding agent.
Customizing the built-in GitHub MCP server

The GitHub MCP server is enabled by default and connects to GitHub with a specially scoped token that only has read-only access to the current repository.

If you want to allow Copilot to access data outside the current repository, you can give it a personal access token with wider access.

Create a personal access token with the appropriate permissions. We recommend using a fine-grained personal access token, where you can limit the token's access to read-only permissions on specific repositories. For more information on personal access tokens, see [Managing your personal access tokens](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens).

On GitHub, navigate to the main page of the repository.

Under your repository name, click 

Settings. If you cannot see the "Settings" tab, select the

dropdown menu, then click Settings.

Screenshot of a repository header showing the tabs. The "Settings" tab is highlighted by a dark orange outline.

In the "Code & automation" section of the sidebar, click Copilot then Coding agent.

Add your configuration in the MCP configuration section. For example, you can add the following:

JavaScript

// If you copy and paste this example, you will need to remove the comments prefixed with //, which are not valid JSON.
{
"mcpServers": {
"github-mcp-server": {
"type": "http",
// Remove "/readonly" to enable wider access to all tools.
// Then, use the "tools" key to specify the subset of tools you'd like to include.
"url": "https://api.githubcopilot.com/mcp/readonly",
"tools": ["*"]
}
}
}

Click Save.
In the left sidebar, click Environments.
Click the copilot environment.
Under "Environment secrets", click Add environment secret.
Call the secret COPILOT_MCP_GITHUB_PERSONAL_ACCESS_TOKEN, enter your personal access token in the "Value" field, then click Add secret.

For information on using the GitHub MCP server in other environments, see Using the GitHub MCP Server.
Next steps

[Creating custom agents](https://docs.github.com/en/copilot/how-tos/use-copilot-agents/coding-agent/create-custom-agents)
[Customizing the development environment for GitHub Copilot coding agent](https://docs.github.com/en/copilot/customizing-copilot/customizing-the-development-environment-for-copilot-coding-agent)
[Extending GitHub Copilot Chat with Model Context Protocol (MCP) servers](https://docs.github.com/en/copilot/customizing-copilot/extending-copilot-chat-with-mcp)

Help and support
Did you find what you needed?
Privacy policy
Help us make these docs great!

All GitHub docs are open source. See something that's wrong or unclear? Submit a pull request.

Learn how to contribute
Still need help?
Ask the GitHub community
Contact support
Legal

© 2025 GitHub, Inc.
[Terms](https://docs.github.com/en/site-policy/github-terms/github-terms-of-service)
[Privacy](https://docs.github.com/en/site-policy/privacy-policies/github-privacy-statement)
[Status](https://www.githubstatus.com/)
[Pricing](https://github.com/pricing)
[Expert services](https://services.github.com/)
[Blog](https://github.blog/)

Extending GitHub Copilot coding agent with the Model Context Protocol (MCP) - GitHub Docs

Co-authored-by: TheRealSeber <111927572+TheRealSeber@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 3, 2025

@copilot are you sure? these are the docs: Skip to main content
[GitHub Docs](h...

You're right. Per the GitHub docs, MCP servers must be configured in repository settings, not via a file. Removed mcp.json in commit 44d3429.

The workflow still installs Swagger-MCP to /tmp/swagger-mcp. To enable it:

  1. Go to SettingsCopilotCoding agentMCP servers
  2. Add this JSON configuration:
{
  "mcpServers": {
    "swagger": {
      "type": "stdio",
      "command": "node",
      "args": ["/tmp/swagger-mcp/build/index.js"],
      "env": {
        "SWAGGER_URL": "https://mini-maxit.github.io/backend/master/swagger.yaml"
      }
    }
  }
}
  1. Under Networking, add mini-maxit.github.io to allowed hosts

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a GitHub Actions workflow to automate the Copilot environment setup for the mini-maxit/frontend repository. The workflow pre-provisions the development environment with pnpm, installs dependencies, validates the build, and sets up a Swagger MCP server for backend API integration. This enables faster Copilot startup times by ensuring all tools and dependencies are prepared in advance.

Key Changes

  • New automated workflow for Copilot environment provisioning with pnpm 10.15.1, dependency installation, linting, and production build validation
  • Swagger MCP server setup for backend API documentation integration from an external repository
  • Build artifact caching strategy to improve subsequent workflow run performance

npm install -g pnpm@10.15.1
pnpm -v

- name: Setup Node.js
Copy link

Copilot AI Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The step name uses "Setup" as a verb, but the correct spelling is "Set up" (two words when used as a verb). "Setup" (one word) is a noun.

Suggested fix:

- name: Set up Node.js
Suggested change
- name: Setup Node.js
- name: Set up Node.js

Copilot uses AI. Check for mistakes.
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
Copy link

Copilot AI Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow uses Node.js version 20, but the Dockerfile uses Node.js version 22 (node:22-alpine3.19). This version mismatch could lead to inconsistent behavior between CI and production builds.

Consider aligning the versions:

- name: Set up Node.js
  uses: actions/setup-node@v4
  with:
    node-version: "22"
    cache: "pnpm"

This ensures the CI environment matches the production Docker environment.

Suggested change
node-version: "20"
node-version: "22"

Copilot uses AI. Check for mistakes.
Comment on lines 37 to 38
git clone --depth 1 https://github.com/Vizioz/Swagger-MCP.git /tmp/swagger-mcp
cd /tmp/swagger-mcp
Copy link

Copilot AI Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Swagger MCP server is cloned from an external repository without verification (no commit SHA pinning or signature verification). Consider pinning to a specific commit SHA instead of using --depth 1 with the default branch for better reproducibility and security.

Example:

git clone https://github.com/Vizioz/Swagger-MCP.git /tmp/swagger-mcp
cd /tmp/swagger-mcp
git checkout <specific-commit-sha>

This ensures the workflow always uses a known, tested version of the MCP server.

Suggested change
git clone --depth 1 https://github.com/Vizioz/Swagger-MCP.git /tmp/swagger-mcp
cd /tmp/swagger-mcp
git clone https://github.com/Vizioz/Swagger-MCP.git /tmp/swagger-mcp
cd /tmp/swagger-mcp
git checkout d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3

Copilot uses AI. Check for mistakes.
Comment on lines 55 to 65
pnpm run preview &
# Wait for server to start with retry logic
for i in {1..10}; do
if curl --fail --silent http://localhost:4173/ > /dev/null 2>&1; then
echo "Preview server is ready"
exit 0
fi
echo "Waiting for preview server... (attempt $i/10)"
sleep 2
done
echo "Preview server failed to start"
Copy link

Copilot AI Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The preview server is started in the background (pnpm run preview &) but is never explicitly terminated. While the job will clean up when it exits, it's better practice to explicitly kill the background process to prevent potential resource leaks or hanging processes.

Consider adding a trap to ensure cleanup:

run: |
  pnpm run preview &
  PREVIEW_PID=$!
  trap "kill $PREVIEW_PID 2>/dev/null || true" EXIT
  
  # Wait for server to start with retry logic
  for i in {1..10}; do
    if curl --fail --silent http://localhost:4173/ > /dev/null 2>&1; then
      echo "Preview server is ready"
      kill $PREVIEW_PID 2>/dev/null || true
      exit 0
    fi
    echo "Waiting for preview server... (attempt $i/10)"
    sleep 2
  done
  echo "Preview server failed to start"
  kill $PREVIEW_PID 2>/dev/null || true
  exit 1
Suggested change
pnpm run preview &
# Wait for server to start with retry logic
for i in {1..10}; do
if curl --fail --silent http://localhost:4173/ > /dev/null 2>&1; then
echo "Preview server is ready"
exit 0
fi
echo "Waiting for preview server... (attempt $i/10)"
sleep 2
done
echo "Preview server failed to start"
pnpm run preview &
PREVIEW_PID=$!
trap "kill $PREVIEW_PID 2>/dev/null || true" EXIT
# Wait for server to start with retry logic
for i in {1..10}; do
if curl --fail --silent http://localhost:4173/ > /dev/null 2>&1; then
echo "Preview server is ready"
kill $PREVIEW_PID 2>/dev/null || true
exit 0
fi
echo "Waiting for preview server... (attempt $i/10)"
sleep 2
done
echo "Preview server failed to start"
kill $PREVIEW_PID 2>/dev/null || true

Copilot uses AI. Check for mistakes.
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Setup Swagger MCP server
Copy link

Copilot AI Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The step name uses "Setup" as a verb, but the correct spelling is "Set up" (two words when used as a verb). "Setup" (one word) is a noun.

Suggested fix:

- name: Set up Swagger MCP server

This matches the style used in other steps like "Setup Node.js" which should also be "Set up Node.js", but for consistency with the existing naming pattern in this file, consider following the established convention.

Copilot uses AI. Check for mistakes.
@TheRealSeber TheRealSeber marked this pull request as ready for review December 3, 2025 17:55
@TheRealSeber
Copy link
Contributor

@copilot adjust please to comments

…wagger-MCP commit, add preview cleanup

Co-authored-by: TheRealSeber <111927572+TheRealSeber@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 3, 2025

@copilot adjust please to comments

Addressed all review comments in commit ed38a92:

  • Fixed step names: "Setup" → "Set up" (verb form)
  • Aligned Node.js version to 22 to match Dockerfile
  • Pinned Swagger-MCP to commit 41c2834 for reproducibility
  • Fixed Swagger-MCP build by copying .env.example to .env
  • Added proper preview server cleanup with trap and explicit kill

@TheRealSeber TheRealSeber merged commit 73e1517 into master Dec 3, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Automate Copilot Environment Setup: pre-install pnpm, install deps, cache, and pre-build frontend

2 participants