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: falseWhat 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: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:
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