Skip to content

Conversation

andrew-lastmile
Copy link
Contributor

@andrew-lastmile andrew-lastmile commented Sep 14, 2025

Local run:
image

Cloud run:
image

To do:

  • investigate why this example fails to start file-system server

Summary by CodeRabbit

  • New Features

    • Exposed two app tools in the MCP Server Aggregator example: one using persistent connections and one non-persistent. Each returns a summarized result string of listed tools, file read, and fetch operations.
  • Documentation

    • Added “[Beta] Deploy to the cloud” guide to the MCP Server Aggregator README, covering login, one-command deployment, and client connection.
    • Included configuration example for desktop integration using a bearer token.
    • Added MCP Inspector setup steps (SSE settings, headers) and a tip to increase request timeouts.

Copy link

coderabbitai bot commented Sep 14, 2025

Walkthrough

Exposes two example routines as public app tools returning strings in the MCP Server Aggregator example, adjusting result accumulation and logging. Updates the README with a new “[Beta] Deploy to the cloud” section detailing login, deploy, and client connection steps with config examples. No other modules changed.

Changes

Cohort / File(s) Summary
Docs: Cloud deploy section
examples/basic/mcp_server_aggregator/README.md
Added section “4 [Beta] Deploy to the cloud” with workflow steps, Claude Desktop config using BEARER_TOKEN, and MCP Inspector setup including SSE settings and timeout note.
Example app tools exposure and flow
examples/basic/mcp_server_aggregator/main.py
Converted example_usage_persistent and example_usage to @app.tool functions returning str. Implemented result string accumulation, per-step logging via output variable, renamed read_file -> read_text_file, and kept fetch_fetch. Persistent vs non-persistent aggregator creation preserved; final results returned (and printed in non-persistent variant).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Client as MCP Client
  participant App as Example App (@app.tool)
  participant Agg as MCPAggregator
  participant Servers as MCP Servers

  rect rgba(220,240,255,0.4)
    Note over Client,App: Tool invocation (persistent or non-persistent)
    Client->>App: Call example_usage(_persistent)
    App->>Agg: init(connection_persistence=bool)
  end

  rect rgba(235,255,235,0.4)
    App->>Agg: list_tools()
    Agg->>Servers: Query available tools
    Servers-->>Agg: Tools list
    Agg-->>App: Tools list
    App->>App: Append to result
  end

  rect rgba(235,255,235,0.4)
    App->>Agg: read_text_file(path="README.md")
    Agg->>Servers: read_text_file
    Servers-->>Agg: File contents
    Agg-->>App: Output
    App->>App: Append to result
  end

  rect rgba(235,255,235,0.4)
    App->>Agg: fetch_fetch(...)
    Agg->>Servers: fetch
    Servers-->>Agg: Response
    Agg-->>App: Output
    App->>App: Append to result
  end

  App-->>Client: Return accumulated string result
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • saqadri
  • StreetLamb

Poem

A hop, a skip—two tools take flight,
Strings in their paws, they stitch the night.
Clouds above beckon, “Deploy, explore!”
SSE winds hum at the server’s door.
With tokens tucked in whiskered cheer,
This bunny ships—then disappears. 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "Making MCP Server Aggregator Cloud ready" succinctly captures the PR's main objective—preparing the aggregator for cloud deployment via README additions and exposing example usage as app tools—so it is relevant, concise, and clear for reviewers.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch andrew-docs-mcp-server-aggregator

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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.

Copy link
Collaborator

@saqadri saqadri left a comment

Choose a reason for hiding this comment

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

🚀

@andrew-lastmile
Copy link
Contributor Author

non-persistent mode fails for the filesystem mcp server:

Filesystem server (@modelcontextprotocol/server-filesystem):
	•	Stateful by design.
	•	Needs to negotiate roots (allowed directories) with the client at initialization.
	•	Exposes a larger toolset (read_text_file, list_directory, etc.), which depends on knowing its roots.
	•	In non-persistent mode, the aggregator spins it up, but there’s no stable channel to handle that roots handshake — so it errors out:
	•	Failed to validate request: 'NoneType' object has no attribute 'roots'
	•	Tool 'read_text_file' not found

non-blocking issue, merging for now

@andrew-lastmile andrew-lastmile marked this pull request as ready for review September 16, 2025 16:04
@andrew-lastmile andrew-lastmile merged commit 4e15a7e into main Sep 16, 2025
7 of 8 checks passed
@andrew-lastmile andrew-lastmile deleted the andrew-docs-mcp-server-aggregator branch September 16, 2025 16:08
Copy link

@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: 0

🧹 Nitpick comments (11)
examples/basic/mcp_server_aggregator/main.py (11)

20-20: Initialize result with proper spacing.

Consider adding a space after the equals sign for better readability.

-    result=""
+    result = ""

39-39: Add spacing in string concatenation for better formatting.

The concatenation lacks spacing which could make the output harder to read.

-        result+="Tools available:"+str(output)
+        result += "Tools available: " + str(output)

47-47: Improve string concatenation formatting.

Add proper spacing for better readability.

-        result+="\n\nread_text_file result:" + str(output)
+        result += "\n\nread_text_file result: " + str(output)

56-56: Improve string concatenation formatting.

Add proper spacing for consistency.

-        result+=f"\n\nfetch result: {str(output)}"
+        result += f"\n\nfetch result: {str(output)}"

61-61: Add null check before closing aggregator.

The aggregator could be None if creation fails before the assignment completes.

-        await aggregator.close()
+        if aggregator:
+            await aggregator.close()

73-73: Initialize result with proper spacing.

-    result=""
+    result = ""

92-92: Add spacing in string concatenation.

-        result+="Tools available:"+str(output)
+        result += "Tools available: " + str(output)

100-100: Improve string concatenation formatting.

-        result+="\n\nread_text_file result:" + str(output)
+        result += "\n\nread_text_file result: " + str(output)

108-109: Inconsistent logging approach and formatting.

Line 108 uses f-string in the message while other locations use the data parameter. Also missing proper spacing in concatenation on line 109.

-        logger.info(f"fetch result: {str(output)}")
-        result+=f"\n\nfetch result: {str(output)}"
+        logger.info("fetch result:", data=output)
+        result += f"\n\nfetch result: {str(output)}"

114-114: Add null check before closing aggregator.

-        await aggregator.close()
+        if aggregator:
+            await aggregator.close()

116-116: Consider removing print statement in tool function.

Since this function is now a tool that returns a string result, the print statement may be redundant - the caller/framework will handle output display.

Consider removing the print statement as the return value should be sufficient for cloud deployment scenarios where the output is handled by the MCP framework.

-    print(result)
-
     return result
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fce6d5b and 55bfc26.

📒 Files selected for processing (2)
  • examples/basic/mcp_server_aggregator/README.md (1 hunks)
  • examples/basic/mcp_server_aggregator/main.py (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
examples/basic/mcp_server_aggregator/main.py (3)
src/mcp_agent/server/app_server.py (1)
  • app (134-136)
src/mcp_agent/app.py (1)
  • logger (193-210)
src/mcp_agent/logging/logger.py (2)
  • info (271-279)
  • error (291-299)
🔇 Additional comments (4)
examples/basic/mcp_server_aggregator/README.md (1)

61-114: Cloud deployment documentation looks comprehensive and well-structured.

The new cloud deployment section provides clear step-by-step instructions for deploying the MCP Server Aggregator. The documentation includes essential configuration examples for both Claude Desktop and MCP Inspector integrations, with appropriate emphasis on the timeout settings for LLM calls.

examples/basic/mcp_server_aggregator/main.py (3)

11-19: Good transformation to cloud-compatible tool interface.

Converting example_usage_persistent to an @app.tool decorated function with a string return type makes it accessible as an MCP tool in the cloud deployment. The docstring clearly explains the persistent connection behavior.


43-43: Tool name change aligns with filesystem server's actual interface.

The change from read_file to read_text_file correctly matches the actual tool name exposed by the @modelcontextprotocol/server-filesystem package.


65-72: Non-persistent mode implementation with known filesystem server limitation.

As noted in the PR objectives, the non-persistent mode fails with the filesystem server because it requires stateful roots negotiation. This is a known issue being tracked separately. The tool decorator and return type changes are appropriate for cloud deployment.

Since this is a known issue with the filesystem server in non-persistent mode, consider adding a comment in the code to document this limitation until it's resolved.

 @app.tool
 async def example_usage()->str:
     '''
     this example function/tool call will use an MCP aggregator
     to connect to both the file and filesystem servers and 
     aggregate them together, so you can list all tool calls from
-    both servers at once.
+    both servers at once.
+    
+    Note: The filesystem server may fail in non-persistent mode due to
+    stateful roots negotiation requirements.
     '''

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