Skip to content

Conversation

@rholinshead
Copy link
Member

@rholinshead rholinshead commented Oct 29, 2025

Summary

Add a cloud-deployable example for observability with OTLP endpoints, using Langfuse as the exporter.

Testing

Run locally and deploy to cloud, then run from the server. Both result in traces in Langfuse

Summary by CodeRabbit

  • New Features

    • Added an observability example demonstrating OpenTelemetry + Langfuse integration for MCP apps.
  • Documentation

    • Expanded Inspector configuration guide with detailed settings and timeout guidance.
    • Added full observability setup documentation, prerequisites, local testing, and deployment guidance.
  • Configuration

    • Switched logger transport from file-based logging to console output.

@rholinshead rholinshead requested a review from saqadri October 29, 2025 14:38
@coderabbitai
Copy link

coderabbitai bot commented Oct 29, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds a new observability example for MCP (Python app, OpenTelemetry, Langfuse) with configs and docs; updates MCP example README with Inspector settings; changes logger transport from file to console in an existing MCP example; removes an inline comment in a temporal requirements file.

Changes

Cohort / File(s) Summary
MCP Inspector docs & config
examples/cloud/mcp/README.md, examples/cloud/mcp/mcp_agent.config.yaml
Appended Inspector configuration docs (SSE transport, URL, headers, token, timeout guidance) to README; changed logger transports from file to console and removed log file path in the MCP config.
New Observability Example — Docs
examples/cloud/observability/README.md
Added README describing OpenTelemetry + Langfuse observability example, prerequisites, configuration (OTLP, API keys), local testing, and deployment notes.
New Observability Example — Code
examples/cloud/observability/main.py
New MCP Python example: app = MCPApp(...), get_magic_number, grade_story_async tool orchestrating parallel LLM agents (proofreader, fact_checker, style_enforcer, grader) with OpenTelemetry spans, and main entrypoint starting the app and SSE server.
New Observability Example — Config & deps
examples/cloud/observability/mcp_agent.config.yaml, examples/cloud/observability/mcp_agent.secrets.yaml.example, examples/cloud/observability/requirements.txt
New config enabling OTEL (service name set), asyncio execution engine, example secrets including OpenAI key and OTLP headers, and requirements (local mcp-agent path plus openai).
Temporal example tidy
examples/temporal/requirements.txt
Removed an inline instructional comment about removing the local path for cloud deployment.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant GradeStory as grade_story_async()
    participant Magic as get_magic_number()
    participant Parallel as ParallelLLM
    participant Agents as Agents (Proofreader,FactChecker,StyleEnforcer,Grader)
    participant OTEL as OpenTelemetry

    Client->>GradeStory: invoke grade_story_async(story)
    GradeStory->>OTEL: start trace/span
    GradeStory->>Magic: compute magic number (sync)
    Magic-->>GradeStory: magic_number (span recorded)
    GradeStory->>Parallel: execute ParallelLLM (fan-out)
    Parallel->>Agents: run Proofreader,FactChecker,StyleEnforcer (parallel)
    Agents-->>Parallel: results
    Parallel->>Agents: run Grader (fan-in)
    Agents-->>Parallel: final grade
    Parallel-->>GradeStory: aggregated result
    GradeStory->>OTEL: log result & end span
    GradeStory-->>Client: return final grade
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Review attention: examples/cloud/observability/main.py (async patterns, ParallelLLM/agent wiring, error handling, instrumentation).
  • Verify OTLP/secret formatting in mcp_agent.secrets.yaml.example and mcp_agent.config.yaml.
  • Confirm logger change in examples/cloud/mcp/mcp_agent.config.yaml aligns with expected runtime logging.

Possibly related PRs

Suggested reviewers

  • saqadri

Poem

🐰 In traces and spans through cloud-lit night,

Four agents hop, making stories bright.
Logs whisper softly, OTEL in tune,
A rabbit applauds under the observability moon. ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "Feat/cloud observability example" directly and clearly relates to the primary change in the changeset. The bulk of the modifications introduce a new observability example in the examples/cloud/observability/ directory, including main.py, configuration files, documentation, and requirements—all designed to demonstrate cloud-deployable observability using OTLP endpoints and Langfuse. The title accurately captures this main objective in concise, specific language that a teammate scanning PR history would immediately understand. While the title uses a commit convention prefix and doesn't detail specific technologies like Langfuse, PR titles are not expected to cover every detail, and this level of specificity is appropriate and sufficient.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 31af4ee and 4b4a07a.

📒 Files selected for processing (2)
  • examples/cloud/observability/README.md (1 hunks)
  • examples/cloud/observability/main.py (1 hunks)

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.

@rholinshead rholinshead marked this pull request as ready for review October 29, 2025 14:48


# You can always explicitly trace using opentelemetry as usual
def get_magic_number(original_number: int = 0) -> int:
Copy link
Collaborator

Choose a reason for hiding this comment

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

One other thing that may be great to add would be a function decorated as an app.workflow_task, which is then called via app_ctx.executor.execute. That will execute the function as an activity, and will be great to show that. Totally optional, but wanted to suggest that for completeness

Copy link
Member Author

Choose a reason for hiding this comment

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

Done
Screenshot 2025-10-29 at 3 29 53 PM

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: 1

🧹 Nitpick comments (1)
examples/cloud/observability/main.py (1)

52-79: Consider passing context to Agent instances for better tracing.

The Agent instances are created without an explicit context parameter. While the Agent class falls back to get_current_context() internally, explicitly passing the context ensures proper tracing context propagation and access to app configuration.

Apply this pattern to improve context propagation:

     proofreader = Agent(
         name="proofreader",
         instruction="""Review the short story for grammar, spelling, and punctuation errors.
         Identify any awkward phrasing or structural issues that could improve clarity. 
         Provide detailed feedback on corrections.""",
+        context=context,
     )
 
     fact_checker = Agent(
         name="fact_checker",
         instruction="""Verify the factual consistency within the story. Identify any contradictions,
         logical inconsistencies, or inaccuracies in the plot, character actions, or setting. 
         Highlight potential issues with reasoning or coherence.""",
+        context=context,
     )
 
     style_enforcer = Agent(
         name="style_enforcer",
         instruction="""Analyze the story for adherence to style guidelines.
         Evaluate the narrative flow, clarity of expression, and tone. Suggest improvements to 
         enhance storytelling, readability, and engagement.""",
+        context=context,
     )
 
     grader = Agent(
         name="grader",
         instruction="""Compile the feedback from the Proofreader and Fact Checker
         into a structured report. Summarize key issues and categorize them by type. 
         Provide actionable recommendations for improving the story, 
         and give an overall grade based on the feedback.""",
+        context=context,
     )
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a675752 and 31af4ee.

📒 Files selected for processing (8)
  • examples/cloud/mcp/README.md (1 hunks)
  • examples/cloud/mcp/mcp_agent.config.yaml (1 hunks)
  • examples/cloud/observability/README.md (1 hunks)
  • examples/cloud/observability/main.py (1 hunks)
  • examples/cloud/observability/mcp_agent.config.yaml (1 hunks)
  • examples/cloud/observability/mcp_agent.secrets.yaml.example (1 hunks)
  • examples/cloud/observability/requirements.txt (1 hunks)
  • examples/temporal/requirements.txt (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
examples/cloud/observability/main.py (5)
src/mcp_agent/agents/agent.py (1)
  • Agent (62-1161)
src/mcp_agent/server/app_server.py (2)
  • app (244-246)
  • create_mcp_server_for_app (504-2042)
src/mcp_agent/core/context.py (2)
  • Context (65-323)
  • name (195-198)
src/mcp_agent/workflows/llm/augmented_llm_openai.py (1)
  • OpenAIAugmentedLLM (83-926)
src/mcp_agent/workflows/parallel/parallel_llm.py (1)
  • ParallelLLM (25-282)
🪛 LanguageTool
examples/cloud/observability/README.md

[style] ~3-~3: Try moving the adverb to make the sentence clearer.
Context: ... OTLP exporter (Langfuse). It shows how to automatically trace tool calls, workflows, LLM calls, and add custom t...

(SPLIT_INFINITIVE)

🔇 Additional comments (7)
examples/temporal/requirements.txt (1)

1-7: Verify cloud deployment guidance is documented elsewhere.

The inline comment instructing developers to remove the local mcp-agent path for cloud deployment has been removed. While this file may be intended for local development, the PR description states this is a "cloud-deployable example." Without the reminder, developers using this as a template may not realize they need to change file://../../ to a published package version (e.g., mcp-agent==X.Y.Z) before deploying to the cloud.

Confirm that cloud deployment steps are clearly documented in a deployment guide or README, or consider restoring the comment to prevent accidental misconfiguration.

examples/cloud/mcp/mcp_agent.config.yaml (1)

1-6: LGTM! Console logging is appropriate for cloud deployment.

The change from file-based to console-based logging aligns well with cloud deployment practices where logs are typically captured from stdout/stderr by the container orchestration platform.

examples/cloud/observability/mcp_agent.secrets.yaml.example (1)

1-14: LGTM! Well-structured secrets example with helpful documentation.

The example file provides clear placeholders and includes helpful inline comments referencing the Langfuse documentation and the command for generating the basic auth token.

examples/cloud/mcp/README.md (1)

187-198: LGTM! Helpful Inspector configuration guidance.

The added documentation clearly outlines the required Inspector settings and includes a practical tip about adjusting request timeouts for LLM operations.

examples/cloud/observability/mcp_agent.config.yaml (1)

1-11: LGTM! Clean observability configuration.

The configuration properly enables OpenTelemetry with a descriptive service name and appropriately references the OTLP exporter configuration in the secrets file, maintaining good separation of concerns.

examples/cloud/observability/README.md (1)

1-159: LGTM! Comprehensive and well-structured documentation.

This README provides excellent guidance covering all necessary aspects: features, prerequisites, configuration, local testing, deployment, and debugging. The step-by-step instructions and examples make it easy for users to get started with the observability features.

examples/cloud/observability/main.py (1)

90-102: LGTM! Appropriate error handling for the example.

The try/except block properly catches exceptions during parallel LLM execution, logs errors via the context, and handles the case where no result is produced. This is suitable for a demonstration example.

@@ -0,0 +1,5 @@
# Core framework dependency
mcp-agent @ file://../../../ # Link to the local mcp-agent project root
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify the local dependency path format.

The format mcp-agent @ file://../../../ uses a relative path with the file:// scheme, which is non-standard. According to PEP 508, file:// URLs should typically use absolute paths. Standard alternatives include:

  • -e ../../../ (editable install with relative path)
  • file:///${PWD} (absolute path using environment variable)

Since you mentioned testing was successful, this may work in your environment. However, please verify it works consistently across different installation contexts (local, cloud deployment, CI/CD).


🏁 Script executed:

#!/bin/bash
# Verify the dependency can be installed correctly
cd examples/cloud/observability
python -m pip install --dry-run -r requirements.txt 2>&1 | grep -A5 -B5 "mcp-agent"

Length of output: 192


I need to verify if the mcp-agent package has the required packaging files at the repository root.


---

🏁 Script executed:

```shell
#!/bin/bash
# Check for setup.py and pyproject.toml at repository root
fd -d 1 '(setup\.py|pyproject\.toml)$' . 
echo "---"
# Also verify directory structure
ls -la | head -20

Length of output: 1229


I need to check the pyproject.toml to understand how the package is declared.


---

🏁 Script executed:

```shell
#!/bin/bash
# Check pyproject.toml for package name and structure
cat pyproject.toml | grep -A 10 "^\[project\]" | head -20
echo "---"
# Also check if there's any name field
grep -E '(name\s*=|version\s*=)' pyproject.toml | head -5

Length of output: 446



Fix the local dependency path format in examples/cloud/observability/requirements.txt.

The file://../../../ format with relative paths fails during installation: pip cannot resolve it and reports that pyproject.toml is not found, even though it exists at the repository root. This confirms the path format is non-standard and unreliable.

Replace with one of these standard alternatives:

  • -e ../../../ (editable install with relative path)
  • Absolute path using environment variable or full path with file:// scheme

Update line 2 to use a working format:

-e ../../../
🤖 Prompt for AI Agents
In examples/cloud/observability/requirements.txt around line 2, the dependency
uses a non-standard file://../../../ relative URL which pip cannot resolve;
replace that entry with the editable relative-path format -e ../../../ so pip
installs the local mcp-agent project correctly (or alternatively use an absolute
file:// path), and commit the updated requirements.txt.

@rholinshead rholinshead merged commit 6e75c15 into main Oct 29, 2025
7 of 8 checks passed
andrew-lastmile pushed a commit to andrew-lastmile/mcp-agent-fork that referenced this pull request Nov 4, 2025
* wip

* Clean up observability example + README

* Remove unnecessary filesystem mcp server

* Remove spurious comment in requirements

* Add activity/task to example
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.

3 participants