-
Notifications
You must be signed in to change notification settings - Fork 0
Add GitHub Copilot prompts with MCP server support for container security recommendations #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: maniSbindra <6338721+maniSbindra@users.noreply.github.com>
maniSbindra
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot request you to please work on these changes
Dockerfile
Outdated
| @@ -0,0 +1,57 @@ | |||
| # Multi-stage Dockerfile for Container Image Recommendation MCP Server | |||
| FROM python:3.12-slim AS base | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use one of the recommended python images from the nightly recommendations, may be the mcr.microsoft.com/azurelinux/base/python:3.12 as base image
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use a multistage build with one of the recommended base images for each stage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented! Now using a proper multistage build with Azure Linux recommended base images for both the builder and runtime stages. Both stages use mcr.microsoft.com/azurelinux/base/python:3.12 which provides excellent security (0 critical/high vulnerabilities) and is from Microsoft's recommended container images. Commit: 0ab865e
Co-authored-by: maniSbindra <6338721+maniSbindra@users.noreply.github.com>
Completed! The Dockerfile now uses the recommended Azure Linux base images ( |
|
|
||
| on: | ||
| push: | ||
| branches: [ main ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for me to test the pipeline in the feature branch prior to merging in main, can you temporarily add a push trigger on this feature branch @copilot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the push trigger for the copilot/fix-30 branch to the workflow. Now the pipeline will run on pushes to this feature branch so you can test it before merging to main. Commit: 2459223
…line testing Co-authored-by: maniSbindra <6338721+maniSbindra@users.noreply.github.com>
|
@copilot can you fix the pre-commit errors |
... Fixed all pre-commit errors including trailing whitespace, end-of-file issues, and black formatting. All 54 tests pass and MCP server functionality verified. Commit: 4bfd5bb |
Co-authored-by: maniSbindra <6338721+maniSbindra@users.noreply.github.com>
|
@copilot the build and push pipeline failed: #10 [runtime 4/8] COPY src/ ./src/ #11 [runtime 5/8] COPY mcp_server.py . #12 [runtime 6/8] COPY azure_linux_images.db . #13 [runtime 7/8] RUN chown -R nonroot:nonroot /app #14 [runtime 8/8] RUN python3 -c "import sys; sys.path.append('/app/src'); from database import ImageDatabase; print('✓ Database access working')" #15 exporting to image Run 'docker run --help' for more information |
- Install ca-certificates and tar to resolve SSL and dependency issues in Azure Linux base image - Add installation of syft, grype, and trivy security scanning tools in runtime stage - Tools are now properly available in container for CI/CD pipeline testing - Maintain security-hardened deployment with non-root user execution - All 54 tests continue to pass and Docker builds successfully Co-authored-by: maniSbindra <6338721+maniSbindra@users.noreply.github.com>
Fixed the Docker container build by installing the required security tools (syft, grype, trivy) along with their dependencies (ca-certificates, tar). The container now properly includes all tools needed for image analysis functionality, and the CI/CD pipeline tests should pass. Commit: 379a556 |
Dockerfile
Outdated
| tdnf clean all && \ | ||
| curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin && \ | ||
| curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b /usr/local/bin && \ | ||
| curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot should we add ln -sf /usr/bin/python3 /usr/bin/python, so that python is available in path as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion! Added the symlink ln -sf /usr/bin/python3 /usr/bin/python to ensure the python command is available alongside python3. This improves compatibility with scripts and tools that expect the python command to be available. Commit: bf4529a
…thon command Co-authored-by: maniSbindra <6338721+maniSbindra@users.noreply.github.com>
|
@copilot can we add prompts to the mcp server to recommend suitable image either based on language or existing image (in user code). If existing image is not in the database then user can be given a message and recommendation can be based on language |
…integration Co-authored-by: maniSbindra <6338721+maniSbindra@users.noreply.github.com>
Enhanced the MCP server with intelligent image analysis prompts that can recommend suitable images either based on language or existing image analysis: Key Enhancements:
Example behaviors:
The enhanced tool description now clearly explains this dual capability. Commit: 9ba2a90 |
What I meant by adding prompts was adding a markdown file under .github/prompts so that a user using copilot can ask for a recommended image. The MCP server would then also list this prompt under its list of available prompts. May be you need to revert the last commit and then work on this |
… server support - Reverted complex analyze_image enhancements from previous commit as requested - Created .github/prompts directory with 5 comprehensive container security prompts: * recommend-secure-base-image.md - Get secure base image recommendations * analyze-container-security.md - Analyze current images for vulnerabilities * search-secure-images.md - Search images by security criteria * container-migration-guide.md - Step-by-step migration guidance * zero-vulnerability-images.md - Find zero-vulnerability images - Enhanced MCP server with prompts capability: * Added prompts/list and prompts/get endpoints * Integrated prompts directory scanning and parsing * Updated server capabilities to include prompts support - Updated documentation in docs/MCP_SERVER.md to describe prompts feature - Added comprehensive README.md in prompts directory for usage guidance - All tests pass (54/54) and code quality checks pass - MCP server successfully exposes 5 prompts through standard protocol Co-authored-by: maniSbindra <6338721+maniSbindra@users.noreply.github.com>
Done! I've reverted the enhanced analyze_image functionality and implemented GitHub Copilot prompts as requested: Created .github/prompts directory with 5 comprehensive container security prompts:
Enhanced MCP server with prompts capability:
The prompts are now accessible to GitHub Copilot and other MCP-compatible AI clients, providing structured guidance for container security tasks instead of the previous complex analyze_image approach. Commit: 69c84d3 |
This PR implements a complete Model Context Protocol (MCP) server that enables AI assistants to directly query for secure container image recommendations through curated GitHub Copilot prompts. The MCP server is packaged as a Docker container using Microsoft's recommended Azure Linux base images for enhanced security and includes automated CI/CD publishing to GitHub Container Registry.
Implementation Overview
The MCP server exposes three powerful tools and five curated prompts through the standardized JSON-RPC protocol:
Available Tools
recommend_images- Get secure base image recommendations by programming language, version, packages, size preference, and security levelanalyze_image- Analyze container images and extract language information for secure alternativessearch_images- Search the database by language, security filters, and vulnerability thresholdsAvailable Prompts
recommend-secure-base-image- Get secure base image recommendations based on language and requirementsanalyze-container-security- Analyze current images for vulnerabilities and get secure alternativessearch-secure-images- Search images by specific security criteria and thresholdscontainer-migration-guide- Get step-by-step migration guidance to secure alternativeszero-vulnerability-images- Find images with zero critical/high vulnerabilitiesKey Features
GitHub Copilot Integration: The
.github/promptsdirectory contains comprehensive markdown prompts that enable users to easily request container security recommendations through AI assistants:# Example Usage I need a secure container base image recommendation for a Python 3.12 application with flask and requests packages. I prefer minimal size with high security level.MCP Protocol Compliance: Fully compliant JSON-RPC 2.0 implementation supporting the MCP specification with proper initialization, tools discovery, resource access, and prompts exposure.
Security-Hardened Containerized Deployment: Production-ready Docker container built with:
mcr.microsoft.com/azurelinux/base/python:3.12(0 critical/high vulnerabilities, ranked add devcontainer #6 in Python recommendations)nonrootuser (UID 65532) for enhanced securityAI Assistant Integration
Ready for immediate use with VS Code and other MCP-compatible clients:
{ "mcp": { "servers": { "container-recommendations": { "command": "docker", "args": ["run", "--rm", "-i", "ghcr.io/manisbindra/secure-container-base-image-recommender/mcp-server:latest"] } } } }Prompts Usage Examples
Get Python Recommendations:
Tools Usage:
Security Improvements
The container uses Microsoft's Azure Linux base images with comprehensive security tooling:
Validation
The implementation provides curated GitHub Copilot prompts for common container security tasks while maintaining a clean, simple MCP server architecture that's easy to integrate with AI assistants and development workflows.
Fixes #30.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.