We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/venikman/fpf-agent-stack'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
parser.ts•1.18 KiB
import yaml from 'yaml';
import { ParseResult, SkillBoundary } from './types';
/**
* Parses the raw content of a SKILL.md file into Boundary and Kernel.
* Implements the "Knife" rule:
* 1. Boundary = YAML between first --- and second ---
* 2. Kernel = Everything after second ---
*/
export function parseSkill(raw: string): ParseResult {
const trimmed = raw.trim();
if (!trimmed.startsWith('---')) {
throw new Error('Skill file must start with YAML frontmatter delimiter (---)');
}
const parts = trimmed.split('---');
// parts[0] is empty (before first ---)
// parts[1] is YAML content
// parts[2...] is Markdown content (re-joined)
if (parts.length < 3) {
throw new Error('Skill file is missing closing frontmatter delimiter (---)');
}
const yamlContent = parts[1];
const kernelContent = parts.slice(2).join('---'); // Re-join in case body has ---
let boundary: SkillBoundary;
try {
boundary = yaml.parse(yamlContent) as SkillBoundary;
} catch (e) {
throw new Error(`Failed to parse YAML frontmatter: ${e}`);
}
return {
boundary,
kernel: { content: kernelContent },
raw
};
}