Add Copilot setup workflow for automated environment provisioning#70
Add Copilot setup workflow for automated environment provisioning#70TheRealSeber merged 5 commits intomasterfrom
Conversation
Co-authored-by: TheRealSeber <111927572+TheRealSeber@users.noreply.github.com>
|
@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: |
Co-authored-by: TheRealSeber <111927572+TheRealSeber@users.noreply.github.com>
Added Swagger MCP server setup in commit
{
"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
The MCP config file ( |
|
@copilot are you sure? these are the docs: Skip to main content 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. 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. 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 Adding an MCP configuration to your repository Repository administrators can configure MCP servers by following these steps: Settings. If you cannot see the "Settings" tab, select the 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. { The configuration object can contain the following keys: Required keys for local and remote MCP servers Local MCP specific keys Remote MCP specific keys Example configurations The Sentry MCP server gives Copilot authenticated access to exceptions recorded in Sentry. // If you copy and paste this example, you will need to remove the comments prefixed with The Notion MCP server gives Copilot authenticated access to notes and other content from Notion. // If you copy and paste this example, you will need to remove the comments prefixed with 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. { The Cloudflare MCP server creates connections between your Cloudflare services, including processing documentation and data analysis. { 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. JSON { 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: For more information on MCP in VS Code, see the VS Code docs. 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. Settings. If you cannot see the "Settings" tab, select the Validating your MCP configuration Once you've set up your MCP configuration, you should test it to make sure it is set up correctly. 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. 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. Settings. If you cannot see the "Settings" tab, select the JavaScript // If you copy and paste this example, you will need to remove the comments prefixed with For information on using the GitHub MCP server in other environments, see Using the GitHub MCP Server. Help and support All GitHub docs are open source. See something that's wrong or unclear? Submit a pull request. Learn how to contribute Extending GitHub Copilot coding agent with the Model Context Protocol (MCP) - GitHub Docs |
Co-authored-by: TheRealSeber <111927572+TheRealSeber@users.noreply.github.com>
You're right. Per the GitHub docs, MCP servers must be configured in repository settings, not via a file. Removed The workflow still installs Swagger-MCP to
{
"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"
}
}
}
}
|
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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| - name: Setup Node.js | |
| - name: Set up Node.js |
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: "20" |
There was a problem hiding this comment.
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.
| node-version: "20" | |
| node-version: "22" |
| git clone --depth 1 https://github.com/Vizioz/Swagger-MCP.git /tmp/swagger-mcp | ||
| cd /tmp/swagger-mcp |
There was a problem hiding this comment.
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.
| 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 |
| 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" |
There was a problem hiding this comment.
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| 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 |
| - name: Install dependencies | ||
| run: pnpm install --frozen-lockfile | ||
|
|
||
| - name: Setup Swagger MCP server |
There was a problem hiding this comment.
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 serverThis 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 adjust please to comments |
…wagger-MCP commit, add preview cleanup Co-authored-by: TheRealSeber <111927572+TheRealSeber@users.noreply.github.com>
Addressed all review comments in commit
|
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
.github/workflows/copilot-setup-steps.ymlworkflow_dispatchand changes to the workflow file itselfpackageManagerin package.json)actions/setup-node(aligned with Dockerfile)prepare,check,lint(graceful failures to avoid blocking on non-critical issues)Vizioz/Swagger-MCPto/tmp/swagger-mcp(pinned to commit41c28344for reproducibility)MCP Server Configuration
The workflow pre-builds the Swagger MCP server to
/tmp/swagger-mcp. To enable it for the Copilot coding agent:{ "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" } } } }mini-maxit.github.ioto allowed hostsKey decisions
setup-nodesince the cache option requires pnpm to exist|| trueon check/lint intentional—ensures Copilot can start even with minor issuesFixes #69
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.