[PR #6] [MERGED] Fix issue #4: Ensure headers are properly sent in SSE connections #32

Closed
opened 2026-02-16 08:17:21 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/langchainjs-mcp-adapters/pull/6
Author: @vrknetha
Created: 3/8/2025
Status: Merged
Merged: 3/8/2025
Merged by: @vrknetha

Base: mainHead: bugfix/sse-headers-issue


📝 Commits (7)

  • 050886c Fix issue #4: Ensure headers are properly sent in SSE connections
  • 2a3d6b7 Update package-lock.json for SSE headers fix
  • b46cb6c Fix issue #4 and increase test coverage to 80%
  • fd33e9a Update package-lock.json for extended-eventsource dependency
  • 02440e5 Update MultiServerMCPClient with improved test coverage and ESLint configuration
  • 0cf4b11 Remove unused imports from example files
  • 8f03e30 Fix agent-integration test for GitHub Actions by adding type assertion

📊 Changes

11 files changed (+1561 additions, -307 deletions)

View changed files

📝 README.md (+58 -0)
📝 __tests__/agent-integration.test.ts (+1 -0)
📝 __tests__/client.test.ts (+249 -53)
📝 eslint.config.mjs (+34 -29)
📝 examples/agent_example.ts (+12 -20)
📝 examples/gemini_agent_example.ts (+10 -4)
📝 examples/react_agent_bug_test.ts (+9 -4)
📝 examples/sse_with_headers_example.ts (+82 -99)
📝 package-lock.json (+1013 -69)
📝 package.json (+11 -6)
📝 src/client.ts (+82 -23)

📄 Description

This PR addresses issue #4 where custom headers were not being properly sent in SSE connections.

Changes Made

  1. Enhanced the SSE connection implementation to properly send headers:

    • Added support for the extended-eventsource library (better headers handling)
    • Improved fallback to standard eventsource with proper header configuration
    • Fixed header passing in both Node.js and browser environments
  2. Added comprehensive documentation:

    • Updated README with detailed information about SSE headers support
    • Added examples showing best practices for different environments
  3. Improved example file (sse_with_headers_example.ts) demonstrating different approaches:

    • Node.js with extended-eventsource (recommended approach)
    • Browser with query parameters
    • Browser with server-side proxy (best practice)
  4. Updated dependencies:

    • Added extended-eventsource as an optional dependency

Testing

Tested the implementation using both standard eventsource and extended-eventsource to ensure headers are correctly passed in SSE connections.

Fixes #4


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/langchainjs-mcp-adapters/pull/6 **Author:** [@vrknetha](https://github.com/vrknetha) **Created:** 3/8/2025 **Status:** ✅ Merged **Merged:** 3/8/2025 **Merged by:** [@vrknetha](https://github.com/vrknetha) **Base:** `main` ← **Head:** `bugfix/sse-headers-issue` --- ### 📝 Commits (7) - [`050886c`](https://github.com/langchain-ai/langchainjs-mcp-adapters/commit/050886c0b763ca076c7b4d336e6730d7a696ccd9) Fix issue #4: Ensure headers are properly sent in SSE connections - [`2a3d6b7`](https://github.com/langchain-ai/langchainjs-mcp-adapters/commit/2a3d6b76b4bd936f907b1a3e843640e26cad5024) Update package-lock.json for SSE headers fix - [`b46cb6c`](https://github.com/langchain-ai/langchainjs-mcp-adapters/commit/b46cb6caba62c258a9222048c768f113a0a9add6) Fix issue #4 and increase test coverage to 80% - [`fd33e9a`](https://github.com/langchain-ai/langchainjs-mcp-adapters/commit/fd33e9adeabd4337bf013722e3d00f542010318e) Update package-lock.json for extended-eventsource dependency - [`02440e5`](https://github.com/langchain-ai/langchainjs-mcp-adapters/commit/02440e59faa618434333a34f87a5b2389bb50cf2) Update MultiServerMCPClient with improved test coverage and ESLint configuration - [`0cf4b11`](https://github.com/langchain-ai/langchainjs-mcp-adapters/commit/0cf4b11e61f8599a3fa932327d36a9447c65fd61) Remove unused imports from example files - [`8f03e30`](https://github.com/langchain-ai/langchainjs-mcp-adapters/commit/8f03e30f169df10a2e0155fd00af92873a07f7b6) Fix agent-integration test for GitHub Actions by adding type assertion ### 📊 Changes **11 files changed** (+1561 additions, -307 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+58 -0) 📝 `__tests__/agent-integration.test.ts` (+1 -0) 📝 `__tests__/client.test.ts` (+249 -53) 📝 `eslint.config.mjs` (+34 -29) 📝 `examples/agent_example.ts` (+12 -20) 📝 `examples/gemini_agent_example.ts` (+10 -4) 📝 `examples/react_agent_bug_test.ts` (+9 -4) 📝 `examples/sse_with_headers_example.ts` (+82 -99) 📝 `package-lock.json` (+1013 -69) 📝 `package.json` (+11 -6) 📝 `src/client.ts` (+82 -23) </details> ### 📄 Description This PR addresses issue #4 where custom headers were not being properly sent in SSE connections. ## Changes Made 1. Enhanced the SSE connection implementation to properly send headers: - Added support for the extended-eventsource library (better headers handling) - Improved fallback to standard eventsource with proper header configuration - Fixed header passing in both Node.js and browser environments 2. Added comprehensive documentation: - Updated README with detailed information about SSE headers support - Added examples showing best practices for different environments 3. Improved example file (sse_with_headers_example.ts) demonstrating different approaches: - Node.js with extended-eventsource (recommended approach) - Browser with query parameters - Browser with server-side proxy (best practice) 4. Updated dependencies: - Added extended-eventsource as an optional dependency ## Testing Tested the implementation using both standard eventsource and extended-eventsource to ensure headers are correctly passed in SSE connections. Fixes #4 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 08:17:21 -05:00
yindo closed this issue 2026-02-16 08:17:21 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langchainjs-mcp-adapters#32