Skip to content

add Mcp tutorial#2953

Merged
predic8 merged 5 commits into
masterfrom
mcp-tutorial
May 22, 2026
Merged

add Mcp tutorial#2953
predic8 merged 5 commits into
masterfrom
mcp-tutorial

Conversation

@christiangoerdes
Copy link
Copy Markdown
Collaborator

@christiangoerdes christiangoerdes commented May 22, 2026

Summary by CodeRabbit

  • Documentation

    • Added comprehensive AI/MCP tutorial for exposing Membrane API Gateway as an MCP server, including Claude Desktop setup instructions and security guidance for protecting the MCP endpoint.
  • New Features

    • Included tutorial configuration, traffic generation utilities, and helper scripts to support the AI/MCP tutorial setup across multiple platforms.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 22, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: db56d02a-20fb-44e6-bac5-7496a0d30ae8

📥 Commits

Reviewing files that changed from the base of the PR and between 8016f82 and 2b6779e.

📒 Files selected for processing (4)
  • distribution/tutorials/ai/mcp/10-MCP-Server.yaml
  • distribution/tutorials/ai/mcp/README.md
  • distribution/tutorials/ai/mcp/generate-traffic.cmd
  • distribution/tutorials/ai/mcp/generate-traffic.sh

📝 Walkthrough

Walkthrough

This PR introduces a complete MCP (Model Context Protocol) tutorial for the Membrane API Gateway. It includes configuration examples, documentation with Claude Desktop integration steps, cross-platform launcher and Docker scripts, and traffic generation utilities for testing and demonstration purposes.

Changes

MCP Tutorial Feature

Layer / File(s) Summary
Tutorial documentation and overview
distribution/tutorials/README.md, distribution/tutorials/ai/mcp/README.md
Added "AI / MCP" section to main tutorials list and created a dedicated MCP tutorial README with setup guidance, Claude Desktop configuration for npx mcp-remote http://localhost:2000, endpoint protection patterns using apiKey interceptors, and local proxy setup.
MCP server configuration example
distribution/tutorials/ai/mcp/10-MCP-Server.yaml
YAML configuration that defines an MCP server on port 2000 with maxExchanges: 10000, plus two demo external-target proxy APIs (Fruitshop on 3000, ApiBin on 3001) for traffic inspection and testing.
Launcher scripts for local execution
distribution/tutorials/ai/mcp/membrane.sh, distribution/tutorials/ai/mcp/membrane.cmd
Entrypoint scripts for Unix and Windows that search upward for the Membrane installation root, set environment variables (MEMBRANE_HOME, MEMBRANE_CALLER_DIR), and delegate to the main Membrane launcher.
Docker container runtime scripts
distribution/tutorials/ai/mcp/run-docker.sh, distribution/tutorials/ai/mcp/run-docker.cmd
Shell and batch scripts that pull and run predic8/membrane:7.2.1 in a Docker container with port mapping (2000–2010) and inject the tutorial directory into /opt/membrane/.
Traffic generation and testing utilities
distribution/tutorials/ai/mcp/generate-traffic.sh, distribution/tutorials/ai/mcp/generate-traffic.cmd
Cross-platform scripts that send repeated HTTP requests against configurable Fruit Shop, ApiBin, and attack endpoint backends to simulate API traffic for inspection and testing by the MCP server.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested labels

7.x

Suggested reviewers

  • predic8
  • rrayst

Poem

🐰 A gateway opens to the minds of clay,
Where protocols convene and schemas play,
From Docker's shell to batch files so divine,
This MCP tutorial now helps the AI shine! 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'add Mcp tutorial' accurately describes the main change: adding a new MCP (Model Context Protocol) tutorial to the Membrane API Gateway distribution.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mcp-tutorial

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@christiangoerdes
Copy link
Copy Markdown
Collaborator Author

/ok-to-test

@membrane-ci-server
Copy link
Copy Markdown

This pull request needs "/ok-to-test" from an authorized committer.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@distribution/tutorials/ai/mcp/generate-traffic.cmd`:
- Line 11: The SET command is unquoted and can break if %~1 contains special
characters; update the assignment of the ROUNDS variable by quoting the SET
value — replace the line using the symbol "set ROUNDS=%~1" with a quoted form
such as "set \"ROUNDS=%~1\"" (i.e., use set "ROUNDS=%~1") so the variable is
assigned safely without introducing stray spaces or parsing issues.

In `@distribution/tutorials/ai/mcp/membrane.cmd`:
- Around line 1-24: The batch script uses LF-only line endings which can break
Windows .cmd parsing; convert this file to CRLF line endings and commit the
change so Windows users can run labels like :search_up and :found and the call
to "%MEMBRANE_HOME%\scripts\run-membrane.cmd" reliably; optionally add/update a
.gitattributes entry to enforce CRLF for *.cmd to prevent regressions.

In `@distribution/tutorials/ai/mcp/README.md`:
- Around line 15-32: The example JSON in the README currently overwrites
unrelated top-level keys by including "preferences"; update the snippet so it
only shows the "mcpServers" object (retain the "membrane" entry and its
"command" and "args") and add a short note telling readers to merge this
"mcpServers" object into their existing config rather than replacing the whole
file to avoid resetting user settings; remove the "preferences" block entirely
from the example.

In `@distribution/tutorials/ai/mcp/run-docker.cmd`:
- Around line 1-15: The batch script run-docker.cmd currently uses LF-only line
endings; convert the file to use CRLF (Windows-style) line endings so the
Windows cmd parser correctly executes the script—preserve all existing content
and lines (variables like DIR, IMAGE, CLEANUP_CMD and the docker create/cp/start
commands) but save the file with CRLF endings.
- Around line 7-14: The script assumes the variable CID (set by the docker
create for /f loop) is always populated; add a guard immediately after that loop
to check if CID is empty or undefined and, if so, print a clear error to stderr
and exit with a non-zero status so subsequent docker cp/docker start/CLEANUP_CMD
are not run; ensure the CLEANUP_CMD and later uses reference the validated CID
variable (and avoid running them when CID is empty).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fd46088d-cbc3-421a-bf5a-2cb4228e6800

📥 Commits

Reviewing files that changed from the base of the PR and between 3b52b49 and 8016f82.

📒 Files selected for processing (10)
  • distribution/tutorials/README.md
  • distribution/tutorials/ai/mcp/10-MCP-Server.yaml
  • distribution/tutorials/ai/mcp/20-MCP-Server-Protected.yaml
  • distribution/tutorials/ai/mcp/README.md
  • distribution/tutorials/ai/mcp/generate-traffic.cmd
  • distribution/tutorials/ai/mcp/generate-traffic.sh
  • distribution/tutorials/ai/mcp/membrane.cmd
  • distribution/tutorials/ai/mcp/membrane.sh
  • distribution/tutorials/ai/mcp/run-docker.cmd
  • distribution/tutorials/ai/mcp/run-docker.sh

Comment thread distribution/tutorials/ai/mcp/generate-traffic.cmd
Comment thread distribution/tutorials/ai/mcp/membrane.cmd
Comment thread distribution/tutorials/ai/mcp/README.md
Comment thread distribution/tutorials/ai/mcp/run-docker.cmd
Comment thread distribution/tutorials/ai/mcp/run-docker.cmd
Comment thread distribution/tutorials/ai/mcp/10-MCP-Server.yaml
Comment thread distribution/tutorials/ai/mcp/10-MCP-Server.yaml Outdated
Comment thread distribution/tutorials/ai/mcp/10-MCP-Server.yaml Outdated
@predic8 predic8 merged commit 79a231a into master May 22, 2026
3 of 4 checks passed
@predic8 predic8 deleted the mcp-tutorial branch May 22, 2026 10:17
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.

2 participants