Mcp restaurant agent#32
Conversation
| if DOTENV_PATH.exists(): | ||
| dot = dotenv_values(DOTENV_PATH) | ||
| dv = dot.get(key) | ||
| if dv is not None and str(dv).strip() != "": |
There was a problem hiding this comment.
mcp-agents/mcp-booking-main/src/stripe_checkout.py:34 — Syntax error (extra closing parenthesis)
if dv is not None and str(dv).strip() != "":
return str(dv).strip()) # ← Extra closing parenthesisThis line will cause a SyntaxError when the file is imported. Remove the extra parenthesis:
| if dv is not None and str(dv).strip() != "": | |
| if dv is not None and str(dv).strip() != "": | |
| return str(dv).strip() |
| """ | ||
| if not is_configured(): | ||
| return None | ||
| s = _get_stripe() |
There was a problem hiding this comment.
mcp-agents/mcp-booking-main/src/stripe_checkout.py:169 — Syntax error (missing closing parenthesis)
"amount_cents": int(c["amount_cents"), # ← Missing closing parenthesisThis line will cause a SyntaxError. Add the missing parenthesis:
| s = _get_stripe() | |
| "amount_cents": int(c["amount_cents"]), |
| ), | ||
| ) | ||
| return | ||
|
|
There was a problem hiding this comment.
mcp-agents/mcp-booking-main/src/fetch_uagent.py:334 — true should be True (Python is case-sensitive)
if not state.paid_unlocked and state.pending_checkout_session_id:
if verify_checkout_session_paid(state.pending_checkout_session_id):
state.paid_unlocked = true # ← Should be TruePython uses True/False, not true/false. Also, verify_checkout_session_paid is a synchronous function that makes a network call, which blocks the event loop.
Fix: Use True and consider making the verification async:
| if not state.paid_unlocked and state.pending_checkout_session_id: | |
| if await verify_checkout_session_paid(state.pending_checkout_session_id): | |
| state.paid_unlocked = True |
| CompletePayment, | ||
| Funds, | ||
| RejectPayment, | ||
| RequestPayment, |
There was a problem hiding this comment.
mcp-agents/mcp-booking-main/src/fetch_uagent.py:40 — Hardcoded default seed is a security risk
DEFAULT_SEED = os.getenv(
"FETCH_UAGENT_SEED",
"replace-this-with-your-own-strong-seed-phrase-please",
)The seed deterministically generates the agent's address and wallet. Anyone with the seed can impersonate the agent and drain its FET. The default placeholder could accidentally be used in production.
Fix: Remove the default and require the environment variable:
| RequestPayment, | |
| DEFAULT_SEED = os.getenv("FETCH_UAGENT_SEED") | |
| if not DEFAULT_SEED: | |
| raise ValueError("FETCH_UAGENT_SEED environment variable is required") |
|
|
||
| query = _get_chat_user_text(msg) | ||
| if not query: | ||
| await ctx.send(sender, _chat_text_message("Please send a text query.")) |
There was a problem hiding this comment.
mcp-agents/mcp-booking-main/src/fetch_uagent.py:368 — Same issue: true should be True
if not state.paid_unlocked and state.pending_checkout_session_id:
if verify_checkout_session_paid(state.pending_checkout_session_id):
state.paid_unlocked = true # ← Should be TrueSame as line 334 - use True instead of true.
| await ctx.send(sender, _chat_text_message("Please send a text query.")) | |
| state.paid_unlocked = True |
| f"{c['success_url']}" | ||
| f"?session_id={{CHECKOUT_SESSION_ID}}" | ||
| f"&chat_session_id={chat_session_id}" | ||
| f"&user={user_address}" |
There was a problem hiding this comment.
mcp-agents/mcp-booking-main/src/stripe_checkout.py:112,193 — Bare except swallows errors
except Exception:
return NoneThese bare except clauses silently swallow all errors, making debugging difficult. At minimum, log the error:
| f"&user={user_address}" | |
| except Exception as e: | |
| import logging | |
| logging.error(f"Stripe checkout session creation failed: {e}") | |
| return None |
| await ctx.send(sender, ResponseMessage(text="Missing request text.")) | ||
| return | ||
|
|
||
| state = _gate_state(sender) |
There was a problem hiding this comment.
mcp-agents/mcp-booking-main/src/fetch_uagent.py:287 — Dead code (duplicate assignment)
def _gate_state(sender: str) -> UserGateState:
key = _paywall_state_key(sender)
state = _gate_state_by_sender.get(key)
if state is None:
state = UserGateState()
_gate_state_by_sender[key] = state
state = state # ← This line does nothing
return stateLine 287 assigns state to itself. This is harmless but suggests leftover refactoring code. Remove it.
| state = _gate_state(sender) | |
| if state is None: | |
| state = UserGateState() | |
| _gate_state_by_sender[key] = state | |
| return state |
Review: MCP Restaurant Agent - PR #32SummaryThis PR adds a comprehensive MCP-based restaurant recommendation agent with:
Overall risk: Medium - The code is well-structured and follows best practices, but there are a few security and correctness issues that should be addressed before merging. What I Liked
Security 🔒
|
|
Remove extra files like render, GitHub workflows, and templates, as they are already included across all repositories. |
Summary
This PR adds a new MCP-based restaurant recommendation agent example.
The agent takes natural language queries, uses MCP tools backed by Google Places API to fetch real-time restaurant data, and returns structured recommendations. It also supports a follow-up flow to fetch detailed restaurant information (address, hours, contact, etc.) and includes Yelp enrichment for better user experience.
Type of Change
Checklist
ruff check ..ruff format ..README.mdfor changed example(s)..env.exampleif environment variables are required.CHANGELOG.md(required for non-doc changes).Related Issue
N/A
Notes for Reviewers