javascript-solid-server 0.0.199 → 0.0.201
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 +3 -1
- package/bin/jss.js +3 -0
- package/docs/mcp.md +228 -0
- package/package.json +1 -1
- package/src/config.js +5 -0
- package/src/mcp/index.js +212 -0
- package/src/mcp/protocol.js +52 -0
- package/src/mcp/skills.js +138 -0
- package/src/mcp/tools.js +760 -0
- package/src/server.js +11 -0
- package/test/mcp.test.js +562 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill discovery for the MCP server.
|
|
3
|
+
*
|
|
4
|
+
* Skills are SKILL.md files (or SKILL.jsonld) at well-known paths:
|
|
5
|
+
*
|
|
6
|
+
* <pod>/SKILL.md pod-wide
|
|
7
|
+
* <pod>/public/apps/<name>/SKILL.md per-app
|
|
8
|
+
* <pod>/private/bots/<name>/SKILL.md per-bot
|
|
9
|
+
*
|
|
10
|
+
* The discovery channel (list_skills) is stable; the payload format
|
|
11
|
+
* declared via `skill:format` evolves (anthropic.skill.v1 today,
|
|
12
|
+
* future vocabularies plug in by name).
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import * as storage from '../storage/filesystem.js';
|
|
16
|
+
|
|
17
|
+
const POD_ROOT_SKILL = ['/SKILL.md', '/SKILL.jsonld'];
|
|
18
|
+
const APPS_BASE = '/public/apps/';
|
|
19
|
+
const BOTS_BASE = '/private/bots/';
|
|
20
|
+
|
|
21
|
+
function formatForPath(path) {
|
|
22
|
+
if (path.endsWith('.jsonld')) return 'jsonld';
|
|
23
|
+
return 'anthropic.skill.v1';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function scopeFromPath(path) {
|
|
27
|
+
if (path.startsWith(APPS_BASE)) return 'app';
|
|
28
|
+
if (path.startsWith(BOTS_BASE)) return 'bot';
|
|
29
|
+
return 'pod';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function tryEntry(path) {
|
|
33
|
+
for (const variant of [path, path.replace(/\.md$/, '.jsonld')]) {
|
|
34
|
+
if (await storage.exists(variant)) {
|
|
35
|
+
const s = await storage.stat(variant).catch(() => null);
|
|
36
|
+
return {
|
|
37
|
+
'@id': variant,
|
|
38
|
+
'skill:scope': scopeFromPath(variant),
|
|
39
|
+
'skill:format': formatForPath(variant),
|
|
40
|
+
'skill:source': variant,
|
|
41
|
+
'schema:contentSize': s?.size ?? null
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function listContainerNames(containerPath) {
|
|
49
|
+
if (!(await storage.exists(containerPath))) return [];
|
|
50
|
+
try {
|
|
51
|
+
const entries = await storage.listContainer(containerPath);
|
|
52
|
+
return entries
|
|
53
|
+
.filter(e => e.isDirectory)
|
|
54
|
+
.map(e => e.name);
|
|
55
|
+
} catch {
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Walk the conventional skill locations and return discovered skills.
|
|
62
|
+
*/
|
|
63
|
+
export async function discoverSkills() {
|
|
64
|
+
const items = [];
|
|
65
|
+
|
|
66
|
+
// Pod-wide
|
|
67
|
+
for (const p of POD_ROOT_SKILL) {
|
|
68
|
+
if (await storage.exists(p)) {
|
|
69
|
+
items.push({
|
|
70
|
+
'@id': p,
|
|
71
|
+
'skill:scope': 'pod',
|
|
72
|
+
'skill:format': formatForPath(p),
|
|
73
|
+
'skill:source': p,
|
|
74
|
+
'schema:name': 'pod'
|
|
75
|
+
});
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Apps
|
|
81
|
+
for (const name of await listContainerNames(APPS_BASE)) {
|
|
82
|
+
const skill = await tryEntry(`${APPS_BASE}${name}/SKILL.md`);
|
|
83
|
+
if (skill) {
|
|
84
|
+
skill['schema:name'] = name;
|
|
85
|
+
items.push(skill);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Bots
|
|
90
|
+
for (const name of await listContainerNames(BOTS_BASE)) {
|
|
91
|
+
const skill = await tryEntry(`${BOTS_BASE}${name}/SKILL.md`);
|
|
92
|
+
if (skill) {
|
|
93
|
+
skill['schema:name'] = name;
|
|
94
|
+
items.push(skill);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
'@context': {
|
|
100
|
+
skill: 'urn:skill:',
|
|
101
|
+
schema: 'https://schema.org/'
|
|
102
|
+
},
|
|
103
|
+
'@type': 'skill:SkillIndex',
|
|
104
|
+
'skill:items': items
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Read a single skill file by path (relative to pod root).
|
|
110
|
+
*/
|
|
111
|
+
export async function readSkill(path) {
|
|
112
|
+
if (!path || typeof path !== 'string') {
|
|
113
|
+
throw new Error('skill path required');
|
|
114
|
+
}
|
|
115
|
+
if (!path.startsWith('/')) path = '/' + path;
|
|
116
|
+
if (!(await storage.exists(path))) {
|
|
117
|
+
throw new Error(`skill not found: ${path}`);
|
|
118
|
+
}
|
|
119
|
+
const content = await storage.read(path);
|
|
120
|
+
return {
|
|
121
|
+
path,
|
|
122
|
+
format: formatForPath(path),
|
|
123
|
+
scope: scopeFromPath(path),
|
|
124
|
+
body: content.toString('utf8')
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Read the pod-wide SKILL.md (or .jsonld). Returns null if none exists.
|
|
130
|
+
*/
|
|
131
|
+
export async function readPodSkill() {
|
|
132
|
+
for (const p of POD_ROOT_SKILL) {
|
|
133
|
+
if (await storage.exists(p)) {
|
|
134
|
+
return readSkill(p);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return null;
|
|
138
|
+
}
|