- 
                Notifications
    You must be signed in to change notification settings 
- Fork 780
Update chatgpt app cloud example with latest mcp sdk updates #597
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
Conversation
| WalkthroughThe PR migrates two instances of a ChatGPT example application from a manual MCP server handler pattern to modern OpenAI Apps SDK decorator-based annotations. Internal functions ( Changes
 Sequence DiagramsequenceDiagram
    participant Client
    participant App as OpenAI App<br/>(Decorated)
    participant Tool as flip_coin()<br/>@app.tool
    participant Resource as get_widget_html()<br/>@mcp.resource
    
    rect rgb(200, 220, 240)
    Note over Client,App: New Decorator-Based Approach
    end
    
    Client->>App: Request tool list
    App->>App: Scan @app.tool decorators
    App-->>Client: Tool metadata (flip_coin)
    
    Client->>App: Execute flip_coin tool
    App->>Tool: Invoke decorated function
    Tool->>Tool: Generate random result
    Tool-->>App: Return {flipResult: ...}
    App-->>Client: Structured output
    
    Client->>App: Request widget resource
    App->>Resource: Invoke @mcp.resource
    Resource->>Resource: Serve WIDGET.html
    Resource-->>App: HTML string
    App-->>Client: Widget content
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 
 Possibly related PRs
 Suggested reviewers
 Poem
 Pre-merge checks and finishing touches❌ Failed checks (1 warning)
 ✅ Passed checks (2 passed)
 ✨ Finishing touches
 🧪 Generate unit tests (beta)
 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. Comment  | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it! love the deleted lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (1)
examples/cloud/chatgpt_app/main.py (1)
135-138: Mirror the structured output schema fixThis copy shares the same
Dict[str, str]annotation whilestructured_output=True. Please apply the TypedDict (or model) adjustment suggested in thesrc/...version so the schema namesflipResult.
🧹 Nitpick comments (1)
src/mcp_agent/data/examples/cloud/chatgpt_app/main.py (1)
135-138: Clarify structured output schema
structured_output=Truederives the JSON schema from the return annotation, andDict[str, str]describes an arbitrary string-keyed map. The UI won’t know thatflipResultis the sole field, so callers lose validation and documentation. Introduce a dedicatedTypedDict(orBaseModel) so the schema explicitly surfacesflipResult.+class FlipCoinResult(TypedDict): + flipResult: str + -async def flip_coin() -> Dict[str, str]: +async def flip_coin() -> FlipCoinResult:Add
from typing import TypedDictto the imports near the top.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
- examples/cloud/chatgpt_app/main.py(3 hunks)
- src/mcp_agent/data/examples/cloud/chatgpt_app/main.py(3 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-07-22T18:59:49.368Z
Learnt from: CR
PR: lastmile-ai/mcp-agent#0
File: examples/usecases/reliable_conversation/CLAUDE.md:0-0
Timestamp: 2025-07-22T18:59:49.368Z
Learning: Applies to examples/usecases/reliable_conversation/examples/reliable_conversation/src/**/*.py : Use mcp-agent's Agent abstraction for ALL LLM interactions, including quality evaluation, to ensure consistent tool access, logging, and error handling.
Applied to files:
- src/mcp_agent/data/examples/cloud/chatgpt_app/main.py
🧬 Code graph analysis (1)
src/mcp_agent/data/examples/cloud/chatgpt_app/main.py (2)
src/mcp_agent/core/context.py (2)
mcp(154-155)
fastmcp(158-173)src/mcp_agent/server/app_server.py (1)
app(280-282)
Summary
With the latest mcp sdk update, we can now set
metafor tools via the decorator (still pending the same for resource decorator but this example doesn't need any meta for it); this allows us to clean up much of the code in the chatgpt app example which was just for overriding the tool/resource implementation.Testing
uv runto see correct resource and toolSummary by CodeRabbit
Refactor
Chores