@mavonengine/cli 0.0.4 → 0.0.6
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 +71 -1
- package/dist/{chunk-TGGH7KA4.js → chunk-7UZYGMGO.js} +1 -1
- package/dist/{chunk-KHC2RAKX.js → chunk-IIWBECVS.js} +1 -1
- package/dist/{docs-QCI5VKET.js → docs-S2SWFUIL.js} +2 -2
- package/dist/index.js +663 -58
- package/dist/{server-QSZHAYK2.js → server-AC5LBJ6A.js} +101 -36
- package/package.json +1 -1
|
@@ -9,14 +9,14 @@ import {
|
|
|
9
9
|
registerDocsTools,
|
|
10
10
|
run,
|
|
11
11
|
vec3
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-IIWBECVS.js";
|
|
13
13
|
import {
|
|
14
14
|
version
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-7UZYGMGO.js";
|
|
16
16
|
|
|
17
17
|
// src/mcp/server.ts
|
|
18
18
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
19
|
-
import { z as
|
|
19
|
+
import { z as z5 } from "zod";
|
|
20
20
|
|
|
21
21
|
// src/mcp/clientTools.ts
|
|
22
22
|
import { mkdir, writeFile } from "fs/promises";
|
|
@@ -599,15 +599,77 @@ function registerClientTools(server, client) {
|
|
|
599
599
|
}));
|
|
600
600
|
}
|
|
601
601
|
|
|
602
|
-
// src/mcp/
|
|
602
|
+
// src/mcp/databaseTools.ts
|
|
603
603
|
import { z as z2 } from "zod";
|
|
604
|
-
var
|
|
604
|
+
var SECRET_COLUMN_RE = /secret|password|passwd|token|hash|salt|api_?key|private/i;
|
|
605
|
+
var MAX_ROWS = 500;
|
|
606
|
+
function redactRows(columns, rows) {
|
|
607
|
+
const secret = new Set(columns.map((column) => column.name).filter((name) => SECRET_COLUMN_RE.test(name)));
|
|
608
|
+
for (const row of rows) {
|
|
609
|
+
for (const key of Object.keys(row)) {
|
|
610
|
+
if (SECRET_COLUMN_RE.test(key))
|
|
611
|
+
secret.add(key);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
return {
|
|
615
|
+
redacted: [...secret],
|
|
616
|
+
rows: secret.size === 0 ? rows : rows.map((row) => Object.fromEntries(Object.entries(row).map(([key, value]) => [key, secret.has(key) && value !== null ? "[redacted]" : value])))
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
function registerDatabaseTools(server, client) {
|
|
620
|
+
server.registerTool("database_overview", {
|
|
621
|
+
title: "Database tables",
|
|
622
|
+
description: `The game server's database, from the project's database plugin (e.g. @mavonengine/sqlite): which plugin gives it, every table with the plugin it belongs to (by its table prefix, "game" for the game's own), its columns and row count, and the migrations each plugin ran. Use database_rows to read a table. Needs the server's admin token (--token) unless the server runs on this machine without one.`,
|
|
623
|
+
inputSchema: {
|
|
624
|
+
table: z2.string().optional().describe("Only tables whose name contains this, case-insensitive")
|
|
625
|
+
},
|
|
626
|
+
annotations: READ_ONLY
|
|
627
|
+
}, ({ table }) => run(async () => {
|
|
628
|
+
const overview = await client.database();
|
|
629
|
+
if (!overview.provider) {
|
|
630
|
+
return {
|
|
631
|
+
provider: null,
|
|
632
|
+
tables: [],
|
|
633
|
+
note: "The project has no database plugin. Install one, e.g. `npx @mavonengine/cli install @mavonengine/sqlite`, and plugins get ctx.db and their migrations run"
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
const needle = table?.toLowerCase();
|
|
637
|
+
const tables = (overview.tables ?? []).filter((t) => !needle || t.name.toLowerCase().includes(needle));
|
|
638
|
+
return { provider: overview.provider, tables, migrations: overview.migrations ?? [] };
|
|
639
|
+
}));
|
|
640
|
+
server.registerTool("database_rows", {
|
|
641
|
+
title: "Rows of a database table",
|
|
642
|
+
description: 'A page of rows of one table of the game server\'s database, as database_overview lists them, with the total row count. Values of columns that look secret (password and token hashes, keys) are replaced with "[redacted]" and listed in `redacted`. Page with offset and limit.',
|
|
643
|
+
inputSchema: {
|
|
644
|
+
table: z2.string().min(1).describe("Table name, e.g. chat_mutes"),
|
|
645
|
+
offset: z2.number().int().min(0).default(0),
|
|
646
|
+
limit: z2.number().int().min(1).max(MAX_ROWS).default(50)
|
|
647
|
+
},
|
|
648
|
+
annotations: READ_ONLY
|
|
649
|
+
}, ({ table, offset, limit }) => run(async () => {
|
|
650
|
+
const page = await client.tableRows(table, offset, limit);
|
|
651
|
+
const { rows, redacted } = redactRows(page.columns ?? [], page.rows ?? []);
|
|
652
|
+
return {
|
|
653
|
+
table: page.table,
|
|
654
|
+
total: page.total,
|
|
655
|
+
offset: page.offset,
|
|
656
|
+
limit: page.limit,
|
|
657
|
+
columns: page.columns ?? [],
|
|
658
|
+
...redacted.length ? { redacted } : {},
|
|
659
|
+
rows
|
|
660
|
+
};
|
|
661
|
+
}));
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
// src/mcp/networkTools.ts
|
|
665
|
+
import { z as z3 } from "zod";
|
|
666
|
+
var clientId2 = z3.string().optional().describe("Tab id from list_clients. Default: the only open tab, or the only one not running the editor");
|
|
605
667
|
var packetFilters = {
|
|
606
|
-
kind:
|
|
607
|
-
direction:
|
|
608
|
-
type:
|
|
609
|
-
afterId:
|
|
610
|
-
limit:
|
|
668
|
+
kind: z3.enum(["packet", "event"]).optional().describe("packet: messages on the wire. event: connect, disconnect, sync_enter, sync_leave, dropped, state_gap\u2026"),
|
|
669
|
+
direction: z3.enum(["in", "out"]).optional().describe("Seen from the side that recorded it: out was sent, in was received"),
|
|
670
|
+
type: z3.string().optional().describe("Message or event name, e.g. sv_state or command. Several separated by commas"),
|
|
671
|
+
afterId: z3.number().int().min(0).default(0),
|
|
672
|
+
limit: z3.number().int().min(1).max(2e3).default(50).describe("Newest records kept when more match")
|
|
611
673
|
};
|
|
612
674
|
function withTime({ timestamp, ...record }) {
|
|
613
675
|
return { ...record, time: new Date(timestamp).toISOString() };
|
|
@@ -630,13 +692,13 @@ function registerNetworkTools(server, client) {
|
|
|
630
692
|
server.registerTool("network_packets", {
|
|
631
693
|
title: "Packets on the server",
|
|
632
694
|
description: "Packets the game server sent and received and its network events, oldest first: time, direction, message name, client (peer), size in bytes, server tick, input sequence id and a few facts about the payload (entity count, ack, command). The server keeps the last 2000. Pass the returned latestId as afterId to get only newer ones; network_packet shows a payload. Development only.",
|
|
633
|
-
inputSchema: { ...packetFilters, peer:
|
|
695
|
+
inputSchema: { ...packetFilters, peer: z3.string().optional().describe("Only one client: its player id (list_players, or playerId from list_clients)") },
|
|
634
696
|
annotations: READ_ONLY
|
|
635
697
|
}, ({ afterId, ...query }) => run(async () => listing(await client.packets({ ...query, after: afterId }))));
|
|
636
698
|
server.registerTool("network_packet", {
|
|
637
699
|
title: "One packet on the server",
|
|
638
700
|
description: "One record from network_packets with its payload, as it was serialized for the wire. Payloads of old records are dropped to bound memory (hasPayload false). Development only.",
|
|
639
|
-
inputSchema: { id:
|
|
701
|
+
inputSchema: { id: z3.number().int().min(1) },
|
|
640
702
|
annotations: READ_ONLY
|
|
641
703
|
}, ({ id }) => run(async () => {
|
|
642
704
|
const { record } = await client.packet(id);
|
|
@@ -648,8 +710,8 @@ function registerNetworkTools(server, client) {
|
|
|
648
710
|
title: "State sync",
|
|
649
711
|
description: "Who is sent what: the current server tick, the sync distance, each player with the entities in its last state update (tracked), its last acknowledged input and the size of that update; and each synced entity with how many players track it (trackedBy, 0 means no player is in range), whether it changed since it was last synced and the tick it was last sent in. For entities that do not show up or stop updating on a client. Development only.",
|
|
650
712
|
inputSchema: {
|
|
651
|
-
player:
|
|
652
|
-
includeEntities:
|
|
713
|
+
player: z3.string().optional().describe("Only this player, and the entities with `tracked` telling whether it is sent them"),
|
|
714
|
+
includeEntities: z3.boolean().default(true)
|
|
653
715
|
},
|
|
654
716
|
annotations: READ_ONLY
|
|
655
717
|
}, ({ player, includeEntities }) => run(async () => {
|
|
@@ -676,7 +738,7 @@ function registerNetworkTools(server, client) {
|
|
|
676
738
|
server.registerTool("client_packet", {
|
|
677
739
|
title: "One packet on a client",
|
|
678
740
|
description: "One record from client_packets with its payload.",
|
|
679
|
-
inputSchema: { id:
|
|
741
|
+
inputSchema: { id: z3.number().int().min(1), clientId: clientId2 },
|
|
680
742
|
annotations: READ_ONLY
|
|
681
743
|
}, ({ id, clientId: clientId3 }) => run(async () => {
|
|
682
744
|
const { record } = await client.client("packet", { id }, clientId3);
|
|
@@ -689,10 +751,10 @@ function registerNetworkTools(server, client) {
|
|
|
689
751
|
description: "What happened between the server and one tab, in order of time: the server's records for that client and the tab's own, merged, each marked with its side. Shows a packet leaving one side and arriving on the other (or not), inputs against the state updates that acknowledge them, and events like sync_enter / sync_leave, dropped and state_gap. Needs the server in development too.",
|
|
690
752
|
inputSchema: {
|
|
691
753
|
clientId: clientId2,
|
|
692
|
-
sinceMs:
|
|
693
|
-
includePings:
|
|
694
|
-
eventsOnly:
|
|
695
|
-
limit:
|
|
754
|
+
sinceMs: z3.number().int().min(100).max(6e5).default(5e3).describe("How far back to look"),
|
|
755
|
+
includePings: z3.boolean().default(false).describe("Keep ping / pong, one pair per second"),
|
|
756
|
+
eventsOnly: z3.boolean().default(false).describe("Leave the packets out"),
|
|
757
|
+
limit: z3.number().int().min(1).max(2e3).default(200).describe("Newest entries kept when more match")
|
|
696
758
|
},
|
|
697
759
|
annotations: READ_ONLY
|
|
698
760
|
}, ({ clientId: clientId3, sinceMs, includePings, eventsOnly, limit }) => run(async () => {
|
|
@@ -717,7 +779,7 @@ function registerNetworkTools(server, client) {
|
|
|
717
779
|
}
|
|
718
780
|
|
|
719
781
|
// src/mcp/pluginTools.ts
|
|
720
|
-
import { z as
|
|
782
|
+
import { z as z4 } from "zod";
|
|
721
783
|
var installCommand = (pkg) => `npx @mavonengine/cli install ${pkg}`;
|
|
722
784
|
async function installedPlugins(client) {
|
|
723
785
|
const [{ plugins = [] }, routes] = await Promise.all([
|
|
@@ -768,7 +830,7 @@ function registerPluginTools(server, client, list) {
|
|
|
768
830
|
server.registerTool("plugin_readme", {
|
|
769
831
|
title: "Read a plugin's readme",
|
|
770
832
|
description: "The README of an official MavonEngine plugin as Markdown, by its package name from available_plugins: what it does, its options for mavonengine.json, how a game hooks into it and its limits.",
|
|
771
|
-
inputSchema: { package:
|
|
833
|
+
inputSchema: { package: z4.string().describe("npm package of the plugin, e.g. @mavonengine/chat") },
|
|
772
834
|
annotations: { ...READ_ONLY, openWorldHint: true }
|
|
773
835
|
}, async ({ package: pkg }) => {
|
|
774
836
|
try {
|
|
@@ -794,6 +856,8 @@ network_packets / client_packets list the packets each side sent and received, n
|
|
|
794
856
|
client, and network_sync tells which entities each player is sent: use them when something does not arrive or arrives late.
|
|
795
857
|
client_trace records a few seconds of a tab for frame drops, stutter and slow rendering: the bottleneck, hitches with
|
|
796
858
|
their causes, hot JS functions, WebGL load, and a trace file for flame charts.
|
|
859
|
+
database_overview lists the tables of the project's database plugin (e.g. @mavonengine/sqlite) and database_rows reads
|
|
860
|
+
one, to check what the game and its plugins stored.
|
|
797
861
|
list_plugins shows the plugins the project has, available_plugins the official ones it could add and plugin_readme how
|
|
798
862
|
one is set up and used: look there before building something a plugin already does, like chat.
|
|
799
863
|
docs_list_pages / docs_get_page read the MavonEngine documentation: check it before guessing how an engine API works.`;
|
|
@@ -820,7 +884,7 @@ function createMcpServer(client, docs, pluginList) {
|
|
|
820
884
|
server.registerTool("server_metrics", {
|
|
821
885
|
title: "Full metrics snapshot",
|
|
822
886
|
description: "The full metrics snapshot. With includeHistory, also the last ~60 samples of CPU, bandwidth and tick timings, to spot spikes.",
|
|
823
|
-
inputSchema: { includeHistory:
|
|
887
|
+
inputSchema: { includeHistory: z5.boolean().default(false).describe("Include the per-sample history arrays") },
|
|
824
888
|
annotations: READ_ONLY
|
|
825
889
|
}, ({ includeHistory }) => run(async () => {
|
|
826
890
|
const metrics = await client.metrics();
|
|
@@ -840,7 +904,7 @@ function createMcpServer(client, docs, pluginList) {
|
|
|
840
904
|
server.registerTool("get_scene", {
|
|
841
905
|
title: "Active scene",
|
|
842
906
|
description: "The scene loaded on the server: name, file, whether it hot-reloads, unsaved changes, settings, and its objects with type, transform, props, the plugin that registered the type and whether the server built it (false for client-only types). Development only.",
|
|
843
|
-
inputSchema: { includeObjects:
|
|
907
|
+
inputSchema: { includeObjects: z5.boolean().default(true).describe("Include the scene objects, not just the summary") },
|
|
844
908
|
annotations: READ_ONLY
|
|
845
909
|
}, ({ includeObjects }) => run(async () => {
|
|
846
910
|
const { scene } = await client.scene();
|
|
@@ -855,18 +919,18 @@ function createMcpServer(client, docs, pluginList) {
|
|
|
855
919
|
title: "Entities in the world",
|
|
856
920
|
description: "Entities in the server world: id, type, position, rotation, scale, whether networked or a player, and the scene object it was built from. Filter by type and/or distance to a point (results are then nearest first). Returns the total match count. Development only.",
|
|
857
921
|
inputSchema: {
|
|
858
|
-
type:
|
|
922
|
+
type: z5.string().optional().describe("Entity class / networked type name, or scene object type, case-insensitive"),
|
|
859
923
|
near: vec3.optional().describe("Only entities around this point, nearest first"),
|
|
860
|
-
radius:
|
|
861
|
-
limit:
|
|
862
|
-
offset:
|
|
924
|
+
radius: z5.number().nonnegative().optional().describe("Max distance from `near`"),
|
|
925
|
+
limit: z5.number().int().min(1).max(500).default(50),
|
|
926
|
+
offset: z5.number().int().min(0).default(0)
|
|
863
927
|
},
|
|
864
928
|
annotations: READ_ONLY
|
|
865
929
|
}, (query) => run(() => client.entities(query)));
|
|
866
930
|
server.registerTool("get_entity", {
|
|
867
931
|
title: "One entity",
|
|
868
932
|
description: "One entity by id, with the state it sends to clients (its serialize() output). Development only.",
|
|
869
|
-
inputSchema: { id:
|
|
933
|
+
inputSchema: { id: z5.string().min(1) },
|
|
870
934
|
annotations: READ_ONLY
|
|
871
935
|
}, ({ id }) => run(async () => {
|
|
872
936
|
const { entity } = await client.entity(id);
|
|
@@ -878,10 +942,10 @@ function createMcpServer(client, docs, pluginList) {
|
|
|
878
942
|
title: "Server logs",
|
|
879
943
|
description: "Recent game server log lines, oldest first. The server keeps the last 500 by default. Pass the returned latestId as afterId later to get only newer lines.",
|
|
880
944
|
inputSchema: {
|
|
881
|
-
level:
|
|
882
|
-
contains:
|
|
883
|
-
afterId:
|
|
884
|
-
limit:
|
|
945
|
+
level: z5.enum(LOG_LEVELS).optional().describe("Only this level and more severe ones, e.g. warn includes error"),
|
|
946
|
+
contains: z5.string().optional().describe("Only lines containing this text, case-insensitive"),
|
|
947
|
+
afterId: z5.number().int().min(0).default(0),
|
|
948
|
+
limit: z5.number().int().min(1).max(500).default(100).describe("Newest lines kept when more match")
|
|
885
949
|
},
|
|
886
950
|
annotations: READ_ONLY
|
|
887
951
|
}, ({ level, contains, afterId, limit }) => run(async () => {
|
|
@@ -902,10 +966,10 @@ function createMcpServer(client, docs, pluginList) {
|
|
|
902
966
|
title: "HTTP requests",
|
|
903
967
|
description: "Recent HTTP requests the game server answered: method, path, status, duration, bytes, address. Pass the returned latestId as afterId later to get only newer ones.",
|
|
904
968
|
inputSchema: {
|
|
905
|
-
pathContains:
|
|
906
|
-
minStatus:
|
|
907
|
-
afterId:
|
|
908
|
-
limit:
|
|
969
|
+
pathContains: z5.string().optional(),
|
|
970
|
+
minStatus: z5.number().int().optional().describe("e.g. 400 for errors only"),
|
|
971
|
+
afterId: z5.number().int().min(0).default(0),
|
|
972
|
+
limit: z5.number().int().min(1).max(500).default(50).describe("Newest requests kept when more match")
|
|
909
973
|
},
|
|
910
974
|
annotations: READ_ONLY
|
|
911
975
|
}, ({ pathContains, minStatus, afterId, limit }) => run(async () => {
|
|
@@ -916,6 +980,7 @@ function createMcpServer(client, docs, pluginList) {
|
|
|
916
980
|
registerClientTools(server, client);
|
|
917
981
|
registerNetworkTools(server, client);
|
|
918
982
|
registerPluginTools(server, client, pluginList);
|
|
983
|
+
registerDatabaseTools(server, client);
|
|
919
984
|
if (docs)
|
|
920
985
|
registerDocsTools(server, docs);
|
|
921
986
|
return server;
|