openshock-mcp 0.0.0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,131 @@
1
+ # PolyForm Noncommercial License 1.0.0
2
+
3
+ <https://polyformproject.org/licenses/noncommercial/1.0.0>
4
+
5
+ ## Acceptance
6
+
7
+ In order to get any license under these terms, you must agree
8
+ to them as both strict obligations and conditions to all
9
+ your licenses.
10
+
11
+ ## Copyright License
12
+
13
+ The licensor grants you a copyright license for the
14
+ software to do everything you might do with the software
15
+ that would otherwise infringe the licensor's copyright
16
+ in it for any permitted purpose. However, you may
17
+ only distribute the software according to [Distribution
18
+ License](#distribution-license) and make changes or new works
19
+ based on the software according to [Changes and New Works
20
+ License](#changes-and-new-works-license).
21
+
22
+ ## Distribution License
23
+
24
+ The licensor grants you an additional copyright license
25
+ to distribute copies of the software. Your license
26
+ to distribute covers distributing the software with
27
+ changes and new works permitted by [Changes and New Works
28
+ License](#changes-and-new-works-license).
29
+
30
+ ## Notices
31
+
32
+ You must ensure that anyone who gets a copy of any part of
33
+ the software from you also gets a copy of these terms or the
34
+ URL for them above, as well as copies of any plain-text lines
35
+ beginning with `Required Notice:` that the licensor provided
36
+ with the software. For example:
37
+
38
+ > Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
39
+
40
+ ## Changes and New Works License
41
+
42
+ The licensor grants you an additional copyright license to
43
+ make changes and new works based on the software for any
44
+ permitted purpose.
45
+
46
+ ## Patent License
47
+
48
+ The licensor grants you a patent license for the software that
49
+ covers patent claims the licensor can license, or becomes able
50
+ to license, that you would infringe by using the software.
51
+
52
+ ## Noncommercial Purposes
53
+
54
+ Any noncommercial purpose is a permitted purpose.
55
+
56
+ ## Personal Uses
57
+
58
+ Personal use for research, experiment, and testing for
59
+ the benefit of public knowledge, personal study, private
60
+ entertainment, hobby projects, amateur pursuits, or religious
61
+ observance, without any anticipated commercial application,
62
+ is use for a permitted purpose.
63
+
64
+ ## Noncommercial Organizations
65
+
66
+ Use by any charitable organization, educational institution,
67
+ public research organization, public safety or health
68
+ organization, environmental protection organization,
69
+ or government institution is use for a permitted purpose
70
+ regardless of the source of funding or obligations resulting
71
+ from the funding.
72
+
73
+ ## Fair Use
74
+
75
+ You may have "fair use" rights for the software under the
76
+ law. These terms do not limit them.
77
+
78
+ ## No Other Rights
79
+
80
+ These terms do not allow you to sublicense or transfer any of
81
+ your licenses to anyone else, or prevent the licensor from
82
+ granting licenses to anyone else. These terms do not imply
83
+ any other licenses.
84
+
85
+ ## Patent Defense
86
+
87
+ If you make any written claim that the software infringes or
88
+ contributes to infringement of any patent, your patent license
89
+ for the software granted under these terms ends immediately. If
90
+ your company makes such a claim, your patent license ends
91
+ immediately for work on behalf of your company.
92
+
93
+ ## Violations
94
+
95
+ The first time you are notified in writing that you have
96
+ violated any of these terms, or done anything with the software
97
+ not covered by your licenses, your licenses can nonetheless
98
+ continue if you come into full compliance with these terms,
99
+ and take practical steps to correct past violations, within
100
+ 32 days of receiving notice. Otherwise, all your licenses
101
+ end immediately.
102
+
103
+ ## No Liability
104
+
105
+ ***As far as the law allows, the software comes as is, without
106
+ any warranty or condition, and the licensor will not be liable
107
+ to you for any damages arising out of these terms or the use
108
+ or nature of the software, under any kind of legal claim.***
109
+
110
+ ## Definitions
111
+
112
+ The **licensor** is the individual or entity offering these
113
+ terms, and the **software** is the software the licensor makes
114
+ available under these terms.
115
+
116
+ **You** refers to the individual or entity agreeing to these
117
+ terms.
118
+
119
+ **Your company** is any legal entity, sole proprietorship,
120
+ or other kind of organization that you work for, plus all
121
+ organizations that have control over, are under the control of,
122
+ or are under common control with that organization. **Control**
123
+ means ownership of substantially all the assets of an entity,
124
+ or the power to direct its management and policies by vote,
125
+ contract, or otherwise. Control can be direct or indirect.
126
+
127
+ **Your licenses** are all the licenses granted to you for the
128
+ software under these terms.
129
+
130
+ **Use** means anything you do with the software requiring one
131
+ of your licenses.
@@ -0,0 +1,374 @@
1
+ Metadata-Version: 2.4
2
+ Name: openshock-mcp
3
+ Version: 0.0.0.3
4
+ Summary: Loopback-only MCP server for OpenShock
5
+ Author: NanashiTheNameless
6
+ Author-email: NanashiTheNameless <NanashiTheNameless@NamelessNanashi.dev>
7
+ Maintainer: NanashiTheNameless
8
+ Maintainer-email: NanashiTheNameless <NanashiTheNameless@NamelessNanashi.dev>
9
+ License-Expression: PolyForm-Noncommercial-1.0.0
10
+ Project-URL: Homepage, https://github.com/NanashiTheNameless/OpenShockMCP
11
+ Project-URL: Issues, https://github.com/NanashiTheNameless/OpenShockMCP/issues
12
+ Project-URL: GitHub Sponsor, https://github.com/sponsors/NanashiTheNameless
13
+ Project-URL: Buy Me a Coffee, https://buymeacoffee.com/NamelessNanashi
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Natural Language :: English
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Programming Language :: Python :: 3.14
23
+ Classifier: Operating System :: OS Independent
24
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
25
+ Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
26
+ Classifier: Typing :: Typed
27
+ Requires-Python: >=3.10
28
+ Description-Content-Type: text/markdown
29
+ License-File: LICENSE.md
30
+ Requires-Dist: mcp>=1.27.0
31
+ Requires-Dist: Nanashi-OpenShockPY>=0.0.1.7
32
+ Requires-Dist: tomli>=2.0.1; python_version < "3.11"
33
+ Provides-Extra: dev
34
+ Requires-Dist: pytest>=9.0.2; extra == "dev"
35
+ Requires-Dist: ruff>=0.8.5; extra == "dev"
36
+ Dynamic: license-file
37
+
38
+ # OpenShock MCP
39
+
40
+ [![PyPI - Version](https://img.shields.io/pypi/v/openshock-mcp)](https://pypi.org/project/openshock-mcp/)
41
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/openshock-mcp)](https://pypi.org/project/openshock-mcp/)
42
+ [![PyPI - Implementation](https://img.shields.io/pypi/implementation/openshock-mcp)](https://pypi.org/project/openshock-mcp/)
43
+ [![PyPI - Types](https://img.shields.io/pypi/types/openshock-mcp)](https://pypi.org/project/openshock-mcp/)
44
+
45
+ [![Tests](https://github.com/NanashiTheNameless/OpenShockMCP/workflows/Test/badge.svg)](https://github.com/NanashiTheNameless/OpenShockMCP/actions/workflows/test.yml)
46
+
47
+ Loopback-only MCP server for OpenShock.
48
+
49
+ It exposes OpenShock devices and shockers as MCP tools through Python and
50
+ [Nanashi-OpenShockPY](https://github.com/NanashiTheNameless/OpenShockPY).
51
+
52
+ This server is meant to run on the same machine as your MCP client. It should
53
+ not be reachable from other devices.
54
+
55
+ ## Liability Waiver
56
+
57
+ Read this before pressing buttons you might later pretend were "just testing".
58
+
59
+ **This software sends real commands to real hardware.** If you call `shock`,
60
+ `vibrate`, or `beep`, devices receive that action. This project does not detect
61
+ sarcasm, hesitation, or regret.
62
+
63
+ By using this project, you agree that:
64
+
65
+ - You are fully responsible for setup, configuration, and usage.
66
+ - You only use it with informed consent and lawful, ethical intent.
67
+ - You leave confirmation safeguards enabled unless you intentionally accept the risk.
68
+ - You understand there is no undo for actions already sent to hardware.
69
+ - You understand "I did not think it would actually do that" is not a bug report.
70
+
71
+ Short version: tool execute command. Consequences belong to operator.
72
+
73
+ ## Quick Start
74
+
75
+ 1. Install:
76
+
77
+ ```bash
78
+ pipx install --force 'git+https://github.com/NanashiTheNameless/OpenShockMCP.git@main'
79
+ ```
80
+
81
+ 2. First run with your API key to generate config and start the server:
82
+
83
+ ```bash
84
+ OPENSHOCK_API_KEY="your-api-key" openshock-mcp
85
+ ```
86
+
87
+ 3. Point your MCP client to `openshock-mcp` (stdio is the default and recommended transport).
88
+
89
+ If you prefer the full setup details, continue below.
90
+
91
+ ## Requirements
92
+
93
+ - Python 3.10 or newer
94
+ - `pipx`
95
+ - `git` (required if you install this project from a GitHub URL)
96
+ - An OpenShock API key
97
+
98
+ Dependencies:
99
+
100
+ ```text
101
+ mcp>=1.27.0
102
+ Nanashi-OpenShockPY>=0.0.1.7
103
+ ```
104
+
105
+ ## Installation
106
+
107
+ Install from GitHub (default):
108
+
109
+ ```bash
110
+ pipx install --force 'git+https://github.com/NanashiTheNameless/OpenShockMCP.git@main'
111
+ ```
112
+
113
+ Also available on PyPI:
114
+
115
+ ```bash
116
+ pipx install openshock-mcp
117
+ ```
118
+
119
+ Install a specific tag or commit:
120
+
121
+ ```bash
122
+ pipx install --force 'git+https://github.com/NanashiTheNameless/OpenShockMCP.git@0.0.0.3'
123
+ ```
124
+
125
+ For local development from a checkout:
126
+
127
+ ```bash
128
+ pipx install --editable /path/to/OpenShockMCP
129
+ ```
130
+
131
+ Check install:
132
+
133
+ ```bash
134
+ openshock-mcp --version
135
+ ```
136
+
137
+ Expected version:
138
+
139
+ ```text
140
+ 0.0.0.3
141
+ ```
142
+
143
+ ## First Run And Config Creation
144
+
145
+ The server uses a TOML config file. If no config exists, `openshock-mcp` creates
146
+ one automatically in the normal per-user config directory for your OS:
147
+
148
+ ```text
149
+ Windows: %APPDATA%\openshock-mcp\config.toml
150
+ macOS: ~/Library/Application Support/openshock-mcp/config.toml
151
+ Linux: ~/.config/openshock-mcp/config.toml
152
+ Other: ~/.config/openshock-mcp/config.toml
153
+ ```
154
+
155
+ If `OPENSHOCK_API_KEY` is set during first run, the generated config includes it
156
+ and the server starts:
157
+
158
+ ```bash
159
+ OPENSHOCK_API_KEY="your-api-key" openshock-mcp
160
+ ```
161
+
162
+ If no API key is available, the server creates a template config and exits. Edit
163
+ `openshock.api_key`, then run it again.
164
+
165
+ ## Configuration
166
+
167
+ ### Default Config File
168
+
169
+ Generated config contents:
170
+
171
+ ```toml
172
+ [server]
173
+ transport = "stdio"
174
+ host = "127.0.0.1"
175
+ port = 8000
176
+ path = "/mcp"
177
+ json_response = false
178
+
179
+ [openshock]
180
+ api_key = "your-api-key"
181
+ base_url = "https://api.openshock.app"
182
+ timeout = 15
183
+
184
+ [safety]
185
+ max_intensity = 100
186
+ max_duration_ms = 65535
187
+ require_confirmation = true
188
+ ```
189
+
190
+ ### Config Lookup Order
191
+
192
+ Config lookup order:
193
+
194
+ 1. `--config /path/to/config.toml`
195
+ 2. `$OPENSHOCK_MCP_CONFIG`
196
+ 3. `./openshock-mcp.toml`
197
+ 4. OS user config path
198
+
199
+ On Unix-like systems, `$XDG_CONFIG_HOME/openshock-mcp/config.toml` is used before
200
+ `~/.config/openshock-mcp/config.toml` when `XDG_CONFIG_HOME` is set.
201
+
202
+ ### Environment Variable Overrides
203
+
204
+ Environment variables can override matching config values for automation.
205
+ `OPENSHOCK_USER_AGENT` is env-only; User-Agent is not written to config files.
206
+
207
+ ```text
208
+ OPENSHOCK_API_KEY
209
+ OPENSHOCK_BASE_URL
210
+ OPENSHOCK_TIMEOUT
211
+ OPENSHOCK_USER_AGENT
212
+ OPENSHOCK_MCP_MAX_INTENSITY
213
+ OPENSHOCK_MCP_MAX_DURATION_MS
214
+ OPENSHOCK_MCP_REQUIRE_CONFIRMATION
215
+ OPENSHOCK_MCP_TRANSPORT
216
+ OPENSHOCK_MCP_HOST
217
+ OPENSHOCK_MCP_PORT
218
+ OPENSHOCK_MCP_PATH
219
+ OPENSHOCK_MCP_JSON_RESPONSE
220
+ OPENSHOCK_MCP_CONFIG
221
+ ```
222
+
223
+ `openshock-mcp.toml` is ignored by git so local secrets do not get committed.
224
+ `openshock-mcp.example.toml` is a safe template.
225
+
226
+ ## Running The Server
227
+
228
+ ### Stdio (Recommended)
229
+
230
+ `stdio` is the default and recommended transport for desktop MCP clients. It
231
+ does not open a network port.
232
+
233
+ Do not use `stdio` as an interactive terminal program. MCP clients launch it and
234
+ send JSON-RPC over stdin. If you run `openshock-mcp` directly in a terminal, it
235
+ prints usage guidance instead of starting the protocol stream.
236
+
237
+ With explicit config:
238
+
239
+ ```bash
240
+ openshock-mcp --config ~/.config/openshock-mcp/config.toml
241
+ ```
242
+
243
+ On Windows PowerShell, pass a Windows path:
244
+
245
+ ```powershell
246
+ openshock-mcp --config "$env:APPDATA\openshock-mcp\config.toml"
247
+ ```
248
+
249
+ Claude Desktop style config:
250
+
251
+ ```json
252
+ {
253
+ "mcpServers": {
254
+ "openshock": {
255
+ "command": "openshock-mcp",
256
+ "args": ["--config", "/home/YOUR_USER/.config/openshock-mcp/config.toml"]
257
+ }
258
+ }
259
+ }
260
+ ```
261
+
262
+ ### HTTP (Only If Your Client Requires It)
263
+
264
+ Use streamable HTTP only when your MCP client needs an HTTP MCP endpoint. The
265
+ server refuses non-loopback hosts such as `0.0.0.0` and LAN IP addresses.
266
+
267
+ ```bash
268
+ openshock-mcp \
269
+ --transport streamable-http \
270
+ --host 127.0.0.1 \
271
+ --port 8765 \
272
+ --config ~/.config/openshock-mcp/config.toml
273
+ ```
274
+
275
+ MCP endpoint:
276
+
277
+ ```text
278
+ http://127.0.0.1:8765/mcp
279
+ ```
280
+
281
+ On startup, the server prints sanitized startup info to stderr:
282
+
283
+ ```text
284
+ openshock-mcp 0.0.0.3 starting
285
+ transport: streamable-http
286
+ mcp endpoint: http://127.0.0.1:8765/mcp
287
+ config: /path/to/config.toml
288
+ api key configured: yes
289
+ safety: max_intensity=100, max_duration_ms=65535, require_confirmation=true
290
+ ```
291
+
292
+ Stdio startup info also goes to stderr so stdout stays reserved for MCP JSON-RPC.
293
+
294
+ This is allowed:
295
+
296
+ ```bash
297
+ openshock-mcp --transport http --host 127.0.0.1
298
+ ```
299
+
300
+ This is rejected:
301
+
302
+ ```bash
303
+ openshock-mcp --transport http --host 0.0.0.0
304
+ ```
305
+
306
+ ## Tools
307
+
308
+ Read-only tools:
309
+
310
+ - `openshock_status`: show sanitized config status. Does not reveal API key.
311
+ - `list_devices`: list OpenShock devices.
312
+ - `get_device`: get one device by ID.
313
+ - `list_shockers`: list shockers, optionally filtered by device ID.
314
+ - `get_shocker`: get one shocker by ID.
315
+
316
+ Action tools:
317
+
318
+ - `shock`: shock one shocker, or use `shocker_id="all"`.
319
+ - `vibrate`: vibrate one shocker, or use `shocker_id="all"`.
320
+ - `beep`: beep one shocker, or use `shocker_id="all"`.
321
+ - `stop`: stop one shocker, or use `shocker_id="all"`.
322
+
323
+ `shock`, `vibrate`, and `beep` require `confirm=true` by default. Keep
324
+ `require_confirmation = true` unless you understand the risk. `stop` does not
325
+ require confirmation.
326
+
327
+ Typical action arguments:
328
+
329
+ ```json
330
+ {
331
+ "shocker_id": "your-shocker-id",
332
+ "intensity": 25,
333
+ "duration": 1000,
334
+ "exclusive": false,
335
+ "confirm": true
336
+ }
337
+ ```
338
+
339
+ Limits:
340
+
341
+ - `intensity`: `0` to `100`, also capped by `max_intensity`
342
+ - `duration`: `300` to `65535` ms, also capped by `max_duration_ms`
343
+
344
+ ## Security Model (Local Only)
345
+
346
+ - `stdio` opens no network listener.
347
+ - HTTP mode only accepts loopback bind hosts: `127.0.0.1`, `localhost`, or `::1`.
348
+ - Non-loopback hosts are rejected before startup.
349
+ - The MCP SDK enables DNS rebinding protection for loopback hosts.
350
+ - API keys are read from local config or environment only.
351
+
352
+ ## Troubleshooting
353
+
354
+ ### `OpenShock API key missing`
355
+
356
+ Set `[openshock].api_key` in your config file, or set `OPENSHOCK_API_KEY`.
357
+
358
+ ### `config file not found`
359
+
360
+ The path passed to `--config` must exist. If you want default lookup, omit
361
+ `--config`.
362
+
363
+ ### `refusing non-loopback HTTP host`
364
+
365
+ Use `127.0.0.1`, `localhost`, or `::1`. This project intentionally does not bind
366
+ to LAN or public interfaces.
367
+
368
+ ### `git` not found during install
369
+
370
+ Install `git`. OpenShockPY is installed from GitHub `main`.
371
+
372
+ ## License
373
+
374
+ PolyForm Noncommercial License 1.0.0. See [LICENSE.md](LICENSE.md).