Skip to content

feat: implement Model Context Protocol (MCP) support#688

Open
Antholoj wants to merge 14 commits intowagoodman:mainfrom
Antholoj:feat/mcp
Open

feat: implement Model Context Protocol (MCP) support#688
Antholoj wants to merge 14 commits intowagoodman:mainfrom
Antholoj:feat/mcp

Conversation

@Antholoj
Copy link
Copy Markdown

@Antholoj Antholoj commented Mar 5, 2026

This PR introduces full support for the Model Context Protocol (MCP), enabling AI agents and IDEs to programmatically analyze Docker/OCI images, inspect layers, and perform deep diffing.

🚀 Key Features

  • Multi-Transport Support: Implementation of stdio, sse, and the modern streamable-http transport protocols.
  • MCP Toolset: New tools for agents including analyze_image, get_wasted_space, inspect_layer, and diff_layers.
  • Performance: Integrated LRU caching for analysis results to minimize repeated computation.
  • Docker-MCP Image: Added a specialized Dockerfile.mcp and corresponding .dockerignore for publishing a containerized MCP server to Docker Hub (antholoj/dive-mcp).
  • Documentation: Comprehensive docs/MCP_GUIDE.md covering local builds, Docker usage, and client integration (Claude Desktop, Gemini-CLI, Cursor).

🛠️ Technical Notes

  • Architectural Integrity: The implementation is non-breaking and strictly respects the original architectural design, utilizing the existing image, filetree, and bus internal packages.
  • Go 1.24 Compatibility: Builder image updated to golang:1.24-alpine to match go.mod requirements.
  • Build Optimization: Uses a dedicated Dockerfile.mcp.dockerignore to bypass root source exclusions during the MCP-specific Docker build process.
  • Container Networking: Configured DIVE_MCP_HOST=0.0.0.0 by default in the MCP Dockerfile to ensure accessibility from the host.

✅ Testing

  • New Tests: Comprehensive unit and integration tests for the MCP handlers and transport layers are included.
  • Verification: Verified via manual smoke tests using the streamable-http transport and validated stdio mode with local AI agent integration.
  • Build Validation: Confirmed full image build cycle using the new Dockerfile.mcp.

Disclaimer: This feature was implemented with the assistance of AI (Gemini CLI).

Antholoj added 14 commits March 3, 2026 00:04
…pliance

- Implement session extraction middleware to handle both header and query param
- Fix path rewriting for POST requests on /sse to support 'dumb' clients
- Add CORS support for Mcp-Session-Id and Mcp-Protocol-Version headers
- Improve baseURL logic and add warnings for 0.0.0.0 listening
…ssion handling

- Standardize all HTTP-based transports on modern Streamable HTTP implementation
- Fix 'Missing sessionId' error by implementing robust header normalization and POST-first handshake support
- Align with Model Context Protocol 2025-03-26 specification for unified HTTP/SSE handling
- Add session extraction middleware for consistent Mcp-Session-Id propagation
- Introduce integration tests for transport verification
- Update documentation to recommend Streamable HTTP for modern MCP clients
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.

1 participant