feat: Implement SSE endpoint for Cursor compatibility
This commit introduces a Server-Sent Events (SSE) endpoint at `/mcp/stream`
to improve compatibility with Cursor, which appears to expect an SSE stream
for actions like `ListOfferings`.
Changes include:
- Added a new `/mcp/stream` route to `mcp_server.py`.
- This stream sends an initial "connected" event.
- It then attempts to fetch and stream Basecamp projects as "offering" events.
- Handles authentication errors (e.g., missing tokens) by sending an
`auth_error` event over SSE.
- Sends an "offerings_complete" event after successfully streaming projects.
- The stream sends periodic "ping" events to keep the connection alive.
- The `Content-Type` header for `/mcp/stream` is correctly set to
`text/event-stream`.
- Updated `README.md` to suggest the new `/mcp/stream` URL for Cursor
configuration and provide context.
Issue #3 (regarding refactoring BasecampClient initialization) was
investigated. The existing `get_basecamp_client()` in `mcp_server.py`,
which includes token refresh logic, was found to be more suitable than
alternatives in `mcp_integration.py` or `composio_integration.py`.
No code changes were made for Issue #3.
Testing with `curl` confirmed the SSE endpoint's functionality,
including correct event flow and error handling.
This commit is contained in:
@@ -75,9 +75,11 @@ The project consists of the following components:
|
||||
|
||||
### Using with Cursor
|
||||
|
||||
1. In Cursor, add the MCP server URL: http://localhost:5001
|
||||
2. Interact with Basecamp through the Cursor interface
|
||||
3. The MCP server will use the stored OAuth token to authenticate with Basecamp
|
||||
1. In Cursor, add the MCP server URL: `http://localhost:5001/mcp/stream`
|
||||
- **Note:** This URL points to the new Server-Sent Events (SSE) endpoint. Cursor may prefer this for real-time updates and for features like `ListOfferings` that stream data.
|
||||
- If you encounter issues, Cursor might alternatively try to use the base URL (`http://localhost:5001`) to first query `/mcp/info` (to discover available actions and endpoints) and then connect to the appropriate endpoint as indicated there.
|
||||
2. Interact with Basecamp through the Cursor interface.
|
||||
3. The MCP server will use the stored OAuth token to authenticate with Basecamp.
|
||||
|
||||
### Authentication Flow
|
||||
|
||||
|
||||
Reference in New Issue
Block a user