You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Resources are how you expose data to LLMs. They can be anything - files, API responses, database queries, system information, etc. Resources can be:
208
207
209
-
Resources are how you expose data to LLMs. They're similar to GET endpoints in a REST API - they provide data but shouldn't perform significant computation or have side effects. Some examples:
profile, err:=getUserProfile(userID) // Your DB/API call here
327
259
if err != nil {
328
260
returnnil, err
329
261
}
330
262
331
263
return []interface{}{
332
264
mcp.TextResourceContents{
333
265
ResourceContents: mcp.ResourceContents{
334
-
URI: "test://db/products",
266
+
URI: fmt.Sprintf("users://%s/profile", userID),
335
267
MIMEType: "application/json",
336
268
},
337
-
Text: string(productsJSON),
269
+
Text: profile,
338
270
},
339
271
}, nil
340
272
})
341
273
```
342
274
343
-
</details>
344
-
345
-
Resources can be:
346
-
- Static or dynamic
347
-
- Text or binary
348
-
- Single or multi-part
349
-
- Template-based for dynamic paths
350
-
- Annotated with metadata
351
-
- Backed by various data sources
352
-
353
-
The URI scheme (e.g., `test://`) is arbitrary - you can use any scheme that makes sense for your application. The handler function is called whenever the resource is requested, allowing for dynamic content generation.
275
+
The examples are simple but demonstrate the core concepts. Resources can be much more sophisticated - serving multiple contents, using annotations, integrating with databases or external APIs, etc.
0 commit comments