npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@type-crafter/mcp

v1.3.1

Published

MCP server for Type Crafter - generate types from YAML specifications

Readme

Type Crafter MCP Server

An MCP (Model Context Protocol) server that helps AI assistants write correct Type Crafter YAML specifications.

npm version License: ISC

Why This MCP?

LLMs often make mistakes when writing Type Crafter YAML specs:

| Common Mistake | Why It Fails | | ------------------ | ------------------------------- | | nullable: true | Property doesn't exist | | optional: true | Property doesn't exist | | name?: string | Syntax not supported | | Top-level arrays | Arrays must be properties | | ../relative/path | Paths must be from project root |

This MCP teaches LLMs the correct format and validates specs before generation.

Installation

# Install MCP server
npm install -g @type-crafter/mcp-server

# Also need type-crafter CLI for generation
npm install -g type-crafter

Configuration

Claude Desktop

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "type-crafter": {
      "command": "type-crafter-mcp"
    }
  }
}

From Source

{
  "mcpServers": {
    "type-crafter": {
      "command": "node",
      "args": ["/path/to/type-crafter/mcp/dist/index.js"]
    }
  }
}

Tools

1. get-writing-guide

Call this FIRST. Returns the writing guide and a sessionId.

Parameters: none

Returns:
- sessionId (pass to other tools)
- Quick start guide
- Common mistakes to avoid
- Quick reference table

2. get-rules-section

Get detailed rules for a specific topic.

Parameters:
- sessionId (optional): From get-writing-guide
- section (required): One of:
    - structure   → Root structure, info, types vs groupedTypes
    - types       → Objects, enums, primitives, arrays
    - nullable    → How required array controls nullability
    - references  → $ref syntax, top-file vs non-top-file
    - composition → oneOf (unions), allOf (intersections)
    - patterns    → Common patterns with examples

3. validate-spec

Validate a YAML spec for correctness.

Parameters:
- sessionId (optional): From get-writing-guide
- specFilePath (required): Path to YAML file

Checks:
- Structure (info, types, groupedTypes)
- Common mistakes (nullable, optional, wrong paths)
- Reference rules (top-file vs non-top-file)

4. get-spec-info

Get information about an existing spec file.

Parameters:
- specFilePath (required): Path to YAML file

Returns:
- Version and title
- List of all types
- List of all grouped types

5. list-languages

List supported languages for type-crafter CLI.

Parameters: none

Returns:
- typescript
- typescript-with-decoders

Workflow

┌─────────────────────────────────────────────────────────────┐
│  1. get-writing-guide                                       │
│     └─→ Returns sessionId + guide                           │
│                                                             │
│  2. Write YAML spec (following the guide)                   │
│                                                             │
│  3. validate-spec(sessionId, specFilePath)                  │
│     ├─→ Valid: "Run type-crafter generate..."               │
│     └─→ Errors: Shows issues + suggests get-rules-section   │
│                                                             │
│  4. Fix issues, re-validate                                 │
│                                                             │
│  5. User runs: type-crafter generate typescript spec.yaml   │
└─────────────────────────────────────────────────────────────┘

Session Enforcement

The MCP uses sessions to encourage reading the guide first:

  • get-writing-guide returns a sessionId
  • Pass sessionId to other tools
  • If validation fails with common mistakes AND no sessionId → suggests reading the guide
  • Sessions expire after 30 minutes

YAML Quick Reference

info:
  version: '1.0.0'
  title: 'My Types'

types:
  User:
    type: object
    required:
      - id # Required → string
      - email # Required → string
    properties:
      id: { type: string }
      email: { type: string }
      name: { type: string } # Not in required → string | null

Generated TypeScript:

export type User = {
  id: string;
  email: string;
  name: string | null;
};

Key Rules

| Rule | Correct | Wrong | | ------------------------- | ---------------------------------- | ----------------------- | | Nullable fields | Omit from required array | nullable: true | | Optional fields | Omit from required array | optional: true | | Arrays | Property inside object | Top-level type | | External refs | ./path/from/root/file.yaml#/Type | ../relative/path.yaml | | Same-file refs (top file) | #/types/TypeName | - | | Same-file refs (non-top) | ./this/file.yaml#/TypeName | #/TypeName |

Usage Examples

Creating Types

User: "Create types for a user API with id, email, and optional name"

LLM: [Calls get-writing-guide]
     [Reads the guide, notes required array controls nullability]
     [Creates YAML spec]
     [Calls validate-spec]
     "Here's your valid spec. Run: type-crafter generate typescript ./types.yaml ./output"

Validating Specs

User: "Check if my types.yaml is valid"

LLM: [Calls validate-spec]
     "Found 2 issues:
      1. Line 15: 'nullable: true' doesn't exist - use required array
      2. Line 23: Wrong path format - use ./path/from/root"

Learning Specific Rules

User: "How do references work in Type Crafter?"

LLM: [Calls get-rules-section with section: "references"]
     "References in Type Crafter work like this..."

Troubleshooting

"nullable: true" errors

Type Crafter doesn't have a nullable property. Use the required array:

# Properties in required → non-nullable
# Properties NOT in required → nullable (Type | null)
required:
  - id
  - email
properties:
  id: { type: string } # string
  email: { type: string } # string
  name: { type: string } # string | null

Reference path errors

All paths are from project root (where you run the CLI), not relative to current file:

# Wrong
$ref: '../common/types.yaml#/User'

# Correct
$ref: './src/common/types.yaml#/User'

"Arrays cannot be top-level types"

Arrays must be properties within objects:

# Wrong
Tags:
  type: array
  items: { type: string }

# Correct
Post:
  type: object
  properties:
    tags:
      type: array
      items: { type: string }

Development

# Install dependencies
npm install

# Build
npm run build

# Watch mode
npm run dev

# Lint
npm run lint

License

ISC