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
{{ message }}
Repository navigation
Commit d4fb881
Browse filesBrowse the repository at this point in the historyBrowse files
some MCP clients such as opencode do not support MCP resource
capabilities, so this flag converts resources into tool calls.
see anomalyco/opencode#806.
Copy file name to clipboardExpand all lines: cmd/buttplug-mcp/main.go
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -43,6 +43,7 @@ func main() {
43
43
pflag.BoolVarP(&config.LogJSON, "log-json", "j", false, "Log in JSON (default is plaintext)")
44
44
pflag.StringVarP(&config.MCPConfig.SSEHostPort, "sse-host", "", "", "host:port to listen to SSE connections")
45
45
pflag.BoolVarP(&config.MCPConfig.UseSSE, "sse", "", false, "Use SSE Transport (default is stdio transport)")
46
+
pflag.BoolVarP(&config.MCPConfig.NoResourcesMode, "no-resources", "", false, "Disable resource capabilities in favor of tools (for MCP clients that don't support them)")
46
47
pflag.StringVarP(&config.BPConfig.WebsocketHost, "ws-host", "", "localhost", "host to connect to the Buttplug Websocket server")
47
48
pflag.IntVarP(&config.BPConfig.WebsocketPort, "ws-port", "", 12345, "port to connect to the Buttplug Websocket server")
mcp.WithResourceDescription("List of buttplug.io connected devices as an array of each device's ID number."),
82
+
mcp.WithMIMEType("application/json"),
83
+
), s.handleDeviceList)
84
+
85
+
// /devices/{id}
86
+
s.mcp.AddResource(mcp.NewResource("buttplug://devices/{id}", "Get Device by ID",
87
+
mcp.WithResourceDescription("Get buttplug.io device information by device ID, where `id` is a key from `/devices`"),
88
+
mcp.WithMIMEType("application/json"),
89
+
), s.handleDeviceOne)
90
+
} else {
91
+
// get_device_ids
92
+
s.mcp.AddTool(mcp.NewTool("get_device_ids",
93
+
mcp.WithDescription("List connected buttplug.io devices as an array of device IDs."),
94
+
), s.handleDeviceListTool)
95
+
96
+
// get_device_by_id
97
+
s.mcp.AddTool(mcp.NewTool("get_device_by_id",
98
+
mcp.WithDescription("Get buttplug.io device information by device ID, where `id` is a key from `get_device_ids`."),
99
+
mcp.WithNumber("id",
100
+
mcp.Required(),
101
+
mcp.Description("Device index to query, sourced from `get_device_ids`."),
102
+
mcp.Pattern(regexInt),
103
+
),
104
+
), s.handleDeviceOneTool)
105
+
}
83
106
84
107
// device_vibrate
85
108
s.mcp.AddTool(mcp.NewTool("device_vibrate",
86
-
mcp.WithDescription("Vibrates device with `id`, selecting `strength`"),
109
+
mcp.WithDescription("Vibrates device with `id` (from `/devices`) at `strength` (0.0 to 1.0) for `duration_sec` seconds, optionally stopping after duration."),
87
110
mcp.WithNumber("id",
88
111
mcp.Required(),
89
112
mcp.Description("Device index to vibrate, sourced from `/devices`."),
@@ -98,7 +121,7 @@ func (s *Server) registerTools() {
98
121
),
99
122
mcp.WithNumber("duration_sec",
100
123
mcp.Required(),
101
-
mcp.Description("Duration in seconds to wait for until returning. If zero, vibrate indefinitely until another command is sent."),
124
+
mcp.Description("Duration in seconds to wait for until returning. If zero, vibrate indefinitely until another command is sent. Avoid setting this to zero unless you definitely plan to stop the device later."),
102
125
mcp.DefaultNumber(0.0),
103
126
mcp.Min(0.0),
104
127
mcp.Max(3600.0),
@@ -111,7 +134,7 @@ func (s *Server) registerTools() {
111
134
112
135
// device_stop
113
136
s.mcp.AddTool(mcp.NewTool("device_stop",
114
-
mcp.WithDescription("Stop vibrating device with `id`"),
137
+
mcp.WithDescription("Stop vibrating device with `id`. Use in emergency situations or to halt vibration early."),
115
138
mcp.WithNumber("id",
116
139
mcp.Required(),
117
140
mcp.Description("Device index to stop, sourced from `/devices`."),
@@ -121,22 +144,35 @@ func (s *Server) registerTools() {
0 commit comments