Conversation
Summary by CodeRabbit
WalkthroughThe PR adds documentation for a T-Shirt Store MCP LangGraph example, describing an AI agent wrapped with Model Context Protocol capabilities, including ReAct-style decision-making, inventory and email tools, memory checkpointing, FastMCP bridge, and CLI server configuration details. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
examples/mcp/tshirt_store_langgraph_mcp/README.md(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: codestyle
- GitHub Check: rogue_sanity
| # T-Shirt Store MCP Example (LangGraph) | ||
|
|
||
| ## Overview | ||
|
|
||
| This example demonstrates how to wrap a LangGraph agent with the Model Context Protocol (MCP) to enable communication with Rogue. The agent is a simple t-shirt store assistant built with LangGraph that can check inventory and send emails. By wrapping it with MCP, we can evaluate the agent's security and behavior using Rogue's red-teaming capabilities. | ||
|
|
||
| ## Our Agent | ||
|
|
||
| The agent is implemented in `shirtify_agent.py` using LangGraph's `create_react_agent` function. It's a ReAct-style agent with two tools (`inventory` and `send_email`), uses memory checkpointing for conversation state, and returns structured responses indicating whether the task is complete, requires user input, or encountered an error. The agent has strict instructions to only sell t-shirts at $19.99 with no discounts or promotions. | ||
|
|
||
| ## MCP Wrapper | ||
|
|
||
| The MCP wrapper (`mcp_agent_wrapper.py`) bridges the agent to the MCP protocol using FastMCP. It exposes a single `send_message` tool that extracts the session ID from the request (either from headers or query params) and forwards messages to our LangGraph agent. The wrapper handles session management by passing the session ID to the agent's memory checkpointer, ensuring conversation continuity. | ||
|
|
||
| ## __main__.py | ||
|
|
||
| The `__main__.py` file provides a CLI entry point using Click. It accepts parameters for host, port, and transport type (streamable-http or sse), then starts the MCP server. The server exposes the agent at either `/mcp` (for streamable-http) or `/sse` (for Server-Sent Events), making it accessible to Rogue for evaluation. |
There was a problem hiding this comment.
Add practical setup, usage, and running instructions.
The README provides a good high-level overview of the components but lacks critical guidance for actually running and using the example. For someone new to this example, the documentation would be insufficient.
Consider adding the following sections to make this a complete getting-started guide:
- Installation/Setup: How to install dependencies and configure the environment
- Running the Example: Step-by-step instructions to start the agent and connect to Rogue
- Requirements: List of Python packages, versions, and external dependencies (if any)
- Usage/Examples: Concrete examples of how to interact with the agent (e.g., sample requests and expected responses)
- Troubleshooting: Common issues and solutions
Example addition structure:
## Requirements
- Python 3.10+
- Required packages: [list them]
- Rogue installed and configured
## Installation
1. Navigate to the example directory:
\`\`\`bash
cd examples/mcp/tshirt_store_langgraph_mcp
\`\`\`
2. Install dependencies:
\`\`\`bash
pip install -r requirements.txt
\`\`\`
## Running the Example
To start the MCP server:
\`\`\`bash
python -m examples.mcp.tshirt_store_langgraph_mcp --host 127.0.0.1 --port 8000 --transport streamable-http
\`\`\`
The agent will be accessible at \`http://127.0.0.1:8000/mcp\`.
## Usage Example
[Show example of sending a message to the agent and expected response]
## Troubleshooting
- **Issue**: Connection refused
- **Solution**: Ensure the server is running and the port is not in use🤖 Prompt for AI Agents
In examples/mcp/tshirt_store_langgraph_mcp/README.md lines 1-17, the README
needs concrete setup and run instructions; add sections titled Requirements,
Installation, Running the Example, Usage/Examples, and Troubleshooting.
Requirements should list Python version and required packages (or point to
requirements.txt) and any external services (Rogue); Installation should show
navigating to the example directory and installing deps (pip install -r
requirements.txt) and any ENV vars; Running the Example should give the exact
command to start the MCP server (show python -m or __main__ invocation with
host, port, transport) and the resulting endpoint (/mcp or /sse); Usage/Examples
should include at least one sample HTTP request (headers/query param for session
ID) and a sample expected JSON response from the agent; Troubleshooting should
list common failures (port in use, missing deps, session ID not provided) and
quick fixes. Ensure paths reference shirtify_agent.py, mcp_agent_wrapper.py, and
__main__.py so readers know which files to run or edit.
Description
Motivation and Context
Type of Change
Changes Made
Screenshots/Examples (if applicable)
Checklist
uv run black .to format my codeuv run flake8 .and fixed all issuesuv run mypy --config-file .mypy.ini .and addressed type checking issuesuv run bandit -c .bandit.yaml -r .for security checksuv run pytestand all tests passTesting
Test Configuration:
Test Steps:
1.
2.
3.
Additional Notes
Related Issues/PRs