MCP server
@ntcore-ts/mcp is a Model Context Protocol server for live NetworkTables. MCP hosts such as Cursor and Claude Desktop can connect, inventory topics, read values (including decoded structs), sample updates, and publish when the write gate is open.
It is built on @ntcore-ts/client. It is not a Driver Station and does not replace offline WPILOG tools.
Install
npm install -g @ntcore-ts/mcp
# or run without a global install:
npx ntcore-ts-mcpCursor / Claude Desktop
Add a stdio server to your MCP config:
{
"mcpServers": {
"ntcore-ts": {
"command": "npx",
"args": ["-y", "ntcore-ts-mcp"],
"env": {
"NT_ALLOW_WRITES": "0",
"NT_REQUIRE_LOCALHOST": "1"
}
}
}
}From this monorepo (development):
{
"mcpServers": {
"ntcore-ts": {
"command": "npx",
"args": ["tsx", "packages/mcp/src/cli.ts"],
"cwd": "/path/to/ntcore-ts",
"env": {
"NT_ALLOW_WRITES": "0",
"NT_REQUIRE_LOCALHOST": "1"
}
}
}
}Reload the MCP server in the host after changing the config. Point it at a running NT server (for example npm run serve -w @ntcore-ts/example-robot on port 5810).
Agent workflow
- Call
nt_guidefirst if you need the tool map and write-gate status. nt_connectwithhost/port(or the team / URI options the tool accepts).nt_list_topicswith a prefix such as/MyTable/.- Use
nt_get/nt_get_multiplefor scalars, arrays, and JSON. - Use
nt_get_decodedforstruct:…/ protobuf topics (returns JSON). - Use
nt_subscribefor a short timed sample window (summaryorsamples). - Enable writes only when needed (see below), then
nt_set/nt_set_multiple. nt_disconnectwhen finished.
Tools
| Tool | Role |
|---|---|
nt_guide | Workflow, tool choice, write-gate status |
nt_connect / nt_disconnect / nt_connection_info | Session |
nt_list_topics | Inventory (prefix filter) |
nt_get / nt_get_multiple | Scalars / arrays / JSON |
nt_get_decoded | Struct / protobuf → JSON |
nt_subscribe | Timed sample window |
nt_list_struct_types | Built-in + discovered struct names |
nt_set_write_mode | Enable/disable writes (confirm: true to enable) |
nt_set / nt_set_multiple | Gated publish |
Writes (safety)
Writes are off by default.
- Enable for the session:
nt_set_write_mode({ enabled: true, confirm: true }) - Or start the process with
NT_ALLOW_WRITES=1 - Path allowlist (default):
/SmartDashboard/**,/Tuning/**,/MyTable/**viaNT_WRITE_ALLOWLIST - Optional:
NT_REQUIRE_LOCALHOST=1refuses writes when the NT host is not local
NetworkTables cannot enable or disable the robot (FMS/Driver Station does that). Do not let an agent command a live robot — published values can still move mechanisms if robot code is listening.
Programmatic use
You can drive the same service from Node without an MCP host:
import { createNtMcpServer, NtMcpService } from '@ntcore-ts/mcp';
const service = new NtMcpService();
await service.connect({ host: 'localhost', port: 5810 });
const list = service.listTopics('/MyTable/');
const server = createNtMcpServer({ service });Implementation notes
- Topic discovery uses short-lived prefix snapshots. A long-lived
prefix=/subscription on the same client instance can block later typed topic subscriptions; the MCP layer snapshot-then-unsubscribes and decodes struct bytes from inventory fornt_get_decoded. - The MCP process sets the client log level to silent so library logs never hit stdout (stdout is the JSON-RPC channel). Package messages go to stderr as single lines.
See also
- Getting started — connect with
@ntcore-ts/client - Struct / Protobuf — binary topic types agents decode via
nt_get_decoded - Package README in the repo:
packages/mcp/README.md