@ntcore-ts/mcp 1.0.0-beta.2
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.
- package/README.md +108 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +1003 -0
- package/dist/cli.js.map +1 -0
- package/dist/decode.d.ts +12 -0
- package/dist/decode.d.ts.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +998 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/inventory.d.ts +34 -0
- package/dist/inventory.d.ts.map +1 -0
- package/dist/log.d.ts +5 -0
- package/dist/log.d.ts.map +1 -0
- package/dist/response.d.ts +24 -0
- package/dist/response.d.ts.map +1 -0
- package/dist/router.d.ts +20 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/sampler.d.ts +41 -0
- package/dist/sampler.d.ts.map +1 -0
- package/dist/server.d.ts +10 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/service.d.ts +28 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/session.d.ts +25 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/write-gate.d.ts +23 -0
- package/dist/write-gate.d.ts.map +1 -0
- package/package.json +65 -0
package/README.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# @ntcore-ts/mcp
|
|
2
|
+
|
|
3
|
+
Model Context Protocol (MCP) server for live [NetworkTables](https://docs.wpilib.org/en/stable/docs/software/networktables/networktables-intro.html), built on [`@ntcore-ts/client`](../client).
|
|
4
|
+
|
|
5
|
+
Exposes connect/discover/get/decode/subscribe tools to MCP hosts (Cursor, Claude Desktop, etc.), with **gated writes** and structured JSON evidence for agents.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g @ntcore-ts/mcp
|
|
11
|
+
# or use npx
|
|
12
|
+
npx ntcore-ts-mcp
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Cursor / Claude Desktop
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"mcpServers": {
|
|
20
|
+
"ntcore-ts": {
|
|
21
|
+
"command": "npx",
|
|
22
|
+
"args": ["-y", "ntcore-ts-mcp"],
|
|
23
|
+
"env": {
|
|
24
|
+
"NT_ALLOW_WRITES": "0"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Local workspace (monorepo):
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"mcpServers": {
|
|
36
|
+
"ntcore-ts": {
|
|
37
|
+
"command": "npx",
|
|
38
|
+
"args": ["tsx", "packages/mcp/src/cli.ts"],
|
|
39
|
+
"cwd": "/path/to/ntcore-ts"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Inspector:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npx @modelcontextprotocol/inspector npx tsx packages/mcp/src/cli.ts
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Tools
|
|
52
|
+
|
|
53
|
+
Call **`nt_guide`** first. Highlights:
|
|
54
|
+
|
|
55
|
+
| Tool | Role |
|
|
56
|
+
| ----------------------------------------------------- | ------------------------------------------------- |
|
|
57
|
+
| `nt_connect` / `nt_disconnect` / `nt_connection_info` | Session |
|
|
58
|
+
| `nt_list_topics` | Inventory (prefix filter) |
|
|
59
|
+
| `nt_get` / `nt_get_multiple` | Scalars / arrays / JSON |
|
|
60
|
+
| `nt_get_decoded` | Struct / protobuf → JSON |
|
|
61
|
+
| `nt_subscribe` | Timed sample window (`summary` or `samples`) |
|
|
62
|
+
| `nt_list_struct_types` | Built-in + discovered struct names |
|
|
63
|
+
| `nt_set_write_mode` | Enable/disable writes (`confirm: true` to enable) |
|
|
64
|
+
| `nt_set` / `nt_set_multiple` | Gated publish |
|
|
65
|
+
|
|
66
|
+
## Writes (safety)
|
|
67
|
+
|
|
68
|
+
Writes are **off by default**.
|
|
69
|
+
|
|
70
|
+
- Enable for the session: `nt_set_write_mode({ enabled: true, confirm: true })`
|
|
71
|
+
- Or start with `NT_ALLOW_WRITES=1`
|
|
72
|
+
- Path allowlist (default): `/SmartDashboard/**,/Tuning/**,/MyTable/**` via `NT_WRITE_ALLOWLIST`
|
|
73
|
+
- Optional: `NT_REQUIRE_LOCALHOST=1` refuses writes to non-local hosts
|
|
74
|
+
|
|
75
|
+
This is **not** a Driver Station. Do not use NT writes to enable/disable a robot on the field.
|
|
76
|
+
|
|
77
|
+
## Programmatic use
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
import { createNtMcpServer, NtMcpService } from '@ntcore-ts/mcp';
|
|
81
|
+
|
|
82
|
+
const service = new NtMcpService();
|
|
83
|
+
await service.connect({ host: 'localhost', port: 5810 });
|
|
84
|
+
const list = service.listTopics('/MyTable/');
|
|
85
|
+
|
|
86
|
+
// Or hand the factory to an MCP host transport:
|
|
87
|
+
const server = createNtMcpServer({ service });
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Docs
|
|
91
|
+
|
|
92
|
+
Full guide (install, tools, write gate, workflow): [MCP server](https://ntcore.chrislawson.dev/guide/mcp) in the VitePress site (`apps/docs/guide/mcp.md` in this repo).
|
|
93
|
+
|
|
94
|
+
## Notes
|
|
95
|
+
|
|
96
|
+
Topic discovery uses **short-lived prefix snapshots**. Leaving a long-lived `prefix=/` subscription open on the same `@ntcore-ts/client` instance prevents later typed topic subscriptions from receiving values; the MCP layer avoids that by snapshot-then-unsubscribe and by decoding struct bytes from inventory for `nt_get_decoded`.
|
|
97
|
+
|
|
98
|
+
The MCP process sets the client log level to **silent** so `tslog` never writes to stdout (which would corrupt the MCP JSON-RPC channel). Operational messages from this package go to stderr only, as single lines.
|
|
99
|
+
|
|
100
|
+
## Out of scope (for now)
|
|
101
|
+
|
|
102
|
+
- Offline WPILOG analysis
|
|
103
|
+
- Embedded roboRIO status MCP
|
|
104
|
+
- HTTP transport / MCP Resources / persistent poll subscriptions
|
|
105
|
+
|
|
106
|
+
## License
|
|
107
|
+
|
|
108
|
+
MIT
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|