agentleFS
reaatechreaatech/mcp-changelog/skills/schema-discovery/SKILL.md

schema-discovery

Skill0 starsChanged 3 months agoMITView on GitHub

The schema-discovery skill provides capabilities for locating and parsing MCP schema files within a git repository. It handles multiple file conventions, malformed JSON, and monorepo-style multi-schema layouts.

13 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use rayfin-functions.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • MicrosoftSkill

    rayfin-functions

    Use when writing Rayfin user-defined functions (UDFs), invoking functions from frontend code, or using functions CLI commands. Triggers: rayfin functions, udf.func, UserDataFunctions, RayfinContext, FabricContext, AppFunctionsSchema, functions init, dev functions apply, client.functions, invoke, func start, function_app.ts, types.ts, rayfin/functions/, FunctionClient, FunctionsSchema, fabric-user-data-functions, functionsBaseUrl, VITE_RAYFIN_FUNCTIONS_URL, bootstrap.ts, rayfinClient.ts

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 4 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 13 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Lazy parsing: Only parse files that match patterns

    line 252
  2. Distinctive:

    Parallel discovery: Check multiple patterns concurrently

    line 253
  3. Distinctive:

    Cache parsed schemas: Avoid re-parsing within a run

    line 254
  4. Distinctive:

    Early termination: Stop at first match for single-schema mode

    line 255

“Common” is measured: kept by at least 6 in 10 of the 13 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Schema Discovery Skill

Purpose

The schema-discovery skill provides capabilities for locating and parsing MCP schema files within a git repository. It handles multiple file conventions, malformed JSON, and monorepo-style multi-schema layouts.

Capabilities

1. Schema File Location

  • Auto-detect schema files by convention
  • Support configurable file patterns
  • Handle glob patterns for multi-schema repos
  • Exclude directories (node_modules, dist, etc.)

2. Schema Parsing

  • Parse JSON and YAML schema files
  • Validate parsed schemas against ToolSnapshot interface
  • Provide helpful error messages for malformed files
  • Support schema version detection

3. Multi-Schema Aggregation

  • Handle repos with multiple schema files
  • Merge or keep separate based on configuration
  • Detect schema conflicts between files
  • Support schema path prefixes for namespacing

Usage Examples

Auto-Detecting Schema Files

import { SchemaLocator } from '@reaatech/mcp-changelog/discovery';

const locator = new SchemaLocator({ repoPath: '/path/to/repo' });

// Auto-detect schema at HEAD
const schemas = await locator.locate('HEAD');
console.log(schemas);
// [
//   {
//     path: 'schema.json',
//     ref: { type: 'tag', name: 'HEAD', sha: '...' },
//     schema: { version: '1.0.0', tools: [...] }
//   }
// ]

// Auto-detect at a specific tag
const v1Schemas = await locator.locate('v1.0.0');

Custom Schema Patterns

import { SchemaLocator, SchemaLocatorConfig } from '@reaatech/mcp-changelog/discovery';

const config: SchemaLocatorConfig = {
  patterns: [
    'mcp-schema.json',
    'api/schema.json',
    '**/*.mcp.json'
  ],
  exclude: ['node_modules/**', 'dist/**', '.git/**']
};

const locator = new SchemaLocator({ repoPath: '/path/to/repo', config });
const schemas = await locator.locate('v2.0.0');

Parsing Schema Files

import { SchemaParser } from '@reaatech/mcp-changelog/discovery';

const parser = new SchemaParser();

// Parse JSON content
const content = '{"version": "1.0.0", "tools": [{"name": "getUser", ...}]}';
const schema = await parser.parse(content, 'schema.json');
console.log(schema.version); // '1.0.0'
console.log(schema.tools.length); // 1

// Parse with error handling
try {
  const badSchema = await parser.parse('{ invalid json }', 'schema.json');
} catch (error) {
  if (error instanceof SchemaParseError) {
    console.error(error.message);
    // "Failed to parse schema.json: Unexpected token 'i' at position 2"
  }
}

Multi-Schema Repository

import { MultiSchemaAggregator } from '@reaatech/mcp-changelog/discovery';

const aggregator = new MultiSchemaAggregator();

// Discover all schemas in a monorepo
const schemas = await aggregator.aggregate({
  ref: 'v1.0.0',
  repoPath: '/path/to/monorepo',
  patterns: ['packages/*/schema.json', 'services/*/mcp.json']
});

console.log(schemas);
// [
//   { path: 'packages/auth/schema.json', schema: {...} },
//   { path: 'services/search/mcp.json', schema: {...} }
// ]

// Compare multi-schema between versions
const { oldSchemas, newSchemas } = await aggregator.aggregateRange({
  from: 'v1.0.0',
  to: 'v2.0.0',
  repoPath: '/path/to/monorepo'
});

Configuration Options

interface SchemaLocatorConfig {
  // File patterns to search for (in priority order)
  patterns: string[];

  // Glob patterns to exclude
  exclude: string[];

  // Whether to search recursively
  recursive: boolean;

  // Maximum depth for recursive search
  maxDepth: number;
}

interface SchemaParserConfig {
  // Strict parsing mode (fail on unknown fields)
  strict: boolean;

  // Allowed schema versions
  allowedVersions: string[];

  // Whether to auto-upgrade old schema formats
  autoUpgrade: boolean;
}

const locatorConfig: SchemaLocatorConfig = {
  patterns: ['schema.json', 'mcp.json', 'tools.json', '**/*.schema.json'],
  exclude: ['node_modules/**', 'dist/**', '.git/**', 'coverage/**'],
  recursive: true,
  maxDepth: 5,
};

const parserConfig: SchemaParserConfig = {
  strict: false,
  allowedVersions: ['1.0.0', '2.0.0'],
  autoUpgrade: true,
};

Schema File Conventions

Auto-detection checks these paths in order (first match wins):

PriorityPatternDescription
1schema.jsonRoot-level schema (most common)
2mcp.jsonAlternative root-level name
3tools.jsonAlternative root-level name
4**/*.schema.jsonGlob for multi-schema repos
5**/mcp.jsonGlob fallback

Best Practices

1. Provide Helpful Parse Errors

// Good: Actionable error
throw new SchemaParseError(filePath, {
  cause: jsonError,
  suggestion: 'Check for trailing commas or unquoted keys'
});

// Bad: Generic error
throw new Error('JSON parse error');

2. Validate Schema Structure

// Good: Validate after parsing
const schema = await parser.parse(content, path);
if (!schema.version) {
  throw new SchemaValidationError('Missing required "version" field');
}
if (!Array.isArray(schema.tools)) {
  throw new SchemaValidationError('"tools" must be an array');
}

// Bad: Trust parsed data
const schema = JSON.parse(content); // May be missing required fields

3. Handle Missing Schemas Gracefully

// Good: Clear error with suggestions
const schemas = await locator.locate(ref);
if (schemas.length === 0) {
  throw new SchemaNotFoundError(ref, {
    searched: config.patterns,
    suggestion: 'Create a schema.json file or configure custom patterns'
  });
}

// Bad: Empty result with no explanation
const schemas = await locator.locate(ref);
if (schemas.length === 0) {
  throw new Error('No schemas found');
}

Error Handling

// Schema file not found
class SchemaNotFoundError extends Error {
  constructor(ref: string, context?: { searched: string[]; suggestion?: string }) {
    super(`No schema file found at ref "${ref}"`);
    this.name = 'SchemaNotFoundError';
  }
}

// Schema parse error
class SchemaParseError extends Error {
  constructor(filePath: string, context?: { cause?: Error; suggestion?: string }) {
    super(`Failed to parse ${filePath}: ${context?.cause?.message}`);
    this.name = 'SchemaParseError';
  }
}

// Schema validation error
class SchemaValidationError extends Error {
  constructor(message: string) {
    super(`Schema validation failed: ${message}`);
    this.name = 'SchemaValidationError';
  }
}

Performance Considerations

  • Lazy parsing: Only parse files that match patterns
  • Parallel discovery: Check multiple patterns concurrently
  • Cache parsed schemas: Avoid re-parsing within a run
  • Early termination: Stop at first match for single-schema mode

Testing Strategies

describe('SchemaLocator', () => {
  it('should find schema.json at repo root', async () => {
    const locator = new SchemaLocator({ repoPath: testRepo });
    const schemas = await locator.locate('HEAD');
    expect(schemas).toHaveLength(1);
    expect(schemas[0].path).toBe('schema.json');
  });

  it('should handle missing schema gracefully', async () => {
    const locator = new SchemaLocator({
      repoPath: emptyRepo,
      config: { patterns: ['nonexistent.json'], exclude: [] }
    });
    await expect(locator.locate('HEAD'))
      .rejects.toThrow(SchemaNotFoundError);
  });

  it('should find multiple schemas with glob pattern', async () => {
    const locator = new SchemaLocator({
      repoPath: monorepo,
      config: { patterns: ['packages/*/schema.json'], exclude: [] }
    });
    const schemas = await locator.locate('HEAD');
    expect(schemas.length).toBeGreaterThan(1);
  });
});

describe('SchemaParser', () => {
  it('should parse valid schema', async () => {
    const parser = new SchemaParser();
    const schema = await parser.parse(validSchemaJson, 'test.json');
    expect(schema.version).toBe('1.0.0');
    expect(schema.tools).toHaveLength(3);
  });

  it('should provide helpful error for malformed JSON', async () => {
    const parser = new SchemaParser();
    await expect(parser.parse('{ invalid }', 'test.json'))
      .rejects.toThrow(SchemaParseError);
  });

  it('should validate required fields', async () => {
    const parser = new SchemaParser();
    await expect(parser.parse('{"tools": []}', 'test.json'))
      .rejects.toThrow(SchemaValidationError);
  });
});

Resources

  • ARCHITECTURE.md - System architecture
  • Schema Discovery section - Detailed module spec
  • mcp-schema-evolution types - ToolSnapshot interface

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.