MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / discoverProtocols

Function discoverProtocols

scripts/build-compliance.cjs:196–221  ·  view source on GitHub ↗
(sourceDir, specialisms)

Source from the content-addressed store, hash-verified

194}
195
196function discoverProtocols(sourceDir, specialisms) {
197 const protocolsDir = path.join(sourceDir, 'protocols');
198 const ids = new Set();
199
200 if (fs.existsSync(protocolsDir)) {
201 for (const entry of fs.readdirSync(protocolsDir, { withFileTypes: true })) {
202 if (entry.isDirectory()) ids.add(entry.name);
203 }
204 }
205 for (const s of specialisms) {
206 if (s.protocol) ids.add(s.protocol);
207 }
208
209 const items = [];
210 for (const id of ids) {
211 const indexPath = path.join(protocolsDir, id, 'index.yaml');
212 const fm = fs.existsSync(indexPath) ? readYamlFrontmatter(indexPath) : {};
213 items.push({
214 id,
215 title: fm.title || null,
216 has_baseline: fs.existsSync(indexPath),
217 path: `protocols/${id}/`
218 });
219 }
220 return items.sort((a, b) => a.id.localeCompare(b.id));
221}
222
223// ── Idempotency lint ────────────────────────────────────────────────
224//

Callers 1

generateIndexFunction · 0.85

Calls 2

readYamlFrontmatterFunction · 0.85
addMethod · 0.80

Tested by

no test coverage detected