Skip to main content
The fastmcp validate command checks your server file for TypeScript compilation errors and validates that the FastMCP server is properly structured.

Usage

Arguments

string
required
Path to your FastMCP server file (TypeScript or JavaScript)

Options

boolean
Enable strict TypeScript validation with type checkingAlias: -sDefault: false

What it validates

The validate command performs two types of checks:
1

TypeScript compilation

Ensures your server file compiles without TypeScript errors.With --strict flag, this uses TypeScript’s strict mode for more thorough type checking.
2

Server structure

Verifies that your file:
  • Properly imports FastMCP
  • Creates a valid FastMCP instance
  • Exports or starts the server correctly

Examples

Basic validation

Check if your server file is valid:
Output on success:

Strict validation

Enable strict TypeScript checking for more thorough validation:
This is useful when you want to catch potential type issues before deployment.

Validation in CI/CD

Use validate in your continuous integration pipeline:

Common errors

Error: [FastMCP Error] File not found: /path/to/file.tsSolution: Verify the file path is correct and the file exists.
Error: [FastMCP] ✗ TypeScript compilation failedSolution: Fix the TypeScript errors shown in the output. Common issues:
  • Missing type imports
  • Incorrect type annotations
  • Syntax errors
Run with --strict to see all type issues:
Error: [FastMCP] ✗ Server structure validation failedSolution: Ensure your file:
  1. Imports FastMCP: import { FastMCP } from "fastmcp"
  2. Creates an instance: const server = new FastMCP({ ... })
  3. Either exports the server or calls server.start()
Example valid structure:

Validation vs. Testing

The validate command checks for structural and type correctness but does not:
  • Test tool functionality
  • Verify runtime behavior
  • Check for logical errors
For runtime testing, use the dev command or inspect command.

Exit codes

The validate command uses standard exit codes: This makes it easy to use in scripts and CI/CD pipelines:

Best practices

1

Validate before committing

Add validation to your pre-commit hooks:
2

Use strict mode in CI

Enable strict validation in your CI/CD pipeline for maximum type safety:
3

Validate all server files

If you have multiple server files, validate them all:

Next steps

Test with dev

Run your server and test it interactively

Debug with inspect

Use visual debugging with MCP Inspector