fastmcp validate command checks your server file for TypeScript compilation errors and validates that the FastMCP server is properly structured.
Usage
Arguments
Path to your FastMCP server file (TypeScript or JavaScript)
Options
Enable strict TypeScript validation with type checkingAlias:
-sDefault: falseWhat it validates
The validate command performs two types of checks:TypeScript compilation
Ensures your server file compiles without TypeScript errors.With
--strict flag, this uses TypeScript’s strict mode for more thorough type checking.Examples
Basic validation
Check if your server file is valid:Strict validation
Enable strict TypeScript checking for more thorough validation:Validation in CI/CD
Use validate in your continuous integration pipeline:Common errors
File not found
File not found
Error:
[FastMCP Error] File not found: /path/to/file.tsSolution: Verify the file path is correct and the file exists.TypeScript compilation failed
TypeScript compilation failed
Error:
[FastMCP] ✗ TypeScript compilation failedSolution: Fix the TypeScript errors shown in the output. Common issues:- Missing type imports
- Incorrect type annotations
- Syntax errors
--strict to see all type issues:Server structure validation failed
Server structure validation failed
Error:
[FastMCP] ✗ Server structure validation failedSolution: Ensure your file:- Imports FastMCP:
import { FastMCP } from "fastmcp" - Creates an instance:
const server = new FastMCP({ ... }) - Either exports the server or calls
server.start()
Validation vs. Testing
Thevalidate command checks for structural and type correctness but does not:
- Test tool functionality
- Verify runtime behavior
- Check for logical errors
dev command or inspect command.
Exit codes
The validate command uses standard exit codes:| Exit Code | Meaning |
|---|---|
0 | Validation passed successfully |
1 | Validation failed or encountered an error |
Best practices
Next steps
Test with dev
Run your server and test it interactively
Debug with inspect
Use visual debugging with MCP Inspector