Alanxtl commented on code in PR #702:
URL: https://github.com/apache/dubbo-go-pixiu/pull/702#discussion_r2254272336


##########
pkg/filter/mcp/mcpserver/context.go:
##########
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package mcpserver
+
+import (
+       "github.com/mark3labs/mcp-go/mcp"
+)
+
+import (
+       "github.com/apache/dubbo-go-pixiu/pkg/common/constant"
+       h "github.com/apache/dubbo-go-pixiu/pkg/context/http"
+)
+
+const MCPDataKey = "mcp_data"
+
+// MCPData stores MCP-related data
+type MCPData struct {
+       // Method stores MCP method name
+       Method string
+       // RequestID stores JSON-RPC request ID
+       RequestID any
+}
+
+// MCPContext MCP context wrapper that composes HttpContext and provides 
MCP-specific operations
+type MCPContext struct {
+       *h.HttpContext
+       mcpData *MCPData
+}
+
+// NewMCPContext creates a new MCP context
+func NewMCPContext(httpCtx *h.HttpContext) *MCPContext {
+       return &MCPContext{
+               HttpContext: httpCtx,
+               mcpData:     &MCPData{},
+       }
+}
+
+// IsMCPRequest checks if it's an MCP request (by method name)
+func (ctx *MCPContext) IsMCPRequest() bool {
+       return ctx.mcpData.Method != ""
+}
+
+// SetMCPMethod sets MCP method name
+func (ctx *MCPContext) SetMCPMethod(method string) {
+       ctx.mcpData.Method = method
+}
+
+// GetMCPMethod gets MCP method name
+func (ctx *MCPContext) GetMCPMethod() string {
+       return ctx.mcpData.Method
+}

Review Comment:
   suggest don't put "get" in the getter's name
   
   ```suggestion
   // MCPMethod gets MCP method name
   func (ctx *MCPContext) MCPMethod() string {
        return ctx.mcpData.Method
   }
   ```
   
   ref: https://go.dev/doc/effective_go
   
   > Go doesn't provide automatic support for getters and setters. There's 
nothing wrong with providing getters and setters yourself, and it's often 
appropriate to do so, but it's neither idiomatic nor necessary to put Get into 
the getter's name. If you have a field called owner (lower case, unexported), 
the getter method should be called Owner (upper case, exported), not GetOwner. 
The use of upper-case names for export provides the hook to discriminate the 
field from the method. A setter function, if needed, will likely be called 
SetOwner. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to