Skip to content

feat: mcp composer integration#9506

Merged
jordanrfrazier merged 128 commits into
release-1.6.0from
mcp-composer-integration-v2
Sep 5, 2025
Merged

feat: mcp composer integration#9506
jordanrfrazier merged 128 commits into
release-1.6.0from
mcp-composer-integration-v2

Conversation

@jordanrfrazier
Copy link
Copy Markdown
Collaborator

@jordanrfrazier jordanrfrazier commented Aug 23, 2025

Adds mcp-composer integration when oauth is enabled

Summary by CodeRabbit

  • New Features

    • Per-project MCP Composer integration with automatic start/stop based on project authentication.
    • UI now fetches and uses a project-specific Composer SSE URL when available, with seamless fallback.
    • Automatic API key authentication for new projects when auto-login is disabled.
  • Improvements

    • Enhanced SSE URL handling with configurable host/port and optional WSL-friendly resolution.
    • Backend startup initializes the MCP Composer service for faster availability.
  • Configuration

    • New settings to enable/disable Composer and configure its host and base port.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Aug 23, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Adds per-project MCP Composer service and settings; integrates service startup; extends backend MCP project APIs to manage composer lifecycle and provide per-project SSE URL; adjusts project creation/update to auto-auth and start/stop composer on OAuth transitions; and updates frontend hooks/utilities/UI to consume composer URLs with fallback to direct SSE.

Changes

Cohort / File(s) Summary of changes
MCP Composer Service Introduction
src/backend/base/langflow/services/mcp_composer/__init__.py, .../mcp_composer/factory.py, .../mcp_composer/service.py
New service, factory, and exports to manage per-project MCP Composer processes: start/stop lifecycle, per-project port allocation, SSE URL tracking, and teardown.
Backend API: MCP Projects
src/backend/base/langflow/api/v1/mcp_projects.py
Adds helpers/endpoints to verify access, detect OAuth projects, start/register composer, fetch per-project composer URL; updates SSE URL handling, auth-driven composer lifecycle, WSL/external host handling; adjusts signatures and return types.
Backend API: Projects lifecycle
src/backend/base/langflow/api/v1/projects.py
Auto-applies API key auth when AUTO_LOGIN is false; on auth updates, starts/stops MCP Composer when switching to/from OAuth; integrates settings/service access and encryption.
App startup
src/backend/base/langflow/main.py
Starts MCP Composer service during app lifespan using service registry.
Service schema
src/backend/base/langflow/services/schema.py
Adds ServiceType.MCP_COMPOSER_SERVICE enum member.
Settings
src/backend/base/langflow/services/settings/base.py
Adds settings: mcp_composer_enabled, mcp_composer_port, mcp_composer_host.
Frontend: Composer URL hook
src/frontend/src/controllers/API/queries/mcp/use-get-composer-url.ts
New query hook to fetch per-project composer URL; returns project_id, sse_url, uses_composer; handles 400 fallback.
Frontend: Patch flows MCP
src/frontend/src/controllers/API/queries/mcp/use-patch-flows-mcp.ts
Extends response to include result with sse_url/uses_composer; updates cache to store/remove composer URL based on result.
Frontend: MCP URL utility
src/frontend/src/customization/utils/custom-mcp-url.ts
Updates helper to accept useComposer/composerUrl and prefer composer SSE URL when provided.
Frontend: MCP Server tab
src/frontend/src/pages/MainPage/pages/homePage/components/McpServerTab.tsx
Integrates composer URL hook and feature flag; selects per-project composer SSE URL when available; falls back to direct SSE.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Frontend
  participant Backend as Backend (API)
  participant Composer as MCP Composer Service

  rect rgba(230,240,255,0.5)
  note over Backend: App startup
  Backend->>Composer: start()
  Composer-->>Backend: ready
  end

  rect rgba(240,255,230,0.5)
  note over User,Frontend: Load MCP tab
  User->>Frontend: Open project
  Frontend->>Backend: GET /mcp/{project_id}/composer-url
  alt OAuth project with composer
    Backend->>Composer: get_or_start(project_id)
    Composer-->>Backend: sse_url, port
    Backend-->>Frontend: { sse_url, uses_composer: true }
    Frontend->>Frontend: use composer sse_url
  else Non-OAuth or disabled
    Backend-->>Frontend: 400 or { uses_composer: false }
    Frontend->>Frontend: fallback to direct SSE URL
  end
  end
Loading
sequenceDiagram
  autonumber
  actor Admin as User (updates auth)
  participant Backend as Backend (projects.update)
  participant Composer as MCP Composer Service

  Admin->>Backend: PATCH project auth_settings (auth_type)
  Backend->>Backend: detect transition
  alt Non-OAuth -> OAuth
    Backend->>Composer: register/start project composer
    Composer-->>Backend: sse_url
    Backend-->>Admin: result { sse_url, uses_composer: true }
  else OAuth -> Non-OAuth
    Backend->>Composer: stop_project_composer(project_id)
    Backend-->>Admin: result { sse_url: direct, uses_composer: false }
  else No change
    Backend-->>Admin: normal response
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

size:XXL, lgtm

Suggested reviewers

  • mfortman11
  • lucaseduoli
  • edwinjosechittilappilly
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch mcp-composer-integration-v2

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codeflash-ai
Copy link
Copy Markdown
Contributor

codeflash-ai Bot commented Sep 4, 2025

⚡️ Codeflash found optimizations for this PR

📄 65% (0.65x) speedup for encrypt_auth_settings in langflow/services/auth/mcp_encryption.py

⏱️ Runtime : 7.19 milliseconds 4.36 milliseconds (best of 29 runs)

I created a new dependent PR with the suggested changes. Please review:

If you approve, it will be merged into this PR (branch mcp-composer-integration-v2).

Copy link
Copy Markdown
Collaborator

@lucaseduoli lucaseduoli left a comment

Choose a reason for hiding this comment

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

LGTM

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Sep 4, 2025

Frontend Unit Test Coverage Report

Coverage Summary

Lines Statements Branches Functions
Coverage: 9%
9.55% (2493/26092) 3.89% (781/20073) 4.02% (226/5617)

Unit Test Results

Tests Skipped Failures Errors Time
820 0 💤 0 ❌ 0 🔥 15.392s ⏱️

@codecov
Copy link
Copy Markdown

codecov Bot commented Sep 4, 2025

Codecov Report

❌ Patch coverage is 23.26531% with 564 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release-1.6.0@3b7601f). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...end/base/langflow/services/mcp_composer/service.py 18.75% 247 Missing ⚠️
src/backend/base/langflow/api/v1/mcp_projects.py 18.36% 200 Missing ⚠️
src/backend/base/langflow/api/v1/projects.py 20.93% 34 Missing ⚠️
...ainPage/pages/homePage/components/McpServerTab.tsx 0.00% 31 Missing ⚠️
...ontrollers/API/queries/mcp/use-get-composer-url.ts 0.00% 12 Missing ⚠️
src/backend/base/langflow/api/v1/auth_helpers.py 69.69% 10 Missing ⚠️
src/backend/base/langflow/main.py 61.53% 10 Missing ⚠️
...controllers/API/queries/mcp/use-patch-flows-mcp.ts 0.00% 9 Missing ⚠️
...kend/base/langflow/services/auth/mcp_encryption.py 61.11% 7 Missing ⚠️
...frontend/src/customization/utils/custom-mcp-url.ts 0.00% 4 Missing ⚠️

❌ Your patch status has failed because the patch coverage (23.26%) is below the target coverage (40.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@               Coverage Diff                @@
##             release-1.6.0    #9506   +/-   ##
================================================
  Coverage                 ?   35.67%           
================================================
  Files                    ?     1217           
  Lines                    ?    57843           
  Branches                 ?     5493           
================================================
  Hits                     ?    20636           
  Misses                   ?    37046           
  Partials                 ?      161           
Flag Coverage Δ
backend 55.56% <25.18%> (?)
frontend 8.77% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...end/base/langflow/services/mcp_composer/factory.py 100.00% <100.00%> (ø)
src/backend/base/langflow/services/schema.py 100.00% <100.00%> (ø)
...rc/backend/base/langflow/services/settings/base.py 78.89% <100.00%> (ø)
...d/base/langflow/services/settings/feature_flags.py 100.00% <ø> (ø)
src/frontend/src/customization/feature-flags.ts 100.00% <ø> (ø)
...frontend/src/customization/utils/custom-mcp-url.ts 0.00% <0.00%> (ø)
...kend/base/langflow/services/auth/mcp_encryption.py 83.05% <61.11%> (ø)
...controllers/API/queries/mcp/use-patch-flows-mcp.ts 0.00% <0.00%> (ø)
src/backend/base/langflow/api/v1/auth_helpers.py 69.69% <69.69%> (ø)
src/backend/base/langflow/main.py 65.10% <61.53%> (ø)
... and 5 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Sep 4, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
8 Security Hotspots
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants