8000 Refactor/update mcp spec by elvankonukseven · Pull Request #102 · llm4s/llm4s · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Refactor/update mcp spec #102

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

Merged
merged 4 commits into from
Jul 15, 2025

Conversation

elvankonukseven
Copy link
Contributor
@elvankonukseven elvankonukseven commented Jul 12, 2025

This PR aims to update the MCP connector with the latest spec (2025-06-18) with Streamable HTTP Transport Protocol:

Summary

Adds complete MCP (Model Context Protocol) server and client implementation supporting the latest 2025-06-18 Streamable HTTP specification with automatic fallback to legacy protocols.

Key Changes

-New Transport Protocol: Implements Streamable HTTP (2025-06-18) with single endpoint, session management, and protocol headers

-Automatic Fallback: Seamless fallback from 2025-06-18 to 2024-11-05 HTTP+SSE when servers don't support newer protocol

-Session Management: Server-generated sessions with mcp-session-id headers for stateful operations

-Protocol Compliance: Supports 2025-06-18, 2025-03-26, and 2024-11-05 specifications with proper JSON-RPC 2.0 handling

The examples have also been adapted to the new spec.

Fixes elvankonukseven/GSoC-Progress-Tracker#6

@rorygraves
Copy link
Collaborator

@elvankonukseven See the notes on scalafmt and githooks in the readme. - the CI test is vailaing

@rorygraves
Copy link
Collaborator

AI Generated:

PR #102 Review: MCP Spec Update to 2025-06-18

Summary

This PR updates the MCP (Model Context Protocol) implementation to support the latest 2025-06-18 Streamable HTTP specification with automatic fallback to legacy protocols. It's a significant
architectural improvement that enhances compatibility and future-proofs the MCP integration.

Key Strengths ✅

  1. Modern Protocol Support: Implements the latest 2025-06-18 Streamable HTTP specification with proper session management and protocol headers.
  2. Backward Compatibility: Intelligent fallback mechanism from 2025-06-18 → 2025-03-26 → 2024-11-05 ensures compatibility with existing servers.
  3. Enhanced Transport Architecture:
    - Single /mcp endpoint supporting POST, GET, DELETE methods
    - Server-generated session management with mcp-session-id headers
    - Proper HTTP status code handling (405, 404 detection)
  4. Improved Tool Output: Structured content with resource references and annotations (following PRs #371 and #603).
  5. Better Error Handling: Comprehensive MCP-specific error codes and proper JSON-RPC 2.0 compliance.

Technical Highlights 🔧

  • Smart Transport Selection: tryHttpTransportWithFallback() automatically detects server capabilities
  • Session Lifecycle: Proper session creation, management, and cleanup via DELETE requests
  • Content Negotiation: Supports both application/json and text/event-stream responses
  • Resource References: Tool results can now include structured resource links

Areas for Improvement 📋

  1. Test Coverage: No visible unit tests for the new transport protocols and fallback logic.
  2. Documentation: While the examples are updated, more comprehensive documentation on the protocol differences would be helpful.
  3. Error Recovery: Could benefit from more robust session recovery mechanisms for network interruptions.
  4. Performance: The fallback mechanism involves making two requests on failure - consider caching server capabilities.

Code Quality Assessment

  • Architecture: Well-structured with clear separation of concerns
  • Error Handling: Comprehensive error codes and proper JSON-RPC compliance
  • Logging: Good logging throughout for debugging and monitoring
  • Style: Follows existing Scala conventions and patterns

Recommendation: ✅ APPROVE

This is a high-quality PR that significantly improves the MCP implementation. The automatic fallback mechanism ensures smooth migration while providing access to the latest protocol features.
The code is well-structured and maintains backward compatibility.

Suggested next steps:

  1. Add unit tests for the new transport protocols
  2. Consider adding integration tests for the fallback mechanism
  3. Update documentation to explain the protocol selection process

The PR is ready for merge pending any CI checks and team review.


I think this assessment is pretty good. Please reformat so the CI passes and then we can merge and decide on whether we need tests here right now.

@elvankonukseven
Copy link
Contributor Author

Thanks for your review @rorygraves ! Please let me know if any other changes are needed :)

@elvankonukseven elvankonukseven marked this pull request as ready for review July 14, 2025 15:19
@rorygraves rorygraves merged commit 769e985 into llm4s:main Jul 15, 2025
2 checks passed
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.

Change MCP connector's spec to latest one
2 participants
0