-
-
Notifications
You must be signed in to change notification settings - Fork 166
feat: integrate tool fetching and calling with SSE transport #145
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
Reviewer's GuideThis PR integrates support for fetching and invoking backend tools over SSE in the MCP gateway scenario by retrieving the SSE transport from server state and delegating tool operations to it with proper error handling. Sequence Diagram for Fetching Tools via SSE TransportsequenceDiagram
actor User
participant MCPGateway
participant State
participant SSETransport
participant BackendServiceSSE
User->>MCPGateway: MCP Request (method: tools/list, protocol: SSE)
MCPGateway->>State: GetTransport(conn.Meta().Prefix)
State-->>MCPGateway: transport (SSETransport instance)
alt transport is available
MCPGateway->>SSETransport: FetchTools(context)
activate SSETransport
SSETransport->>BackendServiceSSE: Fetch tools over SSE
BackendServiceSSE-->>SSETransport: Tools data
deactivate SSETransport
SSETransport-->>MCPGateway: tools
MCPGateway-->>User: MCP Response (tools)
else transport is nil OR FetchTools fails
MCPGateway-->>User: MCP Response (Error: Failed to fetch tools)
end
Sequence Diagram for Calling a Tool via SSE TransportsequenceDiagram
actor User
participant MCPGateway
participant State
participant SSETransport
participant BackendServiceSSE
User->>MCPGateway: MCP Request (method: tools/call, params, protocol: SSE)
MCPGateway->>State: GetTransport(conn.Meta().Prefix)
State-->>MCPGateway: transport (SSETransport instance)
alt transport is available
MCPGateway->>SSETransport: CallTool(context, params, requestInfo)
activate SSETransport
SSETransport->>BackendServiceSSE: Execute tool over SSE with params
BackendServiceSSE-->>SSETransport: Tool result
deactivate SSETransport
SSETransport-->>MCPGateway: result
MCPGateway-->>User: MCP Response (result)
else transport is nil OR CallTool fails
MCPGateway-->>User: MCP Response (Error: Tool execution error or config not found)
end
Class Diagram: Server Interaction with SSE TransportclassDiagram
class Server {
+state: State
+handleMCPRequest(c gin.Context, req mcp.JSONRPCRequest, conn session.Conn)
}
class State {
+GetTransport(prefix string) Transport
}
class Transport {
<<Interface>>
+FetchTools(ctx context.Context) []Tool
+CallTool(ctx context.Context, params any, reqInfo any) any
}
class SSETransport {
+FetchTools(ctx context.Context) []Tool
+CallTool(ctx context.Context, params any, reqInfo any) any
}
Server o-- State : uses
State ..> Transport : provides
Transport <|.. SSETransport : implements
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
支持在网关采用 MCP 协议、后端服务使用 SSE 协议的场景下,实现对后端工具的获取与调用功能。
Summary by Sourcery
Add support for fetching and invoking backend tools over SSE transport in the MCP server.
New Features: