The HED MCP (Model Context Protocol) Server provides tools and resources for validating HED (Hierarchical Event Descriptor) data. It implements the Model Context Protocol specification to expose HED validation capabilities to MCP-compatible clients.
- Name:
hed-mcp-server - Version:
1.0.0 - Protocol: MCP (Model Context Protocol)
- Transport: stdio
The server provides the following tools for HED validation:
Validates a string of HED tags using the specified HED schema version.
Parameters:
hedString(string, required): The HED string to validatehedVersion(string, required): The HED schema version to use (e.g., '8.4.0' or 'lang_1.1.0, score_2.1.0')checkForWarnings(boolean, optional): Whether to check for warnings in addition to errors (default: false)definitions(array of strings, optional): Array of definition strings to use during validation
Returns:
{
errors: FormattedIssue[];
warnings: FormattedIssue[];
}Example Usage:
{
"method": "tools/call",
"params": {
"name": "validateHedString",
"arguments": {
"hedString": "Event/Sensory-event, Red, Blue",
"hedVersion": "8.4.0",
"checkForWarnings": true
}
}
}Validates a HED TSV file using the specified HED schema version.
Parameters:
filePath(string, required): The absolute path to the TSV file to validatehedVersion(string, required): The HED schema version to use (e.g., '8.4.0' or 'lang_1.1.0, score_2.1.0')checkForWarnings(boolean, optional): Whether to check for warnings in addition to errors (default: false)fileData(string, optional): Optional file data to use instead of reading from filePathjsonData(string, optional): Optional JSON data string for sidecar informationdefinitions(array of strings, optional): Array of definition strings to use during validation
Returns:
{
errors: FormattedIssue[];
warnings: FormattedIssue[];
}Example Usage:
{
"method": "tools/call",
"params": {
"name": "validateHedTsv",
"arguments": {
"filePath": "/path/to/events.tsv",
"hedVersion": "8.4.0",
"checkForWarnings": true
}
}
}Parses a HED sidecar file using the specified HED schema version.
Parameters:
filePath(string, required): The absolute path to the sidecar file to parsehedVersion(string, required): The HED schema version to use (e.g., '8.4.0' or 'lang_1.1.0, score_2.1.0')checkForWarnings(boolean, optional): Whether to check for warnings in addition to errors (default: false)fileData(string, optional): Optional JSON string containing the sidecar data to use instead of reading from filePath
Returns:
{
parsedHedSidecar: string; // Stringified JSON of the parsed sidecar data
errors: FormattedIssue[];
warnings: FormattedIssue[];
}Example Usage:
{
"method": "tools/call",
"params": {
"name": "parseHedSidecar",
"arguments": {
"filePath": "/path/to/task-events.json",
"hedVersion": "8.4.0",
"checkForWarnings": false
}
}
}The server provides the following resources:
- URI:
hed://schema/latest - Name: HED Schema
- Description: Latest HED (Hierarchical Event Descriptor) schema definition
- MIME Type: application/json
Example Usage:
{
"method": "resources/read",
"params": {
"uri": "hed://schema/latest"
}
}Represents a validation issue (error or warning) found during HED validation.
interface FormattedIssue {
code: string; // Error/warning code (e.g., 'TAG_INVALID', 'SIDECAR_INVALID')
detailedCode: string; // Detailed error code for programmatic handling
severity: string; // 'error' or 'warning'
message: string; // Human-readable error message
column: string; // Column information (if applicable)
line: string; // Line information (if applicable)
location: string; // Location information within the file
}Standard result format for validation operations.
interface HedValidationResult {
errors: FormattedIssue[];
warnings: FormattedIssue[];
}Extended result format specifically for sidecar parsing operations.
interface ParseHedSidecarResult {
parsedHedSidecar: string; // Stringified JSON of the parsed sidecar data
errors: FormattedIssue[];
warnings: FormattedIssue[];
}The server supports various HED schema versions. Common examples include:
- Standard HED versions:
8.3.0,8.4.0,8.5.0 - Library schemas:
lang_1.1.0,score_2.1.0,testlib_2.0.0 - Multiple schemas:
8.4.0, lang_1.1.0, score_2.1.0
The server supports HED definitions for enhanced validation. Definitions are specified as strings in the format:
(Definition/DefinitionName, (HED tags defining the definition))
Examples:
(Definition/MyColor, (Red))(Definition/MyAction, (Action/Move))(Definition/StimulusOnset, (Event/Sensory-event, (Onset)))
All tools follow consistent error handling patterns:
- Schema loading errors: Return
SCHEMA_LOAD_FAILEDcode when an invalid HED version is specified - File reading errors: Return
FILE_READ_ERRORcode when a file cannot be read - JSON parsing errors: Return
INTERNAL_ERRORcode for malformed JSON data - Validation errors: Return specific HED error codes based on the validation issue
npx @modelcontextprotocol/inspector node dist/server.jsThe server can be integrated into any MCP-compatible client. Example server configuration:
{
"servers": {
"hed-mcp": {
"command": "node",
"args": ["dist/server.js"],
"cwd": "/path/to/hed-mcp-typescript"
}
}
}- Schema Caching: The server implements intelligent schema caching to avoid reloading schemas for repeated operations
- Memory Management: Large files are processed efficiently with streaming where possible
- Concurrent Operations: Multiple validation requests can be handled concurrently
The server logs important events to stderr:
- Server startup and initialization
- Schema cache operations
- Error conditions and exceptions
Enable verbose logging by setting appropriate environment variables in your MCP client.