Guardz Generator MCP Server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Guardz Generator MCP Server generate a type guard for the User interface in src/types/user.ts"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Guardz Generator MCP Server
MCP (Model Context Protocol) Server for TypeScript Type Guard Generation
A Model Context Protocol (MCP) server that generates TypeScript type guards from your TypeScript source code, allowing AI assistants to create robust runtime validation functions through a standardized interface.
π― Core Purpose
Generate TypeScript type guards from interfaces, types, unions, intersections, and complex TypeScript types. This is the primary functionality - everything else supports this goal.
Related MCP server: lsp-intelligence
π Primary Feature: Type Guard Generation
What are Type Guards?
Type guards are runtime validation functions that ensure your data matches your TypeScript types:
// Your TypeScript interface
interface User {
id: number;
name: string;
email: string;
isActive: boolean;
}
// Generated type guard
import { isNumber, isString, isBoolean, isType } from 'guardz';
export const isUser = (value: unknown): value is User => {
return isType(value, {
id: isNumber,
name: isString,
email: isString,
isActive: isBoolean,
});
};Complex Type Examples
Generate type guards for complex types:
interface ApiResponse<T> {
success: boolean;
data: T;
message?: string;
timestamp: number;
}
type UserResponse = ApiResponse<User>;Generated type guard:
import { isBoolean, isNumber, isString, isUndefinedOr, isType } from 'guardz';
export const isApiResponse = <T>(
value: unknown,
isT: (value: unknown) => value is T
): value is ApiResponse<T> => {
return isType(value, {
success: isBoolean,
data: isT,
message: isUndefinedOr(isString),
timestamp: isNumber,
});
};
export const isUserResponse = (value: unknown): value is UserResponse => {
return isApiResponse(value, isUser);
};π¦ Installation
npm install guardz-generator-mcpπ§ Setup
1. Install the MCP Server
npm install -g guardz-generator-mcp2. Configure Your MCP Client
For Claude Desktop:
Create or edit your MCP configuration file (usually ~/.config/claude-desktop/mcp-servers.json):
{
"mcpServers": {
"guardz-generator": {
"command": "guardz-generator-mcp",
"env": {
"NODE_ENV": "production"
}
}
}
}For Other MCP Clients:
Add the server to your MCP client configuration:
{
"mcpServers": {
"guardz-generator": {
"command": "npx",
"args": ["guardz-generator-mcp"],
"env": {
"NODE_ENV": "production"
}
}
}
}π MCP Client Compatibility
This MCP server is compatible with many MCP clients across different platforms:
Desktop Applications
Claude Desktop - Anthropic's desktop app
VS Code with GitHub Copilot - Agent mode with MCP support
Warp - Intelligent terminal with MCP integration
Zed - High-performance code editor
Windsurf Editor - Agentic IDE
Theia IDE - AI-powered development environment
oterm - Terminal client for Ollama
Tome - Cross-platform desktop app for local LLMs
Witsy - AI desktop assistant
Web-Based Platforms
MooPoint - Web-based AI chat platform
Msty Studio - Privacy-first AI productivity platform
Superinterface - AI infrastructure platform
Tambo - Platform for building custom chat experiences
TypingMind - Advanced frontend for LLMs
RecurseChat - Local-first chat client
Shortwave - AI-powered email client
WhatsMCP - MCP client for WhatsApp
Development Tools
Postman - API client with MCP server testing
OpenSumi - AI Native IDE framework
Roo Code - AI coding assistance
Zencoder - Coding agent for VS Code and JetBrains IDEs
Enterprise & Cloud Platforms
NVIDIA Agent Intelligence (AIQ) toolkit - Enterprise agent framework
Tencent CloudBase AI DevKit - AI agent building tool
SpinAI - Observable AI agent framework
Superjoin - Google Sheets extension
Mobile Applications
systemprompt - Voice-controlled mobile app (iOS/Android)
π οΈ Available Tools
Primary Tool: generate_type_guards
Generate TypeScript type guards from source files - This is the main functionality.
Parameters:
files(required): Array of TypeScript files to processconfig(optional): Path to config file (defaults toguardz.generator.config.ts)type(optional): Generate type guard for specific typeguardName(optional): Custom name for the type guard functionincludes(optional): Glob patterns for files to includeexcludes(optional): Glob patterns for files to excludepostProcess(optional): Run lint, prettier, and tsc on generated files (default: true)verbose(optional): Enable verbose loggingdebug(optional): Enable debug logging (creates log file)
Example:
{
"name": "generate_type_guards",
"arguments": {
"files": ["src/types/user.ts"],
"postProcess": true,
"verbose": true
}
}Supporting Tools
These tools support the type guard generation workflow:
discover_files
Helper to find TypeScript files for type guard generation
Parameters:
cliFiles(optional): Files specified via CLIcliIncludes(optional): Include patterns from CLIcliExcludes(optional): Exclude patterns from CLIconfigPath(optional): Path to config file
Example:
{
"name": "discover_files",
"arguments": {
"cliFiles": ["src/**/*.ts"],
"cliExcludes": ["**/*.test.ts"]
}
}validate_typescript
Helper to validate TypeScript before generating type guards
Parameters:
files(required): Array of TypeScript files to validate
Example:
{
"name": "validate_typescript",
"arguments": {
"files": ["src/**/*.ts"]
}
}format_code
Helper to format generated type guard code
Parameters:
files(required): Array of files to format
Example:
{
"name": "format_code",
"arguments": {
"files": ["src/**/*.ts"]
}
}lint_code
Helper to lint generated type guard code
Parameters:
files(required): Array of files to lintfix(optional): Automatically fix linting issues
Example:
{
"name": "lint_code",
"arguments": {
"files": ["src/**/*.ts"],
"fix": true
}
}get_project_info
Helper to get project context for type guard generation
Parameters: None
Example:
{
"name": "get_project_info",
"arguments": {}
}π‘ Usage Examples
Basic Type Guard Generation
Generate type guards for all interfaces in your project:
// Your TypeScript interface
interface User {
id: number;
name: string;
email: string;
isActive: boolean;
}The MCP server will generate:
import { isNumber, isString, isBoolean, isType } from 'guardz';
export const isUser = (value: unknown): value is User => {
return isType(value, {
id: isNumber,
name: isString,
email: isString,
isActive: isBoolean,
});
};Complex Type Guards
Generate type guards for complex types:
interface ApiResponse<T> {
success: boolean;
data: T;
message?: string;
timestamp: number;
}
type UserResponse = ApiResponse<User>;Generated type guard:
import { isBoolean, isNumber, isString, isUndefinedOr, isType } from 'guardz';
export const isApiResponse = <T>(
value: unknown,
isT: (value: unknown) => value is T
): value is ApiResponse<T> => {
return isType(value, {
success: isBoolean,
data: isT,
message: isUndefinedOr(isString),
timestamp: isNumber,
});
};
export const isUserResponse = (value: unknown): value is UserResponse => {
return isApiResponse(value, isUser);
};Recursive Type Example
interface TreeNode {
value: number;
children: TreeNode[];
}Generated type guard:
import { isNumber, isArrayWithEachItem, isType } from 'guardz';
export const isTreeNode = (value: unknown): value is TreeNode => {
return isType(value, {
value: isNumber,
children: isArrayWithEachItem(isTreeNode),
});
};Empty Object Type Example
interface Config {
settings: {};
metadata: Record<string, unknown>;
}Generated type guard:
import { isObjectWithEachItem, isType, isUnknown } from 'guardz';
export const isConfig = (value: unknown): value is Config => {
return isType(value, {
settings: isType({}), // Uses isType({}) instead of isType<{}>({})
metadata: isObjectWithEachItem(isUnknown),
});
};ποΈ Architecture
The MCP server is built on top of the robust guardz-generator library and follows the Model Context Protocol specification:
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β MCP Client β β MCP Server β β guardz-generatorβ
β (Claude, etc) βββββΊβ (This Package) βββββΊβ (Core Library) β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββKey Components:
MCP Protocol Layer: Handles JSON-RPC communication with MCP clients
Type Guard Generator: Core logic for generating type guards from TypeScript AST
Tool Handlers: Process specific tool requests (generate, validate, format, etc.)
Service Factory: Manages dependencies and provides access to guardz-generator services
π§ Development
Prerequisites
Node.js 18+
npm or yarn
Setup
Clone the repository:
git clone https://github.com/thiennp/guardz-generator-mcp.git
cd guardz-generator-mcpInstall dependencies:
npm installBuild the project:
npm run buildRun tests:
npm testDevelopment Scripts
npm run build- Build the TypeScript codenpm run dev- Run in development mode with tsxnpm test- Run the test suitenpm run lint- Run ESLintnpm run format- Format code with Prettiernpm run type-check- Run TypeScript type checking
π€ Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
Development Guidelines
Fork the repository
Create a feature branch (
git checkout -b feature/amazing-feature)Commit your changes (
git commit -m 'Add some amazing feature')Push to the branch (
git push origin feature/amazing-feature)Open a Pull Request
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π Acknowledgments
guardz-generator - The core type guard generation library
guardz - The runtime validation library
Model Context Protocol - The protocol specification
Anthropic - For Claude and MCP ecosystem
π Support
Issues: GitHub Issues
Discussions: GitHub Discussions
Documentation: Full Documentation
Made with β€οΈ for the TypeScript community
Available Tools
6 toolsdiscover_filesB
Helper to find TypeScript files for type guard generation
Inputs: cliFiles, configPath, cliExcludes, cliIncludes.
format_codeC
Helper to format generated type guard code
Inputs: files (required).
generate_type_guardsC
Generate TypeScript type guards from source files - PRIMARY FUNCTIONALITY
Inputs: files (required), type, debug, config, +5 more.
get_project_infoC
Helper to get project context for type guard generation
Inputs: no named parameters.
lint_codeB
Helper to lint generated type guard code
Inputs: files (required), fix.
validate_typescriptC
Helper to validate TypeScript before generating type guards
Inputs: files (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
TDQS
Scored across 6 tools
Each tool maps to a distinct stage of the pipeline (discover, validate, generate, format, lint, project info), so boundaries are mostly clear. The only mild overlap is between validate_typescript and lint_code, which an agent might hesitate between, but descriptions clarify intent.
All six tools use a consistent snake_case verb_noun pattern (generate_type_guards, discover_files, validate_typescript, format_code, lint_code, get_project_info). No mixing of conventions or vague standalone verbs.
Six tools is well-scoped for a focused generator server: one primary operation plus five helpers that directly support it. Every tool earns its place with no filler.
The surface covers the full workflow from file discovery through validation, generation, formatting, and linting, plus project context. Minor gaps exist around persisting/writing generated output or batch processing multiple files, but agents can work around these.
Maintenance
Related MCP Connectors
Generate a typed SDK, CLI, and MCP server from any OpenAPI or GraphQL spec, and keep them current.
Convert, lint and generate LLM tool schemas for OpenAI, Anthropic, Gemini and MCP
The OpenZeppelin Solidity Contracts MCP server integrates OpenZeppelin's security and style rules into AI-driven development workflows, enabling AI assistants to generate safe, correct, and production-ready smart contracts. It automatically validates generated code against OpenZeppelin standards (including imports, modifiers, naming conventions, and security checks) and supports various contract types including ERC-20, ERC-721, ERC-1155, Stablecoins, RWA, Governor, and Account contracts through prompt-driven workflows.
GitHub Copilot MCP: code, repo, PR, workflow tools for AI assistants.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceAutomatically generates MCP tools, CLI, and web UI from TypeScript methods, enabling AI agents and chat clients to interact with custom capabilities defined once.90 npm100MIT
- AlicenseNot gradedqualityDmaintenanceMCP server providing 29 tools across 5 layers for semantic TypeScript/JavaScript code intelligence, enabling AI agents to find references, trace impacts, guard APIs, and explain errors without text-search false positives.1MIT
- AlicenseAqualityCmaintenanceEnables AI coding agents to interact with TypeScript projects through compiler-level code intelligence, providing tools for navigation, type information, diagnostics, refactoring, and semantic search.29333 npm5Apache 2.0
- AlicenseAqualityDmaintenanceEnables building MCP servers in TypeScript where tool schemas, descriptions, and validation are automatically generated from class methods, their TypeScript types, and JSDoc comments at compile time.1MIT