@@ -25,9 +25,9 @@ func NewRemoteMCPClient(config catalog.ServerConfig) Client {
2525 }
2626}
2727
28- func (c * remoteMCPClient ) Initialize (ctx context.Context , _ * mcp.InitializeParams , _ bool , _ * mcp.ServerSession ) ( * mcp. InitializeResult , error ) {
28+ func (c * remoteMCPClient ) Initialize (ctx context.Context , _ * mcp.InitializeParams , _ bool , _ * mcp.ServerSession ) error {
2929 if c .initialized .Load () {
30- return nil , fmt .Errorf ("client already initialized" )
30+ return fmt .Errorf ("client already initialized" )
3131 }
3232
3333 // Read configuration.
@@ -67,7 +67,7 @@ func (c *remoteMCPClient) Initialize(ctx context.Context, _ *mcp.InitializeParam
6767 // TODO: Need to implement custom HTTP client with headers for streaming
6868 mcpTransport = mcp .NewStreamableClientTransport (url , & mcp.StreamableClientTransportOptions {})
6969 default :
70- return nil , fmt .Errorf ("unsupported remote transport: %s" , transport )
70+ return fmt .Errorf ("unsupported remote transport: %s" , transport )
7171 }
7272
7373 c .client = mcp .NewClient (& mcp.Implementation {
@@ -77,79 +77,17 @@ func (c *remoteMCPClient) Initialize(ctx context.Context, _ *mcp.InitializeParam
7777
7878 session , err := c .client .Connect (ctx , mcpTransport )
7979 if err != nil {
80- return nil , fmt .Errorf ("failed to connect: %w" , err )
80+ return fmt .Errorf ("failed to connect: %w" , err )
8181 }
8282
8383 c .session = session
8484 c .initialized .Store (true )
8585
86- // The Connect method handles initialization automatically in the new SDK
87- return & mcp.InitializeResult {
88- ProtocolVersion : "2024-11-05" ,
89- ServerInfo : & mcp.Implementation {
90- Name : "docker-mcp-gateway" ,
91- Version : "1.0.0" ,
92- },
93- // Capabilities field is private and will be set by the SDK
94- }, nil
95- }
96-
97- func (c * remoteMCPClient ) ListTools (ctx context.Context , params * mcp.ListToolsParams ) (* mcp.ListToolsResult , error ) {
98- if ! c .initialized .Load () {
99- return nil , fmt .Errorf ("client not initialized" )
100- }
101- return c .session .ListTools (ctx , params )
102- }
103-
104- func (c * remoteMCPClient ) ListPrompts (ctx context.Context , params * mcp.ListPromptsParams ) (* mcp.ListPromptsResult , error ) {
105- if ! c .initialized .Load () {
106- return nil , fmt .Errorf ("client not initialized" )
107- }
108- return c .session .ListPrompts (ctx , params )
109- }
110-
111- func (c * remoteMCPClient ) ListResources (ctx context.Context , params * mcp.ListResourcesParams ) (* mcp.ListResourcesResult , error ) {
112- if ! c .initialized .Load () {
113- return nil , fmt .Errorf ("client not initialized" )
114- }
115- return c .session .ListResources (ctx , params )
116- }
117-
118- func (c * remoteMCPClient ) ListResourceTemplates (ctx context.Context , params * mcp.ListResourceTemplatesParams ) (* mcp.ListResourceTemplatesResult , error ) {
119- if ! c .initialized .Load () {
120- return nil , fmt .Errorf ("client not initialized" )
121- }
122- return c .session .ListResourceTemplates (ctx , params )
123- }
124-
125- func (c * remoteMCPClient ) CallTool (ctx context.Context , params * mcp.CallToolParams ) (* mcp.CallToolResult , error ) {
126- if ! c .initialized .Load () {
127- return nil , fmt .Errorf ("client not initialized" )
128- }
129- return c .session .CallTool (ctx , params )
130- }
131-
132- func (c * remoteMCPClient ) GetPrompt (ctx context.Context , params * mcp.GetPromptParams ) (* mcp.GetPromptResult , error ) {
133- if ! c .initialized .Load () {
134- return nil , fmt .Errorf ("client not initialized" )
135- }
136- return c .session .GetPrompt (ctx , params )
137- }
138-
139- func (c * remoteMCPClient ) ReadResource (ctx context.Context , params * mcp.ReadResourceParams ) (* mcp.ReadResourceResult , error ) {
140- if ! c .initialized .Load () {
141- return nil , fmt .Errorf ("client not initialized" )
142- }
143- return c .session .ReadResource (ctx , params )
144- }
145-
146- func (c * remoteMCPClient ) Close () error {
147- if c .session != nil {
148- return c .session .Close ()
149- }
15086 return nil
15187}
15288
89+ func (c * remoteMCPClient ) Session () * mcp.ClientSession {return c .session }
90+
15391func expandEnv (value string , secrets map [string ]string ) string {
15492 return os .Expand (value , func (name string ) string {
15593 return secrets [name ]
0 commit comments