Skip to content

Add HTTP transport support to mock MCP server #59

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Jun 5, 2025

This PR adds HTTP transport support to the mock MCP server, enabling deployment in Docker and Kubernetes environments as requested in issue #55.

What's New

  • HTTP Transport Option: Added --port flag to mcp mock command to run the server with HTTP transport
  • Multiple Endpoints: HTTP server provides JSON-RPC, SSE compatibility, and health check endpoints
  • Docker/Kubernetes Ready: Perfect for containerized deployments and prototyping workflows
  • Backward Compatible: Existing stdio transport remains the default behavior

Usage Examples

Stdio Transport (Default - No Changes)

mcp mock tool hello "A greeting tool"

HTTP Transport (New Feature)

# Start HTTP server on port 3000
mcp mock --port 3000 tool hello "A greeting tool" \
         prompt welcome "Welcome prompt" "Hello {{name}}!" \
         resource docs://api "API docs" "# API Documentation"

# Server provides multiple endpoints:
# - JSON-RPC: POST http://localhost:3000/mcp
# - SSE: GET http://localhost:3000/sse  
# - Health: GET http://localhost:3000/health

Test with curl

curl -X POST http://localhost:3000/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "method": "tools/list", "id": 1}'

Implementation Details

  • Minimal Changes: Only 4 files modified, preserving existing functionality
  • Comprehensive Testing: Added unit tests and integration tests for HTTP functionality
  • Proper JSON-RPC: Full MCP protocol compliance with proper error handling
  • Multiple Transport Support: Server can run with either stdio or HTTP transport
  • Health Monitoring: Built-in health check endpoint for container orchestration

Docker Example

FROM golang:1.24-alpine AS builder
WORKDIR /app
COPY . .
RUN go build -o mcp ./cmd/mcptools

FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=builder /app/mcp .
EXPOSE 3000

CMD ["./mcp", "mock", "--port", "3000", \
     "tool", "hello", "A greeting tool", \
     "resource", "docs://api", "Documentation", "# API Docs"]

This enables the exact use case described in the issue: deploying mock MCP servers in containerized environments for team collaboration and rapid prototyping.

Fixes #55.


💡 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.

@Copilot Copilot AI changed the title [WIP] Can't figure out if there is a way to mock a server with HTTP transport Add HTTP transport support to mock MCP server Jun 5, 2025
@Copilot Copilot AI requested a review from f June 5, 2025 23:29
Copilot finished work on behalf of f June 5, 2025 23:29
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.

Can't figure out if there is a way to mock a server with HTTP transport
2 participants