Content-Length: 674629 | pFad | https://github.com/mark3labs/mcp-go/commit/ae96a68a47e6ad255b8e976e89c30ac595139511

43 fix: update doc comments to match Go conventions (#226) · mark3labs/mcp-go@ae96a68 · GitHub
Skip to content

Commit ae96a68

Browse files
authored
fix: update doc comments to match Go conventions (#226)
1 parent df73667 commit ae96a68

File tree

7 files changed

+28
-23
lines changed

7 files changed

+28
-23
lines changed

client/transport/sse.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ func (c *SSE) SetNotificationHandler(handler func(notification mcp.JSONRPCNotifi
226226
c.onNotification = handler
227227
}
228228

229-
// sendRequest sends a JSON-RPC request to the server and waits for a response.
229+
// SendRequest sends a JSON-RPC request to the server and waits for a response.
230230
// Returns the raw JSON response message or an error if the request fails.
231231
func (c *SSE) SendRequest(
232232
ctx context.Context,

client/transport/stdio.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ func (c *Stdio) Close() error {
148148
return nil
149149
}
150150

151-
// OnNotification registers a handler function to be called when notifications are received.
152-
// Multiple handlers can be registered and will be called in the order they were added.
151+
// SetNotificationHandler sets the handler function to be called when a notification is received.
152+
// Only one handler can be set at a time; setting a new one replaces the previous handler.
153153
func (c *Stdio) SetNotificationHandler(
154154
handler func(notification mcp.JSONRPCNotification),
155155
) {
@@ -208,7 +208,7 @@ func (c *Stdio) readResponses() {
208208
}
209209
}
210210

211-
// sendRequest sends a JSON-RPC request to the server and waits for a response.
211+
// SendRequest sends a JSON-RPC request to the server and waits for a response.
212212
// It creates a unique request ID, sends the request over stdin, and waits for
213213
// the corresponding response or context cancellation.
214214
// Returns the raw JSON response message or an error if the request fails.

client/transport/streamable_http.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ const (
131131
headerKeySessionID = "Mcp-Session-Id"
132132
)
133133

134-
// sendRequest sends a JSON-RPC request to the server and waits for a response.
134+
// SendRequest sends a JSON-RPC request to the server and waits for a response.
135135
// Returns the raw JSON response message or an error if the request fails.
136136
func (c *StreamableHTTP) SendRequest(
137137
ctx context.Context,

mcp/types.go

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,53 +11,53 @@ import (
1111
type MCPMethod string
1212

1313
const (
14-
// Initiates connection and negotiates protocol capabilities.
14+
// MethodInitialize initiates connection and negotiates protocol capabilities.
1515
// https://modelcontextprotocol.io/specification/2024-11-05/basic/lifecycle/#initialization
1616
MethodInitialize MCPMethod = "initialize"
1717

18-
// Verifies connection liveness between client and server.
18+
// MethodPing verifies connection liveness between client and server.
1919
// https://modelcontextprotocol.io/specification/2024-11-05/basic/utilities/ping/
2020
MethodPing MCPMethod = "ping"
2121

22-
// Lists all available server resources.
22+
// MethodResourcesList lists all available server resources.
2323
// https://modelcontextprotocol.io/specification/2024-11-05/server/resources/
2424
MethodResourcesList MCPMethod = "resources/list"
2525

26-
// Provides URI templates for constructing resource URIs.
26+
// MethodResourcesTemplatesList provides URI templates for constructing resource URIs.
2727
// https://modelcontextprotocol.io/specification/2024-11-05/server/resources/
2828
MethodResourcesTemplatesList MCPMethod = "resources/templates/list"
2929

30-
// Retrieves content of a specific resource by URI.
30+
// MethodResourcesRead retrieves content of a specific resource by URI.
3131
// https://modelcontextprotocol.io/specification/2024-11-05/server/resources/
3232
MethodResourcesRead MCPMethod = "resources/read"
3333

34-
// Lists all available prompt templates.
34+
// MethodPromptsList lists all available prompt templates.
3535
// https://modelcontextprotocol.io/specification/2024-11-05/server/prompts/
3636
MethodPromptsList MCPMethod = "prompts/list"
3737

38-
// Retrieves a specific prompt template with filled parameters.
38+
// MethodPromptsGet retrieves a specific prompt template with filled parameters.
3939
// https://modelcontextprotocol.io/specification/2024-11-05/server/prompts/
4040
MethodPromptsGet MCPMethod = "prompts/get"
4141

42-
// Lists all available executable tools.
42+
// MethodToolsList lists all available executable tools.
4343
// https://modelcontextprotocol.io/specification/2024-11-05/server/tools/
4444
MethodToolsList MCPMethod = "tools/list"
4545

46-
// Invokes a specific tool with provided parameters.
46+
// MethodToolsCall invokes a specific tool with provided parameters.
4747
// https://modelcontextprotocol.io/specification/2024-11-05/server/tools/
4848
MethodToolsCall MCPMethod = "tools/call"
4949

50-
// Notifies when the list of available resources changes.
50+
// MethodNotificationResourcesListChanged notifies when the list of available resources changes.
5151
// https://modelcontextprotocol.io/specification/2025-03-26/server/resources#list-changed-notification
5252
MethodNotificationResourcesListChanged = "notifications/resources/list_changed"
5353

5454
MethodNotificationResourceUpdated = "notifications/resources/updated"
5555

56-
// Notifies when the list of available prompt templates changes.
56+
// MethodNotificationPromptsListChanged notifies when the list of available prompt templates changes.
5757
// https://modelcontextprotocol.io/specification/2025-03-26/server/prompts#list-changed-notification
5858
MethodNotificationPromptsListChanged = "notifications/prompts/list_changed"
5959

60-
// Notifies when the list of available tools changes.
60+
// MethodNotificationToolsListChanged notifies when the list of available tools changes.
6161
// https://spec.modelcontextprotocol.io/specification/2024-11-05/server/tools/list_changed/
6262
MethodNotificationToolsListChanged = "notifications/tools/list_changed"
6363
)
@@ -132,7 +132,7 @@ type NotificationParams struct {
132132
}
133133

134134
// MarshalJSON implements custom JSON marshaling
135-
func (p NotificationParams) MarshalJSON() ([]byte, error) {
135+
func (p *NotificationParams) MarshalJSON() ([]byte, error) {
136136
// Create a map to hold all fields
137137
m := make(map[string]interface{})
138138

@@ -863,7 +863,6 @@ type RootsListChangedNotification struct {
863863
Notification
864864
}
865865

866-
/* Client messages */
867866
// ClientRequest represents any request that can be sent from client to server.
868867
type ClientRequest interface{}
869868

@@ -873,7 +872,6 @@ type ClientNotification interface{}
873872
// ClientResult represents any result that can be sent from client to server.
874873
type ClientResult interface{}
875874

876-
/* Server messages */
877875
// ServerRequest represents any request that can be sent from server to client.
878876
type ServerRequest interface{}
879877

mcp/utils.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ func NewJSONRPCError(
125125
}
126126
}
127127

128+
// NewProgressNotification
128129
// Helper function for creating a progress notification
129130
func NewProgressNotification(
130131
token ProgressToken,
@@ -155,6 +156,7 @@ func NewProgressNotification(
155156
return notification
156157
}
157158

159+
// NewLoggingMessageNotification
158160
// Helper function for creating a logging message notification
159161
func NewLoggingMessageNotification(
160162
level LoggingLevel,
@@ -177,6 +179,7 @@ func NewLoggingMessageNotification(
177179
}
178180
}
179181

182+
// NewPromptMessage
180183
// Helper function to create a new PromptMessage
181184
func NewPromptMessage(role Role, content Content) PromptMessage {
182185
return PromptMessage{
@@ -185,6 +188,7 @@ func NewPromptMessage(role Role, content Content) PromptMessage {
185188
}
186189
}
187190

191+
// NewTextContent
188192
// Helper function to create a new TextContent
189193
func NewTextContent(text string) TextContent {
190194
return TextContent{
@@ -193,6 +197,7 @@ func NewTextContent(text string) TextContent {
193197
}
194198
}
195199

200+
// NewImageContent
196201
// Helper function to create a new ImageContent
197202
func NewImageContent(data, mimeType string) ImageContent {
198203
return ImageContent{
@@ -202,6 +207,7 @@ func NewImageContent(data, mimeType string) ImageContent {
202207
}
203208
}
204209

210+
// NewEmbeddedResource
205211
// Helper function to create a new EmbeddedResource
206212
func NewEmbeddedResource(resource ResourceContents) EmbeddedResource {
207213
return EmbeddedResource{
@@ -376,6 +382,7 @@ func NewInitializeResult(
376382
}
377383
}
378384

385+
// FormatNumberResult
379386
// Helper for formatting numbers in tool results
380387
func FormatNumberResult(value float64) *CallToolResult {
381388
return NewToolResultText(fmt.Sprintf("%.2f", value))

server/sse.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func WithBaseURL(baseURL string) SSEOption {
9696
}
9797
}
9898

99-
// Add a new option for setting base path
99+
// WithBasePath adds a new option for setting base path
100100
func WithBasePath(basePath string) SSEOption {
101101
return func(s *SSEServer) {
102102
// Ensure the path starts with / and doesn't end with /
@@ -150,7 +150,7 @@ func WithKeepAlive(keepAlive bool) SSEOption {
150150
}
151151
}
152152

153-
// WithContextFunc sets a function that will be called to customise the context
153+
// WithSSEContextFunc sets a function that will be called to customise the context
154154
// to the server using the incoming request.
155155
func WithSSEContextFunc(fn SSEContextFunc) SSEOption {
156156
return func(s *SSEServer) {

server/stdio.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func WithErrorLogger(logger *log.Logger) StdioOption {
4040
}
4141
}
4242

43-
// WithContextFunc sets a function that will be called to customise the context
43+
// WithStdioContextFunc sets a function that will be called to customise the context
4444
// to the server. Note that the stdio server uses the same context for all requests,
4545
// so this function will only be called once per server instance.
4646
func WithStdioContextFunc(fn StdioContextFunc) StdioOption {

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/mark3labs/mcp-go/commit/ae96a68a47e6ad255b8e976e89c30ac595139511

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy