run-dmcp 0.1.0
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/LICENSE +22 -0
- package/README.md +79 -0
- package/dist/__tests__/engineVocabulary.test.d.ts +1 -0
- package/dist/__tests__/engineVocabulary.test.js +147 -0
- package/dist/db/__tests__/connection.test.d.ts +1 -0
- package/dist/db/__tests__/connection.test.js +72 -0
- package/dist/db/__tests__/testDb.d.ts +33 -0
- package/dist/db/__tests__/testDb.js +41 -0
- package/dist/db/connection.d.ts +22 -0
- package/dist/db/connection.js +107 -0
- package/dist/db/schema.d.ts +1 -0
- package/dist/db/schema.js +725 -0
- package/dist/events/emitter.d.ts +22 -0
- package/dist/events/emitter.js +71 -0
- package/dist/http/server.d.ts +3 -0
- package/dist/http/server.js +649 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +92 -0
- package/dist/register/abilities.d.ts +2 -0
- package/dist/register/abilities.js +165 -0
- package/dist/register/audio.d.ts +2 -0
- package/dist/register/audio.js +326 -0
- package/dist/register/batch.d.ts +2 -0
- package/dist/register/batch.js +343 -0
- package/dist/register/character.d.ts +2 -0
- package/dist/register/character.js +324 -0
- package/dist/register/combat.d.ts +2 -0
- package/dist/register/combat.js +207 -0
- package/dist/register/core.d.ts +2 -0
- package/dist/register/core.js +1040 -0
- package/dist/register/display.d.ts +2 -0
- package/dist/register/display.js +263 -0
- package/dist/register/factions.d.ts +2 -0
- package/dist/register/factions.js +186 -0
- package/dist/register/images.d.ts +2 -0
- package/dist/register/images.js +400 -0
- package/dist/register/inventory.d.ts +2 -0
- package/dist/register/inventory.js +115 -0
- package/dist/register/mcp-prompts.d.ts +2 -0
- package/dist/register/mcp-prompts.js +684 -0
- package/dist/register/mcp-resources.d.ts +2 -0
- package/dist/register/mcp-resources.js +335 -0
- package/dist/register/narrative.d.ts +2 -0
- package/dist/register/narrative.js +242 -0
- package/dist/register/notes.d.ts +2 -0
- package/dist/register/notes.js +170 -0
- package/dist/register/pause.d.ts +2 -0
- package/dist/register/pause.js +580 -0
- package/dist/register/quests.d.ts +2 -0
- package/dist/register/quests.js +118 -0
- package/dist/register/relationships.d.ts +2 -0
- package/dist/register/relationships.js +147 -0
- package/dist/register/resources.d.ts +2 -0
- package/dist/register/resources.js +277 -0
- package/dist/register/secrets.d.ts +2 -0
- package/dist/register/secrets.js +192 -0
- package/dist/register/status.d.ts +2 -0
- package/dist/register/status.js +130 -0
- package/dist/register/tables.d.ts +2 -0
- package/dist/register/tables.js +146 -0
- package/dist/register/tags.d.ts +2 -0
- package/dist/register/tags.js +114 -0
- package/dist/register/time.d.ts +2 -0
- package/dist/register/time.js +281 -0
- package/dist/register/world.d.ts +2 -0
- package/dist/register/world.js +127 -0
- package/dist/schemas/index.d.ts +921 -0
- package/dist/schemas/index.js +121 -0
- package/dist/test-setup.d.ts +1 -0
- package/dist/test-setup.js +13 -0
- package/dist/tools/__tests__/audio.test.d.ts +1 -0
- package/dist/tools/__tests__/audio.test.js +59 -0
- package/dist/tools/__tests__/conserved.test.d.ts +1 -0
- package/dist/tools/__tests__/conserved.test.js +488 -0
- package/dist/tools/__tests__/constraint.test.d.ts +1 -0
- package/dist/tools/__tests__/constraint.test.js +212 -0
- package/dist/tools/__tests__/expiry-consequences.test.d.ts +1 -0
- package/dist/tools/__tests__/expiry-consequences.test.js +110 -0
- package/dist/tools/__tests__/images.test.d.ts +1 -0
- package/dist/tools/__tests__/images.test.js +59 -0
- package/dist/tools/__tests__/relationship.test.d.ts +1 -0
- package/dist/tools/__tests__/relationship.test.js +132 -0
- package/dist/tools/__tests__/resource-constraints.test.d.ts +1 -0
- package/dist/tools/__tests__/resource-constraints.test.js +131 -0
- package/dist/tools/__tests__/resource.test.d.ts +1 -0
- package/dist/tools/__tests__/resource.test.js +190 -0
- package/dist/tools/__tests__/time.test.d.ts +1 -0
- package/dist/tools/__tests__/time.test.js +404 -0
- package/dist/tools/__tests__/timers.test.d.ts +1 -0
- package/dist/tools/__tests__/timers.test.js +426 -0
- package/dist/tools/__tests__/world.test.d.ts +1 -0
- package/dist/tools/__tests__/world.test.js +70 -0
- package/dist/tools/ability.d.ts +48 -0
- package/dist/tools/ability.js +238 -0
- package/dist/tools/audio.d.ts +24 -0
- package/dist/tools/audio.js +365 -0
- package/dist/tools/character.d.ts +70 -0
- package/dist/tools/character.js +309 -0
- package/dist/tools/combat.d.ts +13 -0
- package/dist/tools/combat.js +195 -0
- package/dist/tools/constraint.d.ts +132 -0
- package/dist/tools/constraint.js +269 -0
- package/dist/tools/dice.d.ts +23 -0
- package/dist/tools/dice.js +111 -0
- package/dist/tools/display.d.ts +120 -0
- package/dist/tools/display.js +528 -0
- package/dist/tools/faction.d.ts +61 -0
- package/dist/tools/faction.js +269 -0
- package/dist/tools/game.d.ts +96 -0
- package/dist/tools/game.js +526 -0
- package/dist/tools/image-prompt.d.ts +49 -0
- package/dist/tools/image-prompt.js +479 -0
- package/dist/tools/images.d.ts +47 -0
- package/dist/tools/images.js +449 -0
- package/dist/tools/inventory.d.ts +20 -0
- package/dist/tools/inventory.js +145 -0
- package/dist/tools/narrative.d.ts +58 -0
- package/dist/tools/narrative.js +237 -0
- package/dist/tools/notes.d.ts +41 -0
- package/dist/tools/notes.js +220 -0
- package/dist/tools/pause.d.ts +110 -0
- package/dist/tools/pause.js +1254 -0
- package/dist/tools/quest.d.ts +34 -0
- package/dist/tools/quest.js +164 -0
- package/dist/tools/relationship.d.ts +74 -0
- package/dist/tools/relationship.js +324 -0
- package/dist/tools/resource.d.ts +93 -0
- package/dist/tools/resource.js +374 -0
- package/dist/tools/rules.d.ts +4 -0
- package/dist/tools/rules.js +30 -0
- package/dist/tools/secrets.d.ts +49 -0
- package/dist/tools/secrets.js +195 -0
- package/dist/tools/status.d.ts +36 -0
- package/dist/tools/status.js +218 -0
- package/dist/tools/tables.d.ts +33 -0
- package/dist/tools/tables.js +209 -0
- package/dist/tools/tags.d.ts +52 -0
- package/dist/tools/tags.js +176 -0
- package/dist/tools/time.d.ts +33 -0
- package/dist/tools/time.js +276 -0
- package/dist/tools/timers.d.ts +41 -0
- package/dist/tools/timers.js +215 -0
- package/dist/tools/world.d.ts +78 -0
- package/dist/tools/world.js +331 -0
- package/dist/types/index.d.ts +969 -0
- package/dist/types/index.js +1 -0
- package/dist/utils/__tests__/json.test.d.ts +1 -0
- package/dist/utils/__tests__/json.test.js +55 -0
- package/dist/utils/__tests__/validation.test.d.ts +1 -0
- package/dist/utils/__tests__/validation.test.js +90 -0
- package/dist/utils/errors.d.ts +44 -0
- package/dist/utils/errors.js +121 -0
- package/dist/utils/json.d.ts +9 -0
- package/dist/utils/json.js +23 -0
- package/dist/utils/logger.d.ts +7 -0
- package/dist/utils/logger.js +50 -0
- package/dist/utils/output-schemas.d.ts +594 -0
- package/dist/utils/output-schemas.js +331 -0
- package/dist/utils/tool-annotations.d.ts +147 -0
- package/dist/utils/tool-annotations.js +98 -0
- package/dist/utils/validation.d.ts +34 -0
- package/dist/utils/validation.js +52 -0
- package/dist/utils/verbosity.d.ts +57 -0
- package/dist/utils/verbosity.js +67 -0
- package/dist/utils/webui.d.ts +20 -0
- package/dist/utils/webui.js +35 -0
- package/package.json +75 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Verbosity levels for tool responses:
|
|
4
|
+
* - minimal: Just IDs and names - for quick lookups and references
|
|
5
|
+
* - standard: Common fields needed for most operations (default)
|
|
6
|
+
* - full: All fields including metadata - for detailed inspection
|
|
7
|
+
*/
|
|
8
|
+
export type VerbosityLevel = 'minimal' | 'standard' | 'full';
|
|
9
|
+
export declare const verbositySchema: z.ZodDefault<z.ZodEnum<["minimal", "standard", "full"]>>;
|
|
10
|
+
/**
|
|
11
|
+
* Field sets for each entity type by verbosity level
|
|
12
|
+
*/
|
|
13
|
+
export declare const VERBOSITY_FIELDS: {
|
|
14
|
+
readonly character: {
|
|
15
|
+
readonly minimal: readonly ["id", "name", "isPlayer"];
|
|
16
|
+
readonly standard: readonly ["id", "name", "isPlayer", "status", "locationId"];
|
|
17
|
+
readonly full: null;
|
|
18
|
+
};
|
|
19
|
+
readonly location: {
|
|
20
|
+
readonly minimal: readonly ["id", "name"];
|
|
21
|
+
readonly standard: readonly ["id", "name", "description", "properties"];
|
|
22
|
+
readonly full: null;
|
|
23
|
+
};
|
|
24
|
+
readonly quest: {
|
|
25
|
+
readonly minimal: readonly ["id", "name", "status"];
|
|
26
|
+
readonly standard: readonly ["id", "name", "description", "status", "objectives"];
|
|
27
|
+
readonly full: null;
|
|
28
|
+
};
|
|
29
|
+
readonly item: {
|
|
30
|
+
readonly minimal: readonly ["id", "name"];
|
|
31
|
+
readonly standard: readonly ["id", "name", "description", "quantity", "ownerId", "ownerType"];
|
|
32
|
+
readonly full: null;
|
|
33
|
+
};
|
|
34
|
+
readonly faction: {
|
|
35
|
+
readonly minimal: readonly ["id", "name"];
|
|
36
|
+
readonly standard: readonly ["id", "name", "description", "goals", "resources"];
|
|
37
|
+
readonly full: null;
|
|
38
|
+
};
|
|
39
|
+
readonly resource: {
|
|
40
|
+
readonly minimal: readonly ["id", "name", "currentValue"];
|
|
41
|
+
readonly standard: readonly ["id", "name", "description", "currentValue", "minValue", "maxValue"];
|
|
42
|
+
readonly full: null;
|
|
43
|
+
};
|
|
44
|
+
readonly note: {
|
|
45
|
+
readonly minimal: readonly ["id", "title", "isPinned"];
|
|
46
|
+
readonly standard: readonly ["id", "title", "content", "category", "isPinned", "createdAt"];
|
|
47
|
+
readonly full: null;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Filter an object to include only specified fields
|
|
52
|
+
*/
|
|
53
|
+
export declare function filterFields<T extends object>(obj: T, fields: readonly string[] | null): Partial<T>;
|
|
54
|
+
/**
|
|
55
|
+
* Apply verbosity filtering to an array of entities
|
|
56
|
+
*/
|
|
57
|
+
export declare function applyVerbosity<T extends object>(entities: T[], entityType: keyof typeof VERBOSITY_FIELDS, verbosity: VerbosityLevel): Partial<T>[];
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const verbositySchema = z
|
|
3
|
+
.enum(['minimal', 'standard', 'full'])
|
|
4
|
+
.default('standard')
|
|
5
|
+
.describe('Response verbosity: minimal (IDs/names only), standard (common fields), full (all fields)');
|
|
6
|
+
/**
|
|
7
|
+
* Field sets for each entity type by verbosity level
|
|
8
|
+
*/
|
|
9
|
+
export const VERBOSITY_FIELDS = {
|
|
10
|
+
character: {
|
|
11
|
+
minimal: ['id', 'name', 'isPlayer'],
|
|
12
|
+
standard: ['id', 'name', 'isPlayer', 'status', 'locationId'],
|
|
13
|
+
full: null, // null means include all fields
|
|
14
|
+
},
|
|
15
|
+
location: {
|
|
16
|
+
minimal: ['id', 'name'],
|
|
17
|
+
standard: ['id', 'name', 'description', 'properties'],
|
|
18
|
+
full: null,
|
|
19
|
+
},
|
|
20
|
+
quest: {
|
|
21
|
+
minimal: ['id', 'name', 'status'],
|
|
22
|
+
standard: ['id', 'name', 'description', 'status', 'objectives'],
|
|
23
|
+
full: null,
|
|
24
|
+
},
|
|
25
|
+
item: {
|
|
26
|
+
minimal: ['id', 'name'],
|
|
27
|
+
standard: ['id', 'name', 'description', 'quantity', 'ownerId', 'ownerType'],
|
|
28
|
+
full: null,
|
|
29
|
+
},
|
|
30
|
+
faction: {
|
|
31
|
+
minimal: ['id', 'name'],
|
|
32
|
+
standard: ['id', 'name', 'description', 'goals', 'resources'],
|
|
33
|
+
full: null,
|
|
34
|
+
},
|
|
35
|
+
resource: {
|
|
36
|
+
minimal: ['id', 'name', 'currentValue'],
|
|
37
|
+
standard: ['id', 'name', 'description', 'currentValue', 'minValue', 'maxValue'],
|
|
38
|
+
full: null,
|
|
39
|
+
},
|
|
40
|
+
note: {
|
|
41
|
+
minimal: ['id', 'title', 'isPinned'],
|
|
42
|
+
standard: ['id', 'title', 'content', 'category', 'isPinned', 'createdAt'],
|
|
43
|
+
full: null,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Filter an object to include only specified fields
|
|
48
|
+
*/
|
|
49
|
+
export function filterFields(obj, fields) {
|
|
50
|
+
if (fields === null) {
|
|
51
|
+
return obj; // Return full object
|
|
52
|
+
}
|
|
53
|
+
const result = {};
|
|
54
|
+
for (const field of fields) {
|
|
55
|
+
if (field in obj) {
|
|
56
|
+
result[field] = obj[field];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Apply verbosity filtering to an array of entities
|
|
63
|
+
*/
|
|
64
|
+
export function applyVerbosity(entities, entityType, verbosity) {
|
|
65
|
+
const fields = VERBOSITY_FIELDS[entityType][verbosity];
|
|
66
|
+
return entities.map((entity) => filterFields(entity, fields));
|
|
67
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Set the actual HTTP port after server starts
|
|
3
|
+
*/
|
|
4
|
+
export declare function setHttpPort(port: number): void;
|
|
5
|
+
/**
|
|
6
|
+
* Get the base URL for the HTTP web UI
|
|
7
|
+
*/
|
|
8
|
+
export declare function getWebUiBaseUrl(): string;
|
|
9
|
+
/**
|
|
10
|
+
* Get the web UI URL for a game
|
|
11
|
+
*/
|
|
12
|
+
export declare function getGameUrl(gameId: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Get the web UI URL for a character
|
|
15
|
+
*/
|
|
16
|
+
export declare function getCharacterUrl(characterId: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Get the web UI URL for a location
|
|
19
|
+
*/
|
|
20
|
+
export declare function getLocationUrl(locationId: string): string;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Actual port the HTTP server is running on (set at runtime)
|
|
3
|
+
*/
|
|
4
|
+
let actualHttpPort = null;
|
|
5
|
+
/**
|
|
6
|
+
* Set the actual HTTP port after server starts
|
|
7
|
+
*/
|
|
8
|
+
export function setHttpPort(port) {
|
|
9
|
+
actualHttpPort = port;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Get the base URL for the HTTP web UI
|
|
13
|
+
*/
|
|
14
|
+
export function getWebUiBaseUrl() {
|
|
15
|
+
const port = actualHttpPort ?? parseInt(process.env.DMCP_HTTP_PORT || "3456", 10);
|
|
16
|
+
return `http://localhost:${port}`;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Get the web UI URL for a game
|
|
20
|
+
*/
|
|
21
|
+
export function getGameUrl(gameId) {
|
|
22
|
+
return `${getWebUiBaseUrl()}/games/${gameId}`;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Get the web UI URL for a character
|
|
26
|
+
*/
|
|
27
|
+
export function getCharacterUrl(characterId) {
|
|
28
|
+
return `${getWebUiBaseUrl()}/characters/${characterId}`;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get the web UI URL for a location
|
|
32
|
+
*/
|
|
33
|
+
export function getLocationUrl(locationId) {
|
|
34
|
+
return `${getWebUiBaseUrl()}/locations/${locationId}`;
|
|
35
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "run-dmcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "An MCP server for LLM-run interactive fiction where the server owns what is true - including when it was true. A continuation of DMCP.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Derek Ferguson",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/JavaDerek/run-dmcp.git"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "dist/index.js",
|
|
13
|
+
"bin": {
|
|
14
|
+
"run-dmcp": "dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc && npm run build:client",
|
|
18
|
+
"build:server": "tsc",
|
|
19
|
+
"build:client": "cd client && npm run build",
|
|
20
|
+
"start": "node dist/index.js",
|
|
21
|
+
"dev": "tsx src/index.ts",
|
|
22
|
+
"dev:client": "cd client && npm run dev",
|
|
23
|
+
"test": "vitest",
|
|
24
|
+
"test:run": "vitest run",
|
|
25
|
+
"test:coverage": "vitest run --coverage",
|
|
26
|
+
"test:client": "cd client && npm run test",
|
|
27
|
+
"test:all": "npm run test:run && npm run test:client -- run",
|
|
28
|
+
"lint": "eslint src/",
|
|
29
|
+
"lint:fix": "eslint src/ --fix",
|
|
30
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
31
|
+
"format:check": "prettier --check \"src/**/*.ts\"",
|
|
32
|
+
"typecheck": "tsc --noEmit"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
36
|
+
"better-sqlite3": "^11.0.0",
|
|
37
|
+
"express": "^5.0.1",
|
|
38
|
+
"sharp": "^0.34.5",
|
|
39
|
+
"uuid": "^10.0.0",
|
|
40
|
+
"zod": "^3.25.76"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@eslint/js": "^9.39.2",
|
|
44
|
+
"@types/better-sqlite3": "^7.6.11",
|
|
45
|
+
"@types/express": "^5.0.0",
|
|
46
|
+
"@types/node": "^22.0.0",
|
|
47
|
+
"@types/sharp": "^0.31.1",
|
|
48
|
+
"@types/uuid": "^10.0.0",
|
|
49
|
+
"@vitest/coverage-v8": "^4.0.16",
|
|
50
|
+
"eslint": "^9.39.2",
|
|
51
|
+
"eslint-config-prettier": "^10.1.8",
|
|
52
|
+
"prettier": "^3.7.4",
|
|
53
|
+
"tsx": "^4.0.0",
|
|
54
|
+
"typescript": "^5.0.0",
|
|
55
|
+
"typescript-eslint": "^8.51.0",
|
|
56
|
+
"vitest": "^4.0.16"
|
|
57
|
+
},
|
|
58
|
+
"contributors": [
|
|
59
|
+
"Shawn Rushefsky (DMCP, the project this continues)"
|
|
60
|
+
],
|
|
61
|
+
"keywords": [
|
|
62
|
+
"mcp",
|
|
63
|
+
"interactive-fiction",
|
|
64
|
+
"narrative",
|
|
65
|
+
"timeline",
|
|
66
|
+
"event-sourcing",
|
|
67
|
+
"llm",
|
|
68
|
+
"rpg"
|
|
69
|
+
],
|
|
70
|
+
"files": [
|
|
71
|
+
"dist/",
|
|
72
|
+
"README.md",
|
|
73
|
+
"LICENSE"
|
|
74
|
+
]
|
|
75
|
+
}
|