Skip to content

Conversation

@michiosw
Copy link
Contributor

@michiosw michiosw commented Apr 8, 2025

No description provided.

@michiosw michiosw linked an issue Apr 8, 2025 that may be closed by this pull request
7 tasks
@michiosw michiosw force-pushed the 3-mcp-server-sse-and-tool-endpoints branch from 6e93684 to 6c9d453 Compare April 8, 2025 22:46
@github-actions
Copy link

github-actions bot commented Apr 8, 2025

🦙 MegaLinter status: ⚠️ WARNING

Descriptor Linter Files Fixed Errors Elapsed time
✅ ACTION actionlint 1 0 0.07s
✅ API spectral 1 0 2.37s
⚠️ COPYPASTE jscpd yes 5 3.08s
⚠️ GO revive 21 1 70.21s
⚠️ MARKDOWN markdownlint 1 0 2 3.9s
✅ MARKDOWN markdown-link-check 1 0 5.11s
✅ MARKDOWN markdown-table-formatter 1 1 0 2.26s
✅ REPOSITORY checkov yes no 18.34s
⚠️ REPOSITORY devskim yes 48 1.21s
✅ REPOSITORY dustilock yes no 0.02s
✅ REPOSITORY gitleaks yes no 0.18s
✅ REPOSITORY git_diff yes no 0.01s
✅ REPOSITORY grype yes no 19.73s
✅ REPOSITORY kics yes no 17.08s
✅ REPOSITORY secretlint yes no 0.73s
✅ REPOSITORY syft yes no 1.35s
✅ REPOSITORY trivy yes no 5.14s
✅ REPOSITORY trivy-sbom yes no 0.07s
✅ REPOSITORY trufflehog yes no 3.1s
✅ YAML prettier 3 3 0 5.19s
✅ YAML v8r 3 0 24.88s
✅ YAML yamllint 3 0 4.0s

See detailed report in MegaLinter reports
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security

- Added SQLite database support for managing MCP servers and tools.
- Introduced event bus for handling server addition, removal, and tool updates.
- Created backend service for CRUD operations on MCP servers.
- Implemented updater service for periodic polling of MCP servers and fetching tools.
- Added API handlers for managing MCP servers and exporting configuration.
- Included tests for backend service and database interactions.

This commit establishes the foundational architecture for the agent-browser application, enabling dynamic management of MCP servers and their associated tools.
@michiosw michiosw self-assigned this Apr 11, 2025
@michiosw michiosw force-pushed the 3-mcp-server-sse-and-tool-endpoints branch 2 times, most recently from eb1ef7c to e5e22ec Compare April 12, 2025 19:23
Implements MCP server with hello_world tool and client with multi-server connection support
- Add MCP server proxy that aggregates tools from remote servers
- Implement transparent proxying of tool calls to remote servers
- Copy tool schemas and parameters correctly from remote tools
- Set SSE read timeout to 1200 seconds for long-running operations
- Remove complex reconnection logic in favor of native SSE persistence

The MCP server now acts as a proxy that:
1. Connects to configured remote MCP servers
2. Aggregates their available tools
3. Exposes these tools locally with proper parameter schemas
4. Proxies tool calls to the appropriate remote server

Additionally, fixes SSE connection stability by properly configuring
timeouts and trusting the protocol's built-in persistence, rather than
implementing custom reconnection logic.
- Health monitoring (30s) & auto-recovery with exp backoff
- Smart tool management based on server state
- Continues operation during remote failures
- Moved to config.go with fx integration
- Consolidated to NewMCPComponents

Breaking: NewMCPServer/SSEServer -> NewMCPComponents
- Verify connection health before reuse with ListTools
- Use existing session context for health checks
- Add debug logging for health check failures
@michiosw michiosw force-pushed the 3-mcp-server-sse-and-tool-endpoints branch from e5e22ec to 0fce5e7 Compare April 12, 2025 19:36
Refactor the MCP ConnectionManager to subscribe to backend events (ServerAdded, ServerRemoved) instead of polling the API for server lists.

Introduce internal state (`permanentlyRemoved`) to correctly handle explicit server removal and prevent background reconnection goroutines from interfering.

Add and publish a new `ServerStatusChangedEvent` from the backend service (`UpdateMCPServerStatus`) when a server's connection status is updated in the database. This allows listeners (e.g., UI components) to react directly to connectivity changes.
@michiosw michiosw force-pushed the 3-mcp-server-sse-and-tool-endpoints branch from 6a6cd63 to a8f5c03 Compare April 14, 2025 21:53
Removes the API client dependency from ConnectionManager.

ConnectionManager now publishes ServerStatusChanged and ToolsUpdated
events directly to the event bus instead of calling back into the Web API.

BackendService subscribes to these events to handle DB updates.

InitModule now publishes ServerAddedEvent for existing servers at startup
to ensure ConnectionManager connects to them.
- Performs cleanup (cancel/close) of old MCP connections asynchronously in a separate goroutine within `connectToRemoteServer` to prevent interference with newly established connections. This resolves the immediate context cancellation and rapid reconnect loop observed previously.
- Defines `ToolsProcessedInDBEvent` triggered by `BackendService` after successfully processing tools from a `ToolsUpdatedEvent`.
- `ConnectionManager` now subscribes to `ToolsProcessedInDBEvent` and calls `refreshMCPServerTools` only upon receiving this event, decoupling the internal MCP server tool update from the database update process.
- Removes the direct call to `refreshMCPServerTools` from `updateServerTools` in `ConnectionManager`.
@michiosw michiosw requested a review from Copilot April 15, 2025 18:39
@michiosw michiosw requested a review from maceip April 15, 2025 18:39
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 29 out of 31 changed files in this pull request and generated 1 comment.

Files not reviewed (2)
  • Makefile: Language not supported
  • go.mod: Language not supported
Comments suppressed due to low confidence (1)

internal/config/exporter_test.go:64

  • The test 'TestGenerateConfigJSON' is currently skipped. Consider adding tests to cover the configuration export functionality to ensure that the exported JSON meets the expected structure and content.
t.Skip("Skipping due to issue with backend.Service interface")

{
name: "Local Test Server",
url: "http://0.0.0.0:8001/sse",
description: "Local MCP test server",
Copy link

Copilot AI Apr 15, 2025

Choose a reason for hiding this comment

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

In InitModule, a default server is added with a 'description' field, but the exported configuration only includes name and URL. Consider aligning the default server structure with the ExportedServer type or updating the export logic to include the description if needed.

Copilot uses AI. Check for mistakes.
@maceip maceip merged commit 36c9abc into main Apr 15, 2025
2 checks passed
@michiosw
Copy link
Contributor Author

🎉 This PR is included in version 1.1.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@michiosw michiosw deleted the 3-mcp-server-sse-and-tool-endpoints branch April 15, 2025 18:49
@michiosw
Copy link
Contributor Author

🎉 This PR is included in version 1.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP Server – SSE and Tool Endpoints

4 participants