Skip to content

Commit a81e28c

Browse files
committed
reviewer comments
1 parent 22308c4 commit a81e28c

File tree

2 files changed

+40
-34
lines changed

2 files changed

+40
-34
lines changed

docs/server.md

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -114,23 +114,6 @@ MCP servers can serve resources to clients.
114114
They can register resources individually, or register a _resource template_
115115
that uses a URI pattern to describe a collection of resources.
116116

117-
**Server-side**:
118-
Servers use
119-
[`Server.AddResource`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/mcp#Server.AddResource)
120-
and
121-
[`Server.AddResourceTemplate`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/mcp#Server.AddResourceTemplate)
122-
to register resources and resource templates and associate them with handlers.
123-
If `AddResource` or `AddResourceTemplate` is called before a server is connected, the server will have the
124-
`resources` capability.
125-
If all resources or resource templates are to be added after connection, set
126-
[`ServerOptions.HasResources`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/mcp#ServerOptions.HasResources)
127-
to advertise the capability.
128-
129-
A
130-
[`ResourceHandler`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/mcp#ResourceHandler)
131-
maps a URI to the contents of a resource, which can include text, binary data,
132-
or both.
133-
134117

135118
**Client-side**:
136119
Call [`ClientSession.ReadResource`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/mcp#ClientSession.ReadResource)
@@ -158,6 +141,26 @@ Set
158141
[`ClientOptions.ResourceUpdatedHandler`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/mcp#ClientOptions.ResourceUpdatedHandler)
159142
to be notified of changes to subscribed resources.
160143

144+
**Server-side**:
145+
Use
146+
[`Server.AddResource`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/mcp#Server.AddResource)
147+
or
148+
[`Server.AddResourceTemplate`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/mcp#Server.AddResourceTemplate)
149+
to add a resource or resource template to the server along with its handler.
150+
A
151+
[`ResourceHandler`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/mcp#ResourceHandler)
152+
maps a URI to the contents of a resource, which can include text, binary data,
153+
or both.
154+
If `AddResource` or `AddResourceTemplate` is called before a server is connected, the server will have the
155+
`resources` capability.
156+
The server will have the `resources` capability if any resource or resource template is added before the
157+
server is connected to a client, or if
158+
[`ServerOptions.HasResources`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/mcp#ServerOptions.HasResources)
159+
is explicitly set. When a prompt is added, any clients already connected to the
160+
server will be notified via a `notifications/resources/list_changed`
161+
notification.
162+
163+
161164
```go
162165
func Example_resources() {
163166
ctx := context.Background()

internal/docs/server.src.md

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,6 @@ MCP servers can serve resources to clients.
4040
They can register resources individually, or register a _resource template_
4141
that uses a URI pattern to describe a collection of resources.
4242

43-
**Server-side**:
44-
Servers use
45-
[`Server.AddResource`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/mcp#Server.AddResource)
46-
and
47-
[`Server.AddResourceTemplate`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/mcp#Server.AddResourceTemplate)
48-
to register resources and resource templates and associate them with handlers.
49-
If `AddResource` or `AddResourceTemplate` is called before a server is connected, the server will have the
50-
`resources` capability.
51-
If all resources or resource templates are to be added after connection, set
52-
[`ServerOptions.HasResources`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/mcp#ServerOptions.HasResources)
53-
to advertise the capability.
54-
55-
A
56-
[`ResourceHandler`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/mcp#ResourceHandler)
57-
maps a URI to the contents of a resource, which can include text, binary data,
58-
or both.
59-
6043

6144
**Client-side**:
6245
Call [`ClientSession.ReadResource`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/mcp#ClientSession.ReadResource)
@@ -84,6 +67,26 @@ Set
8467
[`ClientOptions.ResourceUpdatedHandler`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/mcp#ClientOptions.ResourceUpdatedHandler)
8568
to be notified of changes to subscribed resources.
8669

70+
**Server-side**:
71+
Use
72+
[`Server.AddResource`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/mcp#Server.AddResource)
73+
or
74+
[`Server.AddResourceTemplate`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/mcp#Server.AddResourceTemplate)
75+
to add a resource or resource template to the server along with its handler.
76+
A
77+
[`ResourceHandler`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/mcp#ResourceHandler)
78+
maps a URI to the contents of a resource, which can include text, binary data,
79+
or both.
80+
If `AddResource` or `AddResourceTemplate` is called before a server is connected, the server will have the
81+
`resources` capability.
82+
The server will have the `resources` capability if any resource or resource template is added before the
83+
server is connected to a client, or if
84+
[`ServerOptions.HasResources`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/mcp#ServerOptions.HasResources)
85+
is explicitly set. When a prompt is added, any clients already connected to the
86+
server will be notified via a `notifications/resources/list_changed`
87+
notification.
88+
89+
8790
%include ../../mcp/server_example_test.go resources -
8891

8992
## Tools

0 commit comments

Comments
 (0)