Skip to content

Commit 91f1496

Browse files
committed
feat: add MCP resources for hotness and collection (v1.5.1)
1 parent 4e9329f commit 91f1496

File tree

5 files changed

+141
-3
lines changed

5 files changed

+141
-3
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,17 @@ Game recommendations are powered by [Recommend.Games](https://recommend.games/),
5656
| ----------- | ------------------------------------------------------------------------------------------ |
5757
| `bgg-rules` | Answer rules questions by searching BGG forums for relevant discussions and clarifications |
5858

59+
## Resources
60+
61+
BGG MCP exposes resources that AI assistants can access directly for contextual information:
62+
63+
| Resource | URI | Description |
64+
| --------------------- | --------------------- | ----------------------------------------------------------------- |
65+
| `BGG Hotness` | `bgg://hotness` | Current BGG hotness list, always available |
66+
| `My BGG Collection` | `bgg://my-collection` | Your personal BGG collection (requires `BGG_USERNAME` to be set) |
67+
68+
Resources provide AI assistants with direct access to BGG data without needing explicit tool calls, making conversations more natural and efficient.
69+
5970
## Prompts
6071

6172
- **Trade Sales Post** - Generate a formatted sales post for your BGG 'for trade' collection with discounted market prices

main.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"time"
1313

1414
"github.com/kkjdanie/bgg-mcp/prompts"
15+
"github.com/kkjdanie/bgg-mcp/resources"
1516
"github.com/kkjdanie/bgg-mcp/tools"
1617
"github.com/kkjdaniel/gogeek/v2"
1718
"github.com/mark3labs/mcp-go/server"
@@ -54,7 +55,7 @@ func createClientFromSessionConfig(apiKey, cookie string) *gogeek.Client {
5455
func createMCPServer(client *gogeek.Client) *server.MCPServer {
5556
s := server.NewMCPServer(
5657
"BGG MCP",
57-
"1.4.0",
58+
"1.5.1",
5859
server.WithResourceCapabilities(true, true),
5960
server.WithPromptCapabilities(true),
6061
server.WithLogging(),
@@ -91,6 +92,12 @@ func createMCPServer(client *gogeek.Client) *server.MCPServer {
9192
threadDetailsTool, threadDetailsHandler := tools.ThreadDetailsTool(client)
9293
s.AddTool(threadDetailsTool, threadDetailsHandler)
9394

95+
hotnessResource, hotnessResourceHandler := resources.HotnessResource(client)
96+
s.AddResource(hotnessResource, hotnessResourceHandler)
97+
98+
myCollectionResource, myCollectionResourceHandler := resources.MyCollectionResource(client)
99+
s.AddResource(myCollectionResource, myCollectionResourceHandler)
100+
94101
prompts.RegisterPrompts(s)
95102

96103
return s

resources/collection.go

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package resources
2+
3+
import (
4+
"context"
5+
"encoding/json"
6+
"fmt"
7+
"os"
8+
9+
"github.com/kkjdaniel/gogeek/v2"
10+
"github.com/kkjdaniel/gogeek/v2/collection"
11+
"github.com/mark3labs/mcp-go/mcp"
12+
"github.com/mark3labs/mcp-go/server"
13+
)
14+
15+
func MyCollectionResource(client *gogeek.Client) (mcp.Resource, server.ResourceHandlerFunc) {
16+
username := os.Getenv("BGG_USERNAME")
17+
18+
var description string
19+
if username != "" {
20+
description = fmt.Sprintf("Your BoardGameGeek collection (user: %s). Shows all owned games with their ratings, play counts, and status.", username)
21+
} else {
22+
description = "Your BoardGameGeek collection. Requires BGG_USERNAME environment variable to be set."
23+
}
24+
25+
resource := mcp.NewResource(
26+
"bgg://my-collection",
27+
"My BGG Collection",
28+
mcp.WithResourceDescription(description),
29+
mcp.WithMIMEType("application/json"),
30+
)
31+
32+
handler := func(ctx context.Context, request mcp.ReadResourceRequest) ([]mcp.ResourceContents, error) {
33+
if username == "" {
34+
return nil, fmt.Errorf("BGG_USERNAME environment variable not set")
35+
}
36+
37+
result, err := collection.Query(client, username, collection.WithOwned(true))
38+
if err != nil {
39+
return nil, fmt.Errorf("error fetching collection: %v", err)
40+
}
41+
42+
if len(result.Items) == 0 {
43+
return []mcp.ResourceContents{
44+
&mcp.TextResourceContents{
45+
URI: "bgg://my-collection",
46+
MIMEType: "application/json",
47+
Text: "[]",
48+
},
49+
}, nil
50+
}
51+
52+
out, err := json.Marshal(result.Items)
53+
if err != nil {
54+
return nil, fmt.Errorf("error formatting results: %v", err)
55+
}
56+
57+
return []mcp.ResourceContents{
58+
&mcp.TextResourceContents{
59+
URI: "bgg://my-collection",
60+
MIMEType: "application/json",
61+
Text: string(out),
62+
},
63+
}, nil
64+
}
65+
66+
return resource, handler
67+
}

resources/hotness.go

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package resources
2+
3+
import (
4+
"context"
5+
"encoding/json"
6+
"fmt"
7+
8+
"github.com/kkjdaniel/gogeek/v2"
9+
"github.com/kkjdaniel/gogeek/v2/hot"
10+
"github.com/mark3labs/mcp-go/mcp"
11+
"github.com/mark3labs/mcp-go/server"
12+
)
13+
14+
func HotnessResource(client *gogeek.Client) (mcp.Resource, server.ResourceHandlerFunc) {
15+
resource := mcp.NewResource(
16+
"bgg://hotness",
17+
"Current BGG Hotness List",
18+
mcp.WithResourceDescription("The current list of hot board games on BoardGameGeek, updated regularly by the BGG community"),
19+
mcp.WithMIMEType("application/json"),
20+
)
21+
22+
handler := func(ctx context.Context, request mcp.ReadResourceRequest) ([]mcp.ResourceContents, error) {
23+
hotItems, err := hot.Query(client, hot.ItemTypeBoardGame)
24+
if err != nil {
25+
return nil, fmt.Errorf("error fetching hotness list: %v", err)
26+
}
27+
28+
if len(hotItems.Items) == 0 {
29+
return []mcp.ResourceContents{
30+
&mcp.TextResourceContents{
31+
URI: "bgg://hotness",
32+
MIMEType: "application/json",
33+
Text: "[]",
34+
},
35+
}, nil
36+
}
37+
38+
out, err := json.Marshal(hotItems.Items)
39+
if err != nil {
40+
return nil, fmt.Errorf("error formatting results: %v", err)
41+
}
42+
43+
return []mcp.ResourceContents{
44+
&mcp.TextResourceContents{
45+
URI: "bgg://hotness",
46+
MIMEType: "application/json",
47+
Text: string(out),
48+
},
49+
}, nil
50+
}
51+
52+
return resource, handler
53+
}

server.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
"url": "https://github.com/kkjdaniel/bgg-mcp",
88
"source": "github"
99
},
10-
"version": "1.5.0",
10+
"version": "1.5.1",
1111
"packages": [
1212
{
1313
"registryType": "oci",
14-
"identifier": "docker.io/kdaniel/bgg-mcp:1.5.0",
14+
"identifier": "docker.io/kdaniel/bgg-mcp:1.5.1",
1515
"transport": {
1616
"type": "stdio"
1717
},

0 commit comments

Comments
 (0)